Skip to content

feat: Add initial project structure for QA Test Automation, including… #5

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit 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
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Cypress Dashboard (opcional)
CYPRESS_RECORD_KEY=your-cypress-record-key-here

# API Testing URLs
DEMOQA_BASE_URL=https://demoqa.com
AUTOMATIONEXERCISE_BASE_URL=https://automationexercise.com

# Test Configuration
CYPRESS_BROWSER=chrome
CYPRESS_VIEWPORT_WIDTH=1920
CYPRESS_VIEWPORT_HEIGHT=1080

# Timeouts (ms)
CYPRESS_DEFAULT_COMMAND_TIMEOUT=10000
CYPRESS_PAGE_LOAD_TIMEOUT=30000

# Slack notifications (opcional)
SLACK_WEBHOOK_URL=your-slack-webhook-here
104 changes: 104 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
'cypress/globals': true
},
extends: [
'eslint:recommended',
'@typescript-eslint/recommended',
'plugin:cypress/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: [
'@typescript-eslint',
'cypress'
],
rules: {
// General rules
'indent': ['error', 2],
'linebreak-style': ['error', 'unix'],
'quotes': ['error', 'single'],
'semi': ['error', 'never'],
'no-console': 'warn',
'no-unused-vars': 'error',
'no-var': 'error',
'prefer-const': 'error',
'prefer-arrow-callback': 'error',
'arrow-spacing': 'error',
'no-trailing-spaces': 'error',
'eol-last': 'error',
'comma-dangle': ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'array-bracket-spacing': ['error', 'never'],
'space-before-blocks': 'error',
'keyword-spacing': 'error',
'space-infix-ops': 'error',
'no-multiple-empty-lines': ['error', { 'max': 2 }],
'max-len': ['error', { 'code': 120 }],

// Cypress specific rules
'cypress/no-assigning-return-values': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/assertion-before-screenshot': 'warn',
'cypress/no-force': 'warn',
'cypress/no-async-tests': 'error',
'cypress/no-pause': 'error',
'cypress/no-debug': 'error',
'cypress/require-data-selectors': 'warn',

// TypeScript specific rules
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-inferrable-types': 'off',

// Test specific overrides
'no-undef': 'off' // Cypress globals are handled by the plugin
},
overrides: [
{
files: ['**/*.spec.js', '**/*.spec.ts', '**/*.test.js', '**/*.test.ts'],
rules: {
'no-unused-expressions': 'off',
'cypress/no-unnecessary-waiting': 'warn' // Sometimes needed in tests
}
},
{
files: ['**/page-objects/**/*.js', '**/page-objects/**/*.ts'],
rules: {
'class-methods-use-this': 'off'
}
},
{
files: ['cypress.config.js', '*.config.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
}
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}
},
ignorePatterns: [
'node_modules/',
'dist/',
'build/',
'coverage/',
'tests/reports/',
'tests/videos/',
'tests/screenshots/',
'tests/downloads/',
'*.min.js'
]
}
177 changes: 177 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# πŸš€ GitHub Actions Workflows

This folder contains all the GitHub Actions workflow files for the QA Test Automation project.

## πŸ“ Files Overview

### 1. `ci.yml` - Main CI/CD Pipeline
- **Triggers**: Push to main/develop, Pull requests, Manual dispatch
- **Jobs**:
- πŸ”§ Setup & Lint
- πŸ”Œ API Testing (Cypress + Newman)
- 🌐 E2E Testing (Chrome, Firefox, Edge)
- 🎯 DemoQA Tests
- πŸͺ AutomationExercise Tests
- πŸ’¨ Smoke Tests (PR only)
- β™Ώ Accessibility Tests
- πŸ”’ Security Audit
- πŸ“Š Test Summary
- πŸ“’ Notifications

### 2. `nightly.yml` - Comprehensive Nightly Tests
- **Triggers**: Daily at 2 AM UTC, Manual dispatch
- **Jobs**:
- 🎯 DemoQA Full Regression (all browsers + viewports)
- πŸͺ AutomationExercise Full Regression
- πŸ”Œ API Full Regression
- ⚑ Performance Tests
- β™Ώ Comprehensive Accessibility
- 🎯 Cross-Browser Matrix
- πŸ“Š Nightly Summary
- πŸ“’ Nightly Notifications

### 3. `deploy-reports.yml` - Test Reports Deployment
- **Triggers**: After successful CI/CD runs, Manual dispatch
- **Features**:
- πŸ—οΈ Builds beautiful HTML report site
- πŸš€ Deploys to GitHub Pages
- πŸ“Š Organizes reports by category
- πŸ”— Creates navigation links

## πŸ› οΈ Setup Instructions

### Step 1: Copy Files to GitHub Actions
```bash
# From project root, copy all files to .github/workflows/
cp workflow/*.yml .github/workflows/
```

### Step 2: Configure GitHub Secrets
Go to **Repository Settings > Secrets and variables > Actions** and add:

**Required:**
```
CYPRESS_RECORD_KEY=your-cypress-dashboard-key
```

**Optional:**
```
SLACK_WEBHOOK=https://hooks.slack.com/services/YOUR/WEBHOOK
SNYK_TOKEN=your-snyk-token-here
```

### Step 3: Enable GitHub Pages
1. Go to **Repository Settings > Pages**
2. Source: **Deploy from a branch**
3. Branch: **gh-pages** (will be created automatically)
4. Your reports will be available at: `https://yourusername.github.io/your-repo-name`

### Step 4: Create .env File (Optional)
See `environment-variables.md` for all available environment variables.

## πŸ“Š Test Execution Matrix

### CI Pipeline Tests
| Test Type | Browsers | Triggers |
|-----------|----------|----------|
| API Tests | N/A | All pushes, PRs |
| E2E Tests | Chrome, Firefox, Edge | All pushes, PRs |
| DemoQA | Chrome, Firefox | All pushes, PRs |
| AutomationExercise | Chrome, Firefox | All pushes, PRs |
| Smoke Tests | Chrome | PRs only |
| Accessibility | Chrome | All pushes, PRs |

### Nightly Tests
| Test Type | Browsers | Viewports |
|-----------|----------|-----------|
| DemoQA Regression | Chrome, Firefox, Edge | Desktop, Tablet, Mobile |
| AutomationExercise Regression | Chrome, Firefox, Edge | Desktop, Tablet, Mobile |
| API Regression | N/A | N/A |
| Performance | Chrome | Desktop |
| Accessibility | Chrome, Firefox | Desktop |

## 🎯 Available Scripts

### Updated package.json Scripts
The following scripts were added/updated to support CI/CD:

```json
{
"test:api": "cypress run --spec 'tests/e2e/**/api.spec.js'",
"test:e2e:chrome": "cypress run --browser chrome",
"test:e2e:firefox": "cypress run --browser firefox",
"test:e2e:edge": "cypress run --browser edge",
"test:demoqa:chrome": "cypress run --spec 'tests/e2e/demoqa/**/*.spec.js' --browser chrome",
"test:automationexercise:chrome": "cypress run --spec 'tests/e2e/automationexercise/**/*.spec.js' --browser chrome",
"test:smoke": "cypress run --env grepTags=@smoke",
"test:a11y": "cypress run --env grepTags=@accessibility",
"test:performance": "cypress run --env grepTags=@performance",
"test:newman": "newman run tests/api/automationexercise-collection.json -e tests/api/environment.json --reporters json,cli --reporter-json-export newman-results.json"
}
```

## πŸ”§ Cypress Configuration Updates

### Added CI/CD Features
- βœ… CI-specific timeouts (15s instead of 10s)
- βœ… Video recording control via environment variables
- βœ… Enhanced browser launch options for headless CI
- βœ… Environment variable overrides
- βœ… CI detection and configuration
- βœ… Custom tasks for CI information

## πŸ“ˆ Features

### πŸš€ Parallel Execution
- Multiple browsers tested simultaneously
- Separate jobs for different test suites
- Matrix strategy for comprehensive coverage

### πŸ“Š Comprehensive Reporting
- Mochawesome HTML reports
- Newman API test reports
- Accessibility reports
- Performance metrics
- Screenshot and video artifacts

### πŸ”„ Smart Scheduling
- **CI Pipeline**: On every push and PR
- **Smoke Tests**: Only on PRs (faster feedback)
- **Nightly Tests**: Full regression at 2 AM UTC
- **Reports Deployment**: After successful runs

### πŸ”” Notifications
- Slack integration for build status
- Different channels for regular vs nightly tests
- Rich notifications with run details

### πŸ›‘οΈ Security & Quality
- ESLint code quality checks
- Prettier formatting validation
- npm audit for security vulnerabilities
- Snyk security scanning
- Accessibility compliance testing

## 🎨 Reports Website

The deployed reports website includes:
- 🏠 **Homepage** with navigation to all reports
- πŸ“Š **Statistics** dashboard
- 🎯 **Categorized reports** (API, E2E, DemoQA, AutomationExercise, A11y, Nightly)
- πŸ“± **Responsive design**
- πŸ”— **Direct links** to GitHub Actions runs

## πŸš€ Getting Started

1. **Copy workflow files**: `cp workflow/*.yml .github/workflows/`
2. **Configure secrets** in GitHub repository settings
3. **Push to main branch** to trigger first CI run
4. **Check Actions tab** to see workflows running
5. **View reports** at your GitHub Pages URL

## πŸ“ž Support

- Check `environment-variables.md` for configuration options
- Review individual workflow files for specific job details
- GitHub Actions logs provide detailed execution information
- Test reports include screenshots and videos for debugging
Loading