Skip to content
Draft
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d0088b8
e2e specs
hahn-kev Jul 16, 2025
837732f
create e2e test directory
hahn-kev Jul 16, 2025
c2eb8bf
add a health check endpoint
hahn-kev Jul 16, 2025
27d6186
implement fw lite launcher and tests
hahn-kev Jul 16, 2025
46b33ed
setup test data managment
hahn-kev Jul 16, 2025
9478006
setup server operations helper
hahn-kev Jul 16, 2025
93c9aaf
ensure e2e test server is used for lexbox server
hahn-kev Jul 16, 2025
bcb0bef
set environment to development to allow oauth to work with self signe…
hahn-kev Jul 16, 2025
8f0b38e
main integration tests
hahn-kev Jul 16, 2025
0a3ac6a
rename config server to lexboxServer for clarity
hahn-kev Jul 16, 2025
fc01abe
put an id on the server div for testing
hahn-kev Jul 16, 2025
28b2ab0
ensure we never redirect to the login page, instead redirect home
hahn-kev Jul 16, 2025
2ff9146
fix integration tests so they work
hahn-kev Jul 16, 2025
14871fb
get some more tests passing
hahn-kev Jul 16, 2025
2d61419
cleanup unused stuff
hahn-kev Jul 31, 2025
ff70b5f
Merge branch 'develop' into e2e-test-fw-lite
hahn-kev Jul 31, 2025
27afd18
move tests into snapshots folder, along with their playwright config
hahn-kev Jul 31, 2025
4d5b458
split playwright tests into snapshot and e2e
hahn-kev Jul 31, 2025
8349a74
rework the tests, add helper endpoint for deleting a project
hahn-kev Jul 31, 2025
73e8527
ignore test results
hahn-kev Jul 31, 2025
53fcfe5
update ci to run snapshot tests
hahn-kev Jul 31, 2025
b85e0a2
add e2e workflow job
hahn-kev Jul 31, 2025
48734fc
cleanup a bunch of junk from the AI
hahn-kev Jul 31, 2025
26213dd
pre test the fw lite launcher
hahn-kev Jul 31, 2025
6cb67d6
Merge branch 'develop' into e2e-test-fw-lite
hahn-kev Jul 31, 2025
049787d
correct pnpm script in taskfile
hahn-kev Aug 1, 2025
b4f3058
don't hardcode the binary path for the launcher tests
hahn-kev Aug 5, 2025
af03204
ensure the correct path for permissions
hahn-kev Aug 5, 2025
f83dca4
Merge branch 'develop' into e2e-test-fw-lite
hahn-kev Sep 9, 2025
85fd9ff
Handle null checks in `Directory.SetCurrentDirectory` to avoid potent…
hahn-kev Sep 9, 2025
dacc37f
Improve shutdown handling for FW Lite on Windows and add stdin-trigge…
hahn-kev Sep 9, 2025
29404de
Upload Playwright test results and traces on failure in FW Lite workflow
hahn-kev Sep 9, 2025
e1166d3
log server output in playwright test output folder
hahn-kev Sep 10, 2025
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
57 changes: 56 additions & 1 deletion .github/workflows/fw-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
run: pnpm exec playwright install --with-deps
- name: Run snapshot tests
working-directory: frontend/viewer
run: task playwright-test-standalone
run: task test:snapshot-standalone
- name: Build viewer
working-directory: frontend/viewer
run: pnpm run build
Expand Down Expand Up @@ -405,3 +405,58 @@
sleep 10
curl -X POST https://lexbox.org/api/fwlite-release/new-release
e2e-test:
name: E2E Tests
needs: [publish-linux]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- uses: actions/download-artifact@v4
id: download-artifact
with:
name: fw-lite-web-linux
path: fw-lite-web-linux
- name: set execute permissions
run: chmod +x fw-lite-web-linux/*/FwLiteWeb
- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 #v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
package_json_file: 'frontend/package.json'
- uses: actions/setup-node@v4
with:
node-version-file: './frontend/package.json'
cache: 'pnpm'
cache-dependency-path: './frontend/pnpm-lock.yaml'
- name: Prepare frontend
working-directory: frontend
run: |
pnpm install
- name: Test fw lite launcher
working-directory: frontend/viewer
env:
FW_LITE_BINARY_PATH: ${{ steps.download-artifact.outputs.download-path }}/release_linux-x64/FwLiteWeb
run: task e2e-test-helper-unit-tests

- uses: ./.github/actions/setup-k8s
with:
lexbox-api-tag: develop
ingress-controller-port: '6579' # todo, figure out if we can use https as it's required for the tests
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Playwright dependencies
working-directory: frontend/viewer
run: pnpm exec playwright install --with-deps

- name: Run E2E tests
working-directory: frontend/viewer
env:
FW_LITE_BINARY_PATH: ${{ steps.download-artifact.outputs.download-path }}/release_linux-x64/FwLiteWeb
TEST_SERVER_PORT: 6579
run: task test:e2e
278 changes: 278 additions & 0 deletions .kiro/specs/fw-lite-e2e-tests/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
# Design Document

## Overview

The FW Lite E2E Testing Framework provides automated end-to-end testing for FW Lite integration with LexBox. The system uses Playwright for UI automation and integrates with the existing GitHub Actions CI/CD pipeline to ensure critical workflows continue to function after code changes.

The framework follows the existing testing patterns established in the project, extending the current Playwright setup in `frontend/viewer` to include full application testing scenarios that span the entire FW Lite to LexBox integration workflow.

## Architecture

### High-Level Architecture

```mermaid
graph TB
A[GitHub Actions Trigger] --> B[FW Lite Build Workflow]
B --> C[E2E Test Workflow]
C --> D[Test Environment Setup]
D --> E[FW Lite Application Launch]
E --> F[Playwright Test Execution]
F --> G[Test Results & Artifacts]

subgraph "Test Environment"
H[FW Lite Linux Binary]
I[Test Server Configuration]
J[Test Data Setup]
end

subgraph "Test Scenarios"
K[Project Download Test]
L[Entry Creation Test]
M[Data Persistence Test]
N[Media File Test]
O[Live Sync Test]
end

D --> H
D --> I
D --> J
F --> K
F --> L
F --> M
F --> N
F --> O
```

### Workflow Integration

The E2E tests integrate with the existing CI/CD pipeline by:

1. **Triggering after successful FW Lite builds** - Uses the `needs` dependency in GitHub Actions
2. **Consuming build artifacts** - Downloads the Linux FW Lite binary from the previous workflow
3. **Configurable server targeting** - Can run against different environments (local, staging, production)
4. **Artifact preservation** - Uploads test results, screenshots, and logs for debugging

### Test Environment Architecture

```mermaid
graph LR
A[GitHub Runner] --> B[FW Lite Binary]
A --> C[Playwright Browser]
B --> D[LexBox Server]
C --> B
D --> E[Test Projects]
D --> F[Test Users]
```

## Components and Interfaces

### 1. GitHub Actions Workflow (`fw-lite-e2e-tests.yaml`)

**Purpose**: Orchestrates the E2E testing process
**Location**: `.github/workflows/fw-lite-e2e-tests.yaml`

**Key Features**:
- Triggers after successful `publish-linux` job in fw-lite workflow
- Downloads FW Lite Linux artifacts
- Sets up test environment with configurable server endpoints
- Executes Playwright tests
- Uploads test results and failure artifacts

**Configuration Interface**:
```yaml
env:
TEST_SERVER_HOSTNAME: ${{ vars.TEST_SERVER_HOSTNAME || 'localhost:5137' }}
TEST_PROJECT_CODE: 'sena-3'
TEST_DEFAULT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD || 'pass' }}
FW_LITE_BINARY_PATH: './fw-lite-linux/linux-x64/FwLiteWeb'
```

### 2. Playwright Test Suite

**Purpose**: Implements the actual E2E test scenarios
**Location**: `frontend/viewer/tests/e2e/`

**Test Structure**:
```
frontend/viewer/tests/e2e/
├── fw-lite-integration.test.ts # Main integration test
├── helpers/
│ ├── fw-lite-launcher.ts # FW Lite application management
│ ├── project-operations.ts # Project download/management helpers
│ └── test-data.ts # Test data constants and utilities
└── fixtures/
└── test-projects.json # Expected test project configurations
```

### 3. FW Lite Application Manager

**Purpose**: Manages FW Lite application lifecycle during tests
**Location**: `frontend/viewer/tests/e2e/helpers/fw-lite-launcher.ts`

**Interface**:
```typescript
interface FwLiteManager {
launch(config: LaunchConfig): Promise<void>
shutdown(): Promise<void>
isRunning(): boolean
getBaseUrl(): string
}

interface LaunchConfig {
binaryPath: string
serverUrl: string
port?: number
timeout?: number
}
```

### 4. Test Data Management

**Purpose**: Provides consistent test data and expectations
**Location**: `frontend/viewer/tests/e2e/helpers/test-data.ts`

**Interface**:
```typescript
interface TestProject {
code: string
name: string
expectedEntries: number
testUser: string
}

interface TestEntry {
lexeme: string
definition: string
partOfSpeech: string
uniqueIdentifier: string
}
```

## Data Models

### Test Configuration Model

```typescript
interface E2ETestConfig {
server: {
hostname: string
protocol: 'http' | 'https'
port?: number
}
fwLite: {
binaryPath: string
launchTimeout: number
shutdownTimeout: number
}
testData: {
projectCode: string
testUser: string
testPassword: string
}
timeouts: {
projectDownload: number
entryCreation: number
dataSync: number
}
}
```

### Test Result Model

```typescript
interface TestResult {
testName: string
status: 'passed' | 'failed' | 'skipped'
duration: number
error?: string
screenshots: string[]
logs: string[]
}
```

## Error Handling

### Application Launch Failures

- **Timeout handling**: If FW Lite fails to start within the configured timeout, the test fails with clear error messaging
- **Port conflicts**: Automatic port detection and retry logic
- **Binary validation**: Pre-flight checks to ensure the FW Lite binary exists and is executable

### Network and Server Issues

- **Connection retries**: Implement exponential backoff for server connection attempts
- **Server availability checks**: Validate server endpoints before starting tests
- **Graceful degradation**: Skip tests that require unavailable services with clear reporting

### Test Data Issues

- **Project availability**: Verify expected test projects exist before running tests
- **User authentication**: Handle authentication failures with clear error messages
- **Data conflicts**: Implement cleanup strategies for test data conflicts

### Playwright-Specific Error Handling

```typescript
// Example error handling pattern
try {
await page.waitForSelector('[data-testid="project-list"]', { timeout: 30000 })
} catch (error) {
await page.screenshot({ path: 'failure-project-list.png' })
throw new Error(`Project list failed to load: ${error.message}`)
}
```

## Testing Strategy

### Test Categories

1. **Smoke Tests**: Basic application launch and connectivity
2. **Integration Tests**: Full workflow scenarios (download → modify → sync)
3. **Data Persistence Tests**: Verify data survives application restarts
4. **Media File Tests**: Ensure media files are properly handled
5. **Live Sync Tests**: Verify real-time synchronization functionality

### Test Data Strategy

- **Predictable test projects**: Use known projects like 'sena-3' with expected data
- **Unique test identifiers**: Generate unique identifiers for test entries to avoid conflicts
- **Cleanup procedures**: Implement cleanup for test data after test completion
- **Isolation**: Ensure tests don't interfere with each other

### Parallel Execution Strategy

- **Sequential execution**: Run E2E tests sequentially to avoid resource conflicts
- **Test isolation**: Each test scenario operates on separate data sets
- **Resource management**: Proper cleanup between test scenarios

### Retry and Flaky Test Handling

```typescript
// Retry configuration for flaky operations
const retryConfig = {
projectDownload: { attempts: 3, delay: 5000 },
entryCreation: { attempts: 2, delay: 2000 },
dataSync: { attempts: 3, delay: 3000 }
}
```

### Test Environment Matrix

The tests will be designed to run against multiple environments:

- **Local Development**: `localhost:5137`
- **Staging Environment**: Configured via environment variables
- **Production Environment**: Limited test scenarios for critical path validation

### Performance Considerations

- **Test execution time**: Target total execution time under 15 minutes
- **Resource usage**: Monitor memory and CPU usage during test execution
- **Artifact size management**: Compress and limit screenshot/video artifacts

### Reporting and Observability

- **Test result aggregation**: Comprehensive test reports with pass/fail statistics
- **Failure analysis**: Detailed logs and screenshots for failed tests
- **Trend analysis**: Track test execution times and failure patterns over time
- **Integration with existing reporting**: Leverage existing GitHub Actions test reporting
Loading
Loading