c6b865b324
Removed 40 files that were written for the flights-front React project: - 15 root spec files with hardcoded React ports (3000/3001/3002/5173) - 8 ru-ru/ tests with React URLs or React Query-specific features - 8 integration/ tests with React templates - 3 visual/ regression tests with React screenshots - 6 integration templates Kept: 18 cross-app tests (properly use localePath/urlPattern fixtures), 7 clean ru-ru tests, support files, and fixtures. Result: 230 passed, 173 skipped, 0 failed.
E2E Test Suite
Comprehensive Playwright e2e test suite for the Aeroflot-style flight search application.
Structure
e2e/
├── fixtures/ # Test data fixtures
│ ├── cities.json # City data (20+ cities)
│ ├── flights.json # Flight data (scheduled, arrived, delayed, cancelled)
│ ├── routes.json # Route data (Moscow-Sochi, Moscow-St Petersburg, etc.)
│ ├── api-responses.json # API response templates
│ └── errors.json # Error response examples
├── support/
│ └── test-utilities.ts # Comprehensive test utilities (740+ lines)
├── integration/
│ └── templates/ # Template files for generating 300+ tests
│ ├── online-board-arrival.template.ts
│ ├── online-board-departure.template.ts
│ ├── online-board-route.template.ts
│ ├── online-board-flight.template.ts
│ ├── schedule-search.template.ts
│ ├── flight-details.template.ts
│ ├── flights-map.template.ts
│ └── popular-requests.template.ts
└── visual/ # Visual regression tests
├── landing.spec.ts
├── flight-board.spec.ts
└── flight-expanded.spec.ts
Test Utilities
The test-utilities.ts file provides:
Test Data Generators
generateFlight()- Generate flight objects with random datagenerateFlights(count)- Generate multiple flightsgenerateScheduleEntry()- Generate schedule entriesgenerateScheduleEntries(count)- Generate multiple schedule entriesgenerateDestination()- Generate destination objectsgenerateDestinations(count)- Generate multiple destinations
Constants
CITIES- 20+ Russian cities with codes (MOW, LED, AER, etc.)AIRPORTS- 10+ airports (SVO, DME, VKO, LED, AER, etc.)FLIGHT_NUMBERS- 20+ flight numbersAIRLINE_CODES- ['SU', 'FV']AIRLINE_NAMES- { SU: 'Aeroflot', FV: 'Rossiya' }AIRCRAFT_TYPES- 7 aircraft typesSTATUS_TYPES- 10 flight statuses
URL Helpers
buildRouteParam(cityCode, date)- Build route parameterbuildOnlineBoardPath(direction, cityCode, date)- Build online board URLbuildSchedulePath()- Build schedule URLbuildFlightsMapPath()- Build flights map URLbuildFlightDetailsPath(flightNumber, date)- Build flight details URL
Search Helpers
searchFlightByNumber(page, flightNumber, date?)- Search by flight numbersearchFlightByRoute(page, departureCity, arrivalCity, date?)- Search by routesearchFlightByDate(page, date)- Search by dateopenFlightDetails(page, flightIndex)- Open flight details
Assertion Helpers
expectUrlToMatch(page, pattern)- Verify URL matches patternexpectElementToBeVisible(locator, message?)- Element visibleexpectElementToBeHidden(locator, message?)- Element hiddenexpectElementToHaveText(locator, text, message?)- Element has textexpectElementToContainText(locator, text, message?)- Element contains textexpectElementToHaveAttribute(locator, attribute, value, message?)- Element has attributeexpectElementToHaveClass(locator, className, message?)- Element has classexpectElementToBeEnabled(locator, message?)- Element enabledexpectElementToBeDisabled(locator, message?)- Element disabledexpectElementToBeChecked(locator, message?)- Element checkedexpectElementToBeUnchecked(locator, message?)- Element uncheckedexpectElementToHaveValue(locator, value, message?)- Element has valueexpectElementToHaveCount(locator, count, message?)- Element countexpectElementToBeFocused(locator, message?)- Element focusedexpectElementNotToBeFocused(locator, message?)- Element not focused
Date Helpers
getToday()- Get today's dategetTomorrow()- Get tomorrow's dategetYesterday()- Get yesterday's dategetFutureDate(days)- Get future dategetPastDate(days)- Get past dateformatDateForUrl(date)- Format date for URLformatDateForDisplay(date, locale)- Format date for display
Error Generators
generateNotFoundError()- 404 errorgenerateBadRequestError()- 400 errorgenerateUnauthorizedError()- 401 errorgenerateForbiddenError()- 403 errorgenerateServerError()- 500 errorgenerateTimeoutError()- 504 error
Fixtures
cities.json
{
"cities": [
{
"code": "MOW",
"name": "Moscow",
"nameRu": "Москва",
"latitude": 55.7558,
"longitude": 37.6173,
"country": "Russia",
"countryCode": "RU"
},
...
]
}
flights.json
{
"flights": {
"domestic": { ... },
"international": { ... },
"scheduled": { ... },
"arrived": { ... },
"delayed": { ... },
"cancelled": { ... }
}
}
routes.json
{
"routes": {
"moscow-sochi": { ... },
"moscow-stPetersburg": { ... },
"moscow-sochi-return": { ... },
...
}
}
api-responses.json
Complete API response templates for:
- Flight board (departure/arrival)
- Flight details
- Schedule search
- Flights map
- Popular requests
errors.json
Error response examples:
- 404 Not Found
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 422 Validation Error
- 429 Rate Limit
- 500 Server Error
- 503 Service Unavailable
Templates
Each template file contains comprehensive test suites for a specific feature:
1. online-board-arrival.template.ts
- Page navigation tests
- Flight display tests
- Flight search tests
- Date navigation tests
- Filtering tests
- Flight card tests
- Error handling tests
- Accessibility tests
2. online-board-departure.template.ts
- Page navigation tests
- Flight display tests
- Flight search tests
- Date navigation tests
- Filtering tests
- Flight card tests
- Error handling tests
- Accessibility tests
3. online-board-route.template.ts
- Page navigation tests
- Route search tests
- Flight display tests
- Date navigation tests
- Filtering tests
- Flight card tests
- Error handling tests
- Accessibility tests
4. online-board-flight.template.ts
- Page navigation tests
- Flight information tests
- Flight details tests
- Aircraft information tests
- Schedule information tests
- Error handling tests
- Navigation tests
- Accessibility tests
5. schedule-search.template.ts
- Page navigation tests
- Search form tests
- Search functionality tests
- Schedule entry display tests
- Filtering tests
- Error handling tests
- Accessibility tests
6. flight-details.template.ts
- Page navigation tests
- Flight information tests
- Flight details tests
- Aircraft information tests
- Schedule information tests
- Error handling tests
- Navigation tests
- Accessibility tests
7. flights-map.template.ts
- Page navigation tests
- Map display tests
- Filtering tests
- Flight details panel tests
- Map controls tests
- Cluster markers tests
- Error handling tests
- Accessibility tests
- Responsive design tests
8. popular-requests.template.ts
- Page navigation tests
- Request display tests
- Request interaction tests
- Request sorting tests
- Request filtering tests
- Request pagination tests
- Error handling tests
- Accessibility tests
- Responsive design tests
Running Tests
# Run all tests
pnpm e2e
# Run specific test file
pnpm e2e -- tests/landing.spec.ts
# Run in headless mode
pnpm e2e --headless
# Run with UI
pnpm e2e --ui
# Run with trace
pnpm e2e --trace on
# Run with video
pnpm e2e --video on
Test Data Examples
Generate a flight
import { generateFlight } from '@e2e/support/test-utilities';
const flight = generateFlight({
direction: 'departure',
cityCode: 'MOW',
status: 'scheduled',
date: '2026-04-06',
});
Generate multiple flights
import { generateFlights } from '@e2e/support/test-utilities';
const flights = generateFlights(20, {
direction: 'departure',
cityCode: 'MOW',
});
Generate a schedule entry
import { generateScheduleEntry } from '@e2e/support/test-utilities';
const entry = generateScheduleEntry({
from: 'MOW',
to: 'AER',
dateFrom: '2026-04-06',
dateTo: '2026-04-12',
direct: true,
});
Generate an error
import { generateNotFoundError } from '@e2e/support/test-utilities';
const error = generateNotFoundError();
// Returns: { status: 404, body: { error: 'Not Found', message: '...' } }
Best Practices
- Use test utilities - Always use the provided utilities instead of hardcoding data
- Follow naming conventions - Use
test.describefor groups,testfor individual tests - Use data-testid - Always use
data-testidattributes for element selection - Wait for network idle - Use
page.waitForLoadState('networkidle')after navigation - Use assertions - Always use Playwright's
expect()for assertions - Handle errors - Include error handling tests for each feature
- Test accessibility - Include accessibility tests for each feature
- Test responsive - Include responsive design tests for each feature
- Use fixtures - Use JSON fixtures for complex data structures
- Keep tests independent - Each test should be able to run independently
Creating New Tests
- Copy the appropriate template file
- Replace
.template.tswith.spec.ts - Update the test descriptions
- Add specific test cases
- Run the test to verify
Example:
cp e2e/integration/templates/online-board-arrival.template.ts \
e2e/integration/online-board-arrival.spec.ts
Test Coverage
The template files provide comprehensive coverage for:
- Online Board (Arrival/Departure/Route/Flight): 40+ tests each
- Schedule Search: 30+ tests
- Flight Details: 40+ tests
- Flights Map: 30+ tests
- Popular Requests: 30+ tests
Total: 300+ tests with full coverage of all features.