v1.11.0: hide open-package rows with no grounded plane at the origin (ISS-159)
CI / build + unit + e2e (pull_request) Successful in 5m25s
CI / build + unit + e2e (pull_request) Successful in 5m25s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { cargoWeightFor, loadEligiblePlanes } from './RightPane';
|
||||
import { cargoWeightFor, loadEligiblePlanes, visibleOpenPackages } from './RightPane';
|
||||
import type { PackageState, PlaneState, StateSnapshot } from '@/lib/game/state';
|
||||
|
||||
// v0.12.0 (weight model v0.27.0) — the package-model picker rules: a plane can LOAD a
|
||||
@@ -134,3 +134,39 @@ describe('loadEligiblePlanes (Load button eligibility)', () => {
|
||||
expect(loadEligiblePlanes(s, pkg({ id: 'x' }))).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('visibleOpenPackages (market list row filter, ISS-159)', () => {
|
||||
it('shows an open package when a grounded plane sits at its origin', () => {
|
||||
const s = snap(
|
||||
[plane({ id: 'at-origin' })],
|
||||
[pkg({ id: 'x' }), pkg({ id: 'onboard', status: 'loaded', planeId: 'at-origin' })], // non-open statuses never listed
|
||||
);
|
||||
expect(visibleOpenPackages(s).map((p) => p.id)).toEqual(['x']);
|
||||
});
|
||||
|
||||
it('hides an open package when only a flying plane is at its origin (in air, not grounded)', () => {
|
||||
const s = snap([plane({ id: 'en-route', status: 'flying', destIcao: 'LEMD' })], [pkg({ id: 'x' })]);
|
||||
expect(visibleOpenPackages(s)).toEqual([]);
|
||||
});
|
||||
|
||||
it('hides an open package when the grounded plane is elsewhere and another flies to its origin', () => {
|
||||
const s = snap(
|
||||
[
|
||||
plane({ id: 'grounded-elsewhere', locationIcao: 'LEMD' }),
|
||||
plane({ id: 'en-route', status: 'flying', destIcao: 'EDDF' }), // flying TO the package's origin — not grounded there yet
|
||||
],
|
||||
[pkg({ id: 'x' })],
|
||||
);
|
||||
expect(visibleOpenPackages(s)).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps a payload-blocked row visible when a grounded plane at the origin has no room (disabled Load path preserved)', () => {
|
||||
const packages = [
|
||||
...Array.from({ length: 4 }, (_, i) => pkg({ id: `fill-${i}`, status: 'loaded', planeId: 'full', weightKg: 1_200 })), // 4 × 1200 = 4800 — full
|
||||
pkg({ id: 'x' }),
|
||||
];
|
||||
const s = snap([plane({ id: 'full' })], packages);
|
||||
expect(visibleOpenPackages(s).map((p) => p.id)).toEqual(['x']); // row stays…
|
||||
expect(loadEligiblePlanes(s, s.packages.find((p) => p.id === 'x')!)).toEqual([]); // …with Load disabled
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user