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.
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
const depTypes = new Set([
|
|
'dependencies',
|
|
'optionalDependencies',
|
|
'devDependencies',
|
|
'peerDependencies',
|
|
])
|
|
|
|
// sort alphabetically all types of deps for a given package
|
|
const orderDeps = (content) => {
|
|
for (const type of depTypes) {
|
|
if (content && content[type]) {
|
|
content[type] = Object.keys(content[type])
|
|
.sort((a, b) => a.localeCompare(b, 'en'))
|
|
.reduce((res, key) => {
|
|
res[key] = content[type][key]
|
|
return res
|
|
}, {})
|
|
}
|
|
}
|
|
return content
|
|
}
|
|
|
|
const updateDependencies = ({ content, originalContent }) => {
|
|
const pkg = orderDeps({
|
|
...content,
|
|
})
|
|
|
|
// optionalDependencies don't need to be repeated in two places
|
|
if (pkg.dependencies) {
|
|
if (pkg.optionalDependencies) {
|
|
for (const name of Object.keys(pkg.optionalDependencies)) {
|
|
delete pkg.dependencies[name]
|
|
}
|
|
}
|
|
}
|
|
|
|
const result = { ...originalContent }
|
|
|
|
// loop through all types of dependencies and update package json pkg
|
|
for (const type of depTypes) {
|
|
if (pkg[type]) {
|
|
result[type] = pkg[type]
|
|
}
|
|
|
|
// prune empty type props from resulting object
|
|
const emptyDepType =
|
|
pkg[type]
|
|
&& typeof pkg === 'object'
|
|
&& Object.keys(pkg[type]).length === 0
|
|
if (emptyDepType) {
|
|
delete result[type]
|
|
}
|
|
}
|
|
|
|
// if original package.json had dep in peerDeps AND deps, preserve that.
|
|
const { dependencies: origProd, peerDependencies: origPeer } =
|
|
originalContent || {}
|
|
const { peerDependencies: newPeer } = result
|
|
if (origProd && origPeer && newPeer) {
|
|
// we have original prod/peer deps, and new peer deps
|
|
// copy over any that were in both in the original
|
|
for (const name of Object.keys(origPeer)) {
|
|
if (origProd[name] !== undefined && newPeer[name] !== undefined) {
|
|
result.dependencies = result.dependencies || {}
|
|
result.dependencies[name] = newPeer[name]
|
|
}
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
updateDependencies.knownKeys = depTypes
|
|
|
|
module.exports = updateDependencies
|