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.
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import type {AddedKeywordDefinition} from "../types"
|
|
|
|
const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"] as const
|
|
|
|
export type JSONType = (typeof _jsonTypes)[number]
|
|
|
|
const jsonTypes: Set<string> = new Set(_jsonTypes)
|
|
|
|
export function isJSONType(x: unknown): x is JSONType {
|
|
return typeof x == "string" && jsonTypes.has(x)
|
|
}
|
|
|
|
type ValidationTypes = {
|
|
[K in JSONType]: boolean | RuleGroup | undefined
|
|
}
|
|
|
|
export interface ValidationRules {
|
|
rules: RuleGroup[]
|
|
post: RuleGroup
|
|
all: {[Key in string]?: boolean | Rule} // rules that have to be validated
|
|
keywords: {[Key in string]?: boolean} // all known keywords (superset of "all")
|
|
types: ValidationTypes
|
|
}
|
|
|
|
export interface RuleGroup {
|
|
type?: JSONType
|
|
rules: Rule[]
|
|
}
|
|
|
|
// This interface wraps KeywordDefinition because definition can have multiple keywords
|
|
export interface Rule {
|
|
keyword: string
|
|
definition: AddedKeywordDefinition
|
|
}
|
|
|
|
export function getRules(): ValidationRules {
|
|
const groups: Record<"number" | "string" | "array" | "object", RuleGroup> = {
|
|
number: {type: "number", rules: []},
|
|
string: {type: "string", rules: []},
|
|
array: {type: "array", rules: []},
|
|
object: {type: "object", rules: []},
|
|
}
|
|
return {
|
|
types: {...groups, integer: true, boolean: true, null: true},
|
|
rules: [{rules: []}, groups.number, groups.string, groups.array, groups.object],
|
|
post: {rules: []},
|
|
all: {},
|
|
keywords: {},
|
|
}
|
|
}
|