60e2149072
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.
72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
const { serializeError } = require('./error')
|
|
|
|
const deepMap = (input, handler = v => v, path = ['$'], seen = new Set([input])) => {
|
|
// this is in an effort to maintain bole's error logging behavior
|
|
if (path.join('.') === '$' && input instanceof Error) {
|
|
return deepMap({ err: serializeError(input) }, handler, path, seen)
|
|
}
|
|
if (input instanceof Error) {
|
|
return deepMap(serializeError(input), handler, path, seen)
|
|
}
|
|
// allows for non-node js environments, sush as workers
|
|
if (typeof Buffer !== 'undefined' && input instanceof Buffer) {
|
|
return `[unable to log instanceof buffer]`
|
|
}
|
|
if (input instanceof Uint8Array) {
|
|
return `[unable to log instanceof Uint8Array]`
|
|
}
|
|
|
|
if (Array.isArray(input)) {
|
|
const result = []
|
|
for (let i = 0; i < input.length; i++) {
|
|
const element = input[i]
|
|
const elementPath = [...path, i]
|
|
if (element instanceof Object) {
|
|
if (!seen.has(element)) { // avoid getting stuck in circular reference
|
|
seen.add(element)
|
|
result.push(deepMap(handler(element, elementPath), handler, elementPath, seen))
|
|
}
|
|
} else {
|
|
result.push(handler(element, elementPath))
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
if (input === null) {
|
|
return null
|
|
} else if (typeof input === 'object' || typeof input === 'function') {
|
|
const result = {}
|
|
|
|
for (const propertyName of Object.getOwnPropertyNames(input)) {
|
|
// skip logging internal properties
|
|
if (propertyName.startsWith('_')) {
|
|
continue
|
|
}
|
|
|
|
try {
|
|
const property = input[propertyName]
|
|
const propertyPath = [...path, propertyName]
|
|
if (property instanceof Object) {
|
|
if (!seen.has(property)) { // avoid getting stuck in circular reference
|
|
seen.add(property)
|
|
result[propertyName] = deepMap(
|
|
handler(property, propertyPath), handler, propertyPath, seen
|
|
)
|
|
}
|
|
} else {
|
|
result[propertyName] = handler(property, propertyPath)
|
|
}
|
|
} catch (err) {
|
|
// a getter may throw an error
|
|
result[propertyName] = `[error getting value: ${err.message}]`
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
return handler(input, path)
|
|
}
|
|
|
|
module.exports = { deepMap }
|