- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { FunctionCov, RangeCov, ScriptCov } from "./types";
|
|
|
|
/**
|
|
* Compares two script coverages.
|
|
*
|
|
* The result corresponds to the comparison of their `url` value (alphabetical sort).
|
|
*/
|
|
export function compareScriptCovs(a: Readonly<ScriptCov>, b: Readonly<ScriptCov>): number {
|
|
if (a.url === b.url) {
|
|
return 0;
|
|
} else if (a.url < b.url) {
|
|
return -1;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Compares two function coverages.
|
|
*
|
|
* The result corresponds to the comparison of the root ranges.
|
|
*/
|
|
export function compareFunctionCovs(a: Readonly<FunctionCov>, b: Readonly<FunctionCov>): number {
|
|
return compareRangeCovs(a.ranges[0], b.ranges[0]);
|
|
}
|
|
|
|
/**
|
|
* Compares two range coverages.
|
|
*
|
|
* The ranges are first ordered by ascending `startOffset` and then by
|
|
* descending `endOffset`.
|
|
* This corresponds to a pre-order tree traversal.
|
|
*/
|
|
export function compareRangeCovs(a: Readonly<RangeCov>, b: Readonly<RangeCov>): number {
|
|
if (a.startOffset !== b.startOffset) {
|
|
return a.startOffset - b.startOffset;
|
|
} else {
|
|
return b.endOffset - a.endOffset;
|
|
}
|
|
}
|