Skip to content
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
88 changes: 88 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: E2E Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

# Restrict permissions for security
permissions:
contents: read

jobs:
e2e-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: services/dashboard-service/package-lock.json

- name: Install dependencies
working-directory: services/dashboard-service
run: npm ci

- name: Install Playwright Browsers
working-directory: services/dashboard-service
run: npx playwright install chromium --with-deps

- name: Build dashboard service
working-directory: services/dashboard-service
run: npm run build

- name: Run E2E tests
working-directory: services/dashboard-service
run: npm run test:e2e
env:
CI: true
E2E_BASE_URL: http://localhost:3001

- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: services/dashboard-service/playwright-report/
retention-days: 30

- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: services/dashboard-service/test-results/
retention-days: 30

e2e-tests-summary:
runs-on: ubuntu-latest
needs: e2e-tests
if: always()
permissions: {}
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The e2e-tests-summary job has permissions: {} which may prevent it from writing to GITHUB_STEP_SUMMARY. Consider granting at least contents: read permission or removing the explicit empty permissions block to inherit from the workflow level.

Suggested change
permissions: {}

Copilot uses AI. Check for mistakes.

steps:
- name: E2E Test Summary
run: |
echo "## E2E Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.e2e-tests.result }}" == "success" ]; then
echo "✅ All E2E tests passed!" >> $GITHUB_STEP_SUMMARY
else
echo "❌ E2E tests failed. Check the Playwright report for details." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
Comment on lines +78 to +82
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The Playwright configuration disables the automatic web server in CI, but the GitHub Actions workflow does not manually start one, causing all E2E tests to fail.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The playwright.config.ts file sets the webServer option to undefined when the CI environment variable is true. The e2e-tests.yml workflow sets CI: true and runs npm run test:e2e without a preceding step to start the application server, such as npm run start. As a result, Playwright attempts to navigate to http://localhost:3001, but no server is listening. This will cause an immediate connection failure for all E2E tests running in the CI environment.

💡 Suggested Fix

In the .github/workflows/e2e-tests.yml file, add a step to start the web server in the background before the Run E2E tests step. For example, run npm run start before npm run test:e2e.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: .github/workflows/e2e-tests.yml#L78-L82

Potential issue: The `playwright.config.ts` file sets the `webServer` option to
`undefined` when the `CI` environment variable is true. The `e2e-tests.yml` workflow
sets `CI: true` and runs `npm run test:e2e` without a preceding step to start the
application server, such as `npm run start`. As a result, Playwright attempts to
navigate to `http://localhost:3001`, but no server is listening. This will cause an
immediate connection failure for all E2E tests running in the CI environment.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7905710

echo "### Pipeline Stages Tested" >> $GITHUB_STEP_SUMMARY
echo "- Job Scrape Pipeline" >> $GITHUB_STEP_SUMMARY
echo "- Pipeline Match/Filter" >> $GITHUB_STEP_SUMMARY
echo "- Resume Tailoring" >> $GITHUB_STEP_SUMMARY
echo "- Form Fill/Application" >> $GITHUB_STEP_SUMMARY
echo "- Dashboard Reporting" >> $GITHUB_STEP_SUMMARY
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ coverage/
.nyc_output
.coverage

# Playwright
playwright-report/
playwright/.cache
test-results/
blob-report/

# TypeScript
*.tsbuildinfo

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# AJOB4AGENT - Autonomous Job Application System

![E2E Tests](https://github.com/groupthinking/AJOB4AGENT/workflows/E2E%20Tests/badge.svg)
![CI/CD Pipeline](https://github.com/groupthinking/AJOB4AGENT/workflows/CI%2FCD%20Pipeline/badge.svg)

An intelligent, microservices-based platform that automates job search, application submission, and recruiter outreach across multiple job platforms including LinkedIn, Glassdoor, and Wellfound.

## 🚀 Features
Expand Down
279 changes: 279 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
# Testing Documentation

![E2E Tests](https://github.com/groupthinking/AJOB4AGENT/workflows/E2E%20Tests/badge.svg)

This document describes the testing infrastructure for AJOB4AGENT, including unit tests, integration tests, and end-to-end (E2E) tests.

## Table of Contents

- [Overview](#overview)
- [Test Structure](#test-structure)
- [E2E Tests](#e2e-tests)
- [Running Tests](#running-tests)
- [CI Integration](#ci-integration)
- [Writing Tests](#writing-tests)

## Overview

AJOB4AGENT uses a multi-layer testing strategy:

1. **Unit Tests**: Test individual functions and components in isolation
2. **Integration Tests**: Test service interactions and API endpoints
3. **E2E Tests**: Test complete user workflows using Playwright

## Test Structure

```
AJOB4AGENT/
├── tests/
│ └── integration-test.sh # Service integration tests
├── services/
│ ├── dashboard-service/
│ │ ├── src/__tests__/ # Unit tests (Jest)
│ │ │ └── app.test.tsx
│ │ ├── e2e/ # E2E tests (Playwright)
│ │ │ ├── mocks/
│ │ │ │ └── api-mocks.ts # API mock handlers
│ │ │ ├── dashboard.spec.ts # Dashboard reporting tests
│ │ │ ├── job-scrape.spec.ts # Job scrape pipeline tests
│ │ │ ├── pipeline-match.spec.ts # Pipeline matching tests
│ │ │ ├── resume-tailoring.spec.ts # Resume tailoring tests
│ │ │ └── form-fill.spec.ts # Application form fill tests
│ │ └── playwright.config.ts # Playwright configuration
│ └── agent-orchestrator/
│ └── src/__tests__/ # Unit tests (Jest)
│ └── app.test.ts
```

## E2E Tests

E2E tests cover the following pipeline stages:

### 1. Job Scrape Pipeline (`job-scrape.spec.ts`)
- Job search across multiple platforms
- Platform discovery and listing
- Search parameter handling
- Empty results handling
- API timeout handling

### 2. Pipeline Match (`pipeline-match.spec.ts`)
- Job scoring display
- Filter criteria application
- Status tracking through pipeline stages
- Match percentage display

### 3. Resume Tailoring (`resume-tailoring.spec.ts`)
- LLM service integration
- Resume generation status
- Cover letter creation
- Confidence score display
- Failure handling

### 4. Form Fill (`form-fill.spec.ts`)
- Application submission status
- Platform-specific flows (LinkedIn, Glassdoor, Wellfound)
- Form fill failures
- Processing stage tracking

### 5. Dashboard Reporting (`dashboard.spec.ts`)
- Application logs display
- Status indicators (success/failure)
- Table rendering
- Error state handling

## Running Tests

### Prerequisites

- Node.js 18+
- npm 9+
- Playwright browsers (installed automatically)

### Install Dependencies

```bash
# Dashboard service
cd services/dashboard-service
npm install

# Install Playwright browsers
npx playwright install chromium
```

### Run E2E Tests

```bash
# Run all E2E tests
npm run test:e2e

# Run with UI mode (interactive)
npm run test:e2e:ui

# Run in headed mode (see browser)
npm run test:e2e:headed

# View HTML report after test run
npm run test:e2e:report
```

### Run Unit Tests

```bash
# Dashboard service
cd services/dashboard-service
npm test

# Agent orchestrator
cd services/agent-orchestrator
npm test
```

### Run Integration Tests

```bash
# Run full integration test suite (requires Docker)
./tests/integration-test.sh

# Run specific test
./tests/integration-test.sh health
./tests/integration-test.sh llm
./tests/integration-test.sh orchestrator
./tests/integration-test.sh dashboard
```

## CI Integration

E2E tests run automatically on:
- Push to `main` or `develop` branches
- Pull requests to `main`

### GitHub Actions Workflow

The E2E test workflow (`.github/workflows/e2e-tests.yml`) includes:

1. **Setup**: Install Node.js and dependencies
2. **Browser Install**: Install Playwright Chromium browser
3. **Build**: Build the dashboard service
4. **Test**: Run all E2E tests
5. **Report**: Upload test artifacts and reports

### Test Artifacts

After each CI run, the following artifacts are available:

- **playwright-report**: HTML test report
- **test-results**: JUnit XML results

## Writing Tests

### E2E Test Example

```typescript
import { test, expect } from '@playwright/test';
import { setupDashboardMocks } from './mocks/api-mocks';

test.describe('My Feature', () => {
test.beforeEach(async ({ page }) => {
// Setup API mocks
await setupDashboardMocks(page);
});

test('should do something', async ({ page }) => {
await page.goto('/');

// Wait for element
await expect(page.getByRole('heading')).toBeVisible();

// Verify content
await expect(page.getByText('Expected text')).toBeVisible();
});
});
```

### Mock API Responses

Use the mock handlers in `e2e/mocks/api-mocks.ts`:

```typescript
import { setupAllMocks } from './mocks/api-mocks';

test.beforeEach(async ({ page }) => {
await setupAllMocks(page);
});
```

Or setup specific mocks:

```typescript
import {
setupDashboardMocks,
setupJobSearchMocks,
setupTailoringMocks,
setupOrchestratorMocks
} from './mocks/api-mocks';
```

### Custom Mock Data

Override default mock data for specific tests:

```typescript
test('custom scenario', async ({ page }) => {
await page.route('**/api/logs', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify([
// Your custom mock data
]),
});
});
});
```

## Best Practices

1. **Use mocks for external APIs**: Ensures test reliability
2. **Test user-visible behavior**: Focus on what users see
3. **Keep tests independent**: Each test should be able to run alone
4. **Use semantic selectors**: Prefer role-based selectors over classes/IDs
5. **Handle async operations**: Use proper waiting strategies

## Troubleshooting

### Tests timing out

Increase timeout in `playwright.config.ts`:
```typescript
export default defineConfig({
timeout: 60000, // 60 seconds
});
```

### Browser not installed

Run:
```bash
npx playwright install chromium --with-deps
```

### Port already in use

Stop any running dev servers or change the port:
```bash
E2E_BASE_URL=http://localhost:3002 npm run test:e2e
```

## Coverage

Current E2E test coverage by pipeline stage:

| Stage | Tests | Status |
|-------|-------|--------|
| Job Scrape | 7 | ✅ |
| Pipeline Match | 5 | ✅ |
| Resume Tailoring | 6 | ✅ |
| Form Fill | 9 | ✅ |
| Dashboard | 8 | ✅ |

**Total: 35 E2E tests across 5 pipeline stages**
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The total test count is incorrect. According to the table, the sum is 7 + 5 + 6 + 9 + 8 = 35 tests, but the description mentions 33 tests. Please verify and update to match the actual count.

Copilot uses AI. Check for mistakes.
Loading
Loading