Skip to content

TK-0001 New scenarios for front and back #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run Cypress Tests

on:
push:
branches: ["**"]
schedule:
- cron: '0 */2 * * *'

jobs:
cypress-run:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install

- name: Run Cypress tests (headless mode)
run: npx cypress run

- name: Upload videos and screenshots (on failure)
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-artifacts
path: |
cypress/videos
cypress/screenshots
130 changes: 130 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,133 @@ A few tips:
## 🏁 Good luck and happy testing

If you have any questions, don’t hesitate to reach out. 🧪💬




////////////////////////////////////////////////////////////////////////////////////


````markdown
# Cypress Automation Project - AutomationExercise

## Description

This project includes automated end-to-end (E2E) tests using Cypress for the AutomationExercise platform. It covers UI tests for different site features, API validations using Postman, basic code coverage metrics, and an optional setup for CI with GitHub Actions.

---

### Project Selection Justification

I chose [AutomationExercise](https://automationexercise.com) as the target application because it simulates a comprehensive e-commerce platform, including key flows such as user login, product browsing, cart management, and API endpoints. This allowed me to build realistic test cases for both **UI** and **API** layers.

The site provides a stable and predictable environment, which is ideal for implementing reliable and maintainable automated tests. It also exposes a public API, enabling backend verification and negative testing scenarios.

By testing this platform, I was able to simulate real-world interactions and validate the system both through the UI and API. This dual-layer strategy reflects a practical and scalable QA approach for real production environments.

---

## Tools & Technologies

- **Cypress**: Main E2E test automation framework using JavaScript.
- **Postman**: For manual and automated REST API validation.
- **GitHub Actions**: (optional) To execute tests automatically on every pull request.
- **nyc / cypress-coverage**: To collect basic code coverage metrics (basic config included).

---

## Folder Structure

```txt
cypress/
├── e2e/
│ ├── pages/ # Page objects for UI tests
│ ├── tests/ # Cypress E2E test files
├── fixtures/ # Test data (e.g., users)
├── support/ # Custom commands and setup
postman/
├── collections/ # Postman collections for API tests
├── environments/ # Postman environment variables
````

---

## How to Run the Tests

### Prerequisites

* Node.js installed (v16+ recommended)
* npm or yarn installed

### Steps to Run UI Tests with Cypress

1. Clone the repository:

```bash
git clone <repo-url>
cd <project-folder>
```

2. Install dependencies:

```bash
npm install
```

3. Open Cypress Test Runner (GUI mode):

```bash
npx cypress open
```

4. Run all tests in headless mode (CLI):

```bash
npx cypress run
```

### Running API Tests with Postman

* Import the Postman collection from `postman/collections/AutomationExercise_API.postman_collection.json`
* Run the requests manually or using a runner in Postman
* Each request includes test scripts validating response codes and payload structures

---

## Code Coverage

The project includes a basic configuration for `cypress-coverage` using `nyc`. Coverage reports are generated automatically and can help identify untested areas for improvement.

---

## API Coverage and Validation with Postman

| ID | API | Method | URL | Expected Code | Description |
| ---- | ---------------------------------- | ------ | ----------------------------------------------------------------- | ------------- | -------------------------------------------------- |
| API1 | Get All Products List | GET | [productsList](https://automationexercise.com/api/productsList) | 200 | Validates that the product list is returned. |
| API5 | POST to Search Product | POST | [searchProduct](https://automationexercise.com/api/searchProduct) | 200 | Validates product search with a valid parameter. |
| API7 | POST Verify Login (valid) | POST | [verifyLogin](https://automationexercise.com/api/verifyLogin) | 200 | Validates login with correct email/password. |


---

# API Testing with Newman + HTML Report

## Prerequisites

- [Node.js](https://nodejs.org/) installed (v12+)
- Postman Collection (`NaNLabsTest.postman_collection.json`)
- Postman Environment file (`Dev.postman_environment.json`)

---

## Installation & Execution (1 step)

Install Newman, the HTML reporter, and run the tests with one command:

```bash
npm install -g newman newman-reporter-htmlextra && \
newman run NaNLabsTest.postman_collection.json \
-e Dev.postman_environment.json \
-r htmlextra \
--reporter-htmlextra-title "NanLabs Test"
6 changes: 6 additions & 0 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1749167217536" clover="3.2.0">
<project timestamp="1749167217536" name="All files">
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
</project>
</coverage>
1 change: 1 addition & 0 deletions coverage/coverage-final.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"total": {"lines":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"statements":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"functions":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"branches":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
}
Loading