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.
122 lines
3.2 KiB
JavaScript
122 lines
3.2 KiB
JavaScript
'use strict';
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const fs = require('fs');
|
|
const ini = require('ini');
|
|
|
|
const isWindows = process.platform === 'win32';
|
|
|
|
const readRc = filePath => {
|
|
try {
|
|
return ini.parse(fs.readFileSync(filePath, 'utf8')).prefix;
|
|
} catch {}
|
|
};
|
|
|
|
const getEnvNpmPrefix = () => {
|
|
// TODO: Remove the `.reduce` call.
|
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
return Object.keys(process.env).reduce((prefix, name) => {
|
|
return /^npm_config_prefix$/i.test(name) ? process.env[name] : prefix;
|
|
}, undefined);
|
|
};
|
|
|
|
const getGlobalNpmrc = () => {
|
|
if (isWindows && process.env.APPDATA) {
|
|
// Hardcoded contents of `c:\Program Files\nodejs\node_modules\npm\npmrc`
|
|
return path.join(process.env.APPDATA, '/npm/etc/npmrc');
|
|
}
|
|
|
|
// Homebrew special case: `$(brew --prefix)/lib/node_modules/npm/npmrc`
|
|
if (process.execPath.includes('/Cellar/node')) {
|
|
const homebrewPrefix = process.execPath.slice(0, process.execPath.indexOf('/Cellar/node'));
|
|
return path.join(homebrewPrefix, '/lib/node_modules/npm/npmrc');
|
|
}
|
|
|
|
if (process.execPath.endsWith('/bin/node')) {
|
|
const installDir = path.dirname(path.dirname(process.execPath));
|
|
return path.join(installDir, '/etc/npmrc');
|
|
}
|
|
};
|
|
|
|
const getDefaultNpmPrefix = () => {
|
|
if (isWindows) {
|
|
const {APPDATA} = process.env;
|
|
// `c:\node\node.exe` → `prefix=c:\node\`
|
|
return APPDATA ? path.join(APPDATA, 'npm') : path.dirname(process.execPath);
|
|
}
|
|
|
|
// `/usr/local/bin/node` → `prefix=/usr/local`
|
|
return path.dirname(path.dirname(process.execPath));
|
|
};
|
|
|
|
const getNpmPrefix = () => {
|
|
const envPrefix = getEnvNpmPrefix();
|
|
if (envPrefix) {
|
|
return envPrefix;
|
|
}
|
|
|
|
const homePrefix = readRc(path.join(os.homedir(), '.npmrc'));
|
|
if (homePrefix) {
|
|
return homePrefix;
|
|
}
|
|
|
|
if (process.env.PREFIX) {
|
|
return process.env.PREFIX;
|
|
}
|
|
|
|
const globalPrefix = readRc(getGlobalNpmrc());
|
|
if (globalPrefix) {
|
|
return globalPrefix;
|
|
}
|
|
|
|
return getDefaultNpmPrefix();
|
|
};
|
|
|
|
const npmPrefix = path.resolve(getNpmPrefix());
|
|
|
|
const getYarnWindowsDirectory = () => {
|
|
if (isWindows && process.env.LOCALAPPDATA) {
|
|
const dir = path.join(process.env.LOCALAPPDATA, 'Yarn');
|
|
if (fs.existsSync(dir)) {
|
|
return dir;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
const getYarnPrefix = () => {
|
|
if (process.env.PREFIX) {
|
|
return process.env.PREFIX;
|
|
}
|
|
|
|
const windowsPrefix = getYarnWindowsDirectory();
|
|
if (windowsPrefix) {
|
|
return windowsPrefix;
|
|
}
|
|
|
|
const configPrefix = path.join(os.homedir(), '.config/yarn');
|
|
if (fs.existsSync(configPrefix)) {
|
|
return configPrefix;
|
|
}
|
|
|
|
const homePrefix = path.join(os.homedir(), '.yarn-config');
|
|
if (fs.existsSync(homePrefix)) {
|
|
return homePrefix;
|
|
}
|
|
|
|
// Yarn supports the npm conventions but the inverse is not true
|
|
return npmPrefix;
|
|
};
|
|
|
|
exports.npm = {};
|
|
exports.npm.prefix = npmPrefix;
|
|
exports.npm.packages = path.join(npmPrefix, isWindows ? 'node_modules' : 'lib/node_modules');
|
|
exports.npm.binaries = isWindows ? npmPrefix : path.join(npmPrefix, 'bin');
|
|
|
|
const yarnPrefix = path.resolve(getYarnPrefix());
|
|
exports.yarn = {};
|
|
exports.yarn.prefix = yarnPrefix;
|
|
exports.yarn.packages = path.join(yarnPrefix, getYarnWindowsDirectory() ? 'Data/global/node_modules' : 'global/node_modules');
|
|
exports.yarn.binaries = path.join(exports.yarn.packages, '.bin');
|