Files
flights_web_raw/e2e/node_modules/npm-install-checks/lib/dev-engines.js
T
gnezim 60e2149072 Add comprehensive e2e test suites for Tasks 16-25
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date)
- Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class
- Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting
- Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states
- Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions
- Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation

Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares)
- Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline
- Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements
- Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations
- Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary
- Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds

All tests follow AAA pattern and use data-testid selectors matching Angular version.
Total: 245 tests across 10 feature suites.
2026-04-05 19:25:03 +03:00

146 lines
4.0 KiB
JavaScript

const satisfies = require('semver/functions/satisfies')
const validRange = require('semver/ranges/valid')
const recognizedOnFail = [
'ignore',
'warn',
'error',
'download',
]
const recognizedProperties = [
'name',
'version',
'onFail',
]
const recognizedEngines = [
'packageManager',
'runtime',
'cpu',
'libc',
'os',
]
/** checks a devEngine dependency */
function checkDependency (wanted, current, opts) {
const { engine } = opts
if ((typeof wanted !== 'object' || wanted === null) || Array.isArray(wanted)) {
throw new Error(`Invalid non-object value for "${engine}"`)
}
const properties = Object.keys(wanted)
for (const prop of properties) {
if (!recognizedProperties.includes(prop)) {
throw new Error(`Invalid property "${prop}" for "${engine}"`)
}
}
if (!properties.includes('name')) {
throw new Error(`Missing "name" property for "${engine}"`)
}
if (typeof wanted.name !== 'string') {
throw new Error(`Invalid non-string value for "name" within "${engine}"`)
}
if (typeof current.name !== 'string' || current.name === '') {
throw new Error(`Unable to determine "name" for "${engine}"`)
}
if (properties.includes('onFail')) {
if (typeof wanted.onFail !== 'string') {
throw new Error(`Invalid non-string value for "onFail" within "${engine}"`)
}
if (!recognizedOnFail.includes(wanted.onFail)) {
throw new Error(`Invalid onFail value "${wanted.onFail}" for "${engine}"`)
}
}
if (wanted.name !== current.name) {
return new Error(
`Invalid name "${wanted.name}" does not match "${current.name}" for "${engine}"`
)
}
if (properties.includes('version')) {
if (typeof wanted.version !== 'string') {
throw new Error(`Invalid non-string value for "version" within "${engine}"`)
}
if (typeof current.version !== 'string' || current.version === '') {
throw new Error(`Unable to determine "version" for "${engine}" "${wanted.name}"`)
}
if (validRange(wanted.version)) {
if (!satisfies(current.version, wanted.version, opts.semver)) {
return new Error(
// eslint-disable-next-line max-len
`Invalid semver version "${wanted.version}" does not match "${current.version}" for "${engine}"`
)
}
} else if (wanted.version !== current.version) {
return new Error(
`Invalid version "${wanted.version}" does not match "${current.version}" for "${engine}"`
)
}
}
}
/** checks devEngines package property and returns array of warnings / errors */
function checkDevEngines (wanted, current = {}, opts = {}) {
if ((typeof wanted !== 'object' || wanted === null) || Array.isArray(wanted)) {
throw new Error(`Invalid non-object value for "devEngines"`)
}
const errors = []
for (const engine of Object.keys(wanted)) {
if (!recognizedEngines.includes(engine)) {
throw new Error(`Invalid property "devEngines.${engine}"`)
}
const dependencyAsAuthored = wanted[engine]
const dependencies = [dependencyAsAuthored].flat()
const currentEngine = current[engine] || {}
// this accounts for empty array eg { runtime: [] } and ignores it
if (dependencies.length === 0) {
continue
}
const depErrors = []
for (const dep of dependencies) {
const result = checkDependency(dep, currentEngine, { ...opts, engine })
if (result) {
depErrors.push(result)
}
}
const invalid = depErrors.length === dependencies.length
if (invalid) {
const lastDependency = dependencies[dependencies.length - 1]
let onFail = lastDependency.onFail || 'error'
if (onFail === 'download') {
onFail = 'error'
}
const err = Object.assign(new Error(`Invalid devEngines.${engine}`), {
errors: depErrors,
engine,
isWarn: onFail === 'warn',
isError: onFail === 'error',
current: currentEngine,
required: dependencyAsAuthored,
})
errors.push(err)
}
}
return errors
}
module.exports = {
checkDevEngines,
}