Files
flights_web_raw/node_modules/hono/dist/router/linear-router/router.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

119 lines
4.7 KiB
JavaScript

// src/router/linear-router/router.ts
import { METHOD_NAME_ALL, UnsupportedPathError } from "../../router.js";
import { checkOptionalParameter } from "../../utils/url.js";
var emptyParams = /* @__PURE__ */ Object.create(null);
var splitPathRe = /\/(:\w+(?:{(?:(?:{[\d,]+})|[^}])+})?)|\/[^\/\?]+|(\?)/g;
var splitByStarRe = /\*/;
var LinearRouter = class {
name = "LinearRouter";
#routes = [];
add(method, path, handler) {
for (let i = 0, paths = checkOptionalParameter(path) || [path], len = paths.length; i < len; i++) {
this.#routes.push([method, paths[i], handler]);
}
}
match(method, path) {
const handlers = [];
ROUTES_LOOP: for (let i = 0, len = this.#routes.length; i < len; i++) {
const [routeMethod, routePath, handler] = this.#routes[i];
if (routeMethod === method || routeMethod === METHOD_NAME_ALL) {
if (routePath === "*" || routePath === "/*") {
handlers.push([handler, emptyParams]);
continue;
}
const hasStar = routePath.indexOf("*") !== -1;
const hasLabel = routePath.indexOf(":") !== -1;
if (!hasStar && !hasLabel) {
if (routePath === path || routePath + "/" === path) {
handlers.push([handler, emptyParams]);
}
} else if (hasStar && !hasLabel) {
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
const parts = (endsWithStar ? routePath.slice(0, -2) : routePath).split(splitByStarRe);
const lastIndex = parts.length - 1;
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
const part = parts[j];
const index = path.indexOf(part, pos);
if (index !== pos) {
continue ROUTES_LOOP;
}
pos += part.length;
if (j === lastIndex) {
if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
continue ROUTES_LOOP;
}
} else {
const index2 = path.indexOf("/", pos);
if (index2 === -1) {
continue ROUTES_LOOP;
}
pos = index2;
}
}
handlers.push([handler, emptyParams]);
} else if (hasLabel && !hasStar) {
const params = /* @__PURE__ */ Object.create(null);
const parts = routePath.match(splitPathRe);
const lastIndex = parts.length - 1;
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
if (pos === -1 || pos >= path.length) {
continue ROUTES_LOOP;
}
const part = parts[j];
if (part.charCodeAt(1) === 58) {
if (path.charCodeAt(pos) !== 47) {
continue ROUTES_LOOP;
}
let name = part.slice(2);
let value;
if (name.charCodeAt(name.length - 1) === 125) {
const openBracePos = name.indexOf("{");
const next = parts[j + 1];
const lookahead = next && next[1] !== ":" && next[1] !== "*" ? `(?=${next})` : "";
const pattern = name.slice(openBracePos + 1, -1) + lookahead;
const restPath = path.slice(pos + 1);
const match = new RegExp(pattern, "d").exec(restPath);
if (!match || match.indices[0][0] !== 0 || match.indices[0][1] === 0) {
continue ROUTES_LOOP;
}
name = name.slice(0, openBracePos);
value = restPath.slice(...match.indices[0]);
pos += match.indices[0][1] + 1;
} else {
let endValuePos = path.indexOf("/", pos + 1);
if (endValuePos === -1) {
if (pos + 1 === path.length) {
continue ROUTES_LOOP;
}
endValuePos = path.length;
}
value = path.slice(pos + 1, endValuePos);
pos = endValuePos;
}
params[name] ||= value;
} else {
const index = path.indexOf(part, pos);
if (index !== pos) {
continue ROUTES_LOOP;
}
pos += part.length;
}
if (j === lastIndex) {
if (pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
continue ROUTES_LOOP;
}
}
}
handlers.push([handler, params]);
} else if (hasLabel && hasStar) {
throw new UnsupportedPathError();
}
}
}
return [handlers];
}
};
export {
LinearRouter
};