28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { advanceTo, dispatchFromEarthBoard, logbook, playToDeal, state } from "./support";
|
|
|
|
test.describe("end to end (Phase 12)", () => {
|
|
test("12.4: a delivery that lands while the app is closed shows on return", async ({
|
|
page,
|
|
context,
|
|
}) => {
|
|
await playToDeal(page);
|
|
const dispatchId = await dispatchFromEarthBoard(page);
|
|
const before = await state(page);
|
|
const flight = before.activeDispatches.find((d) => d.id === dispatchId)!;
|
|
|
|
// Close the app, let the server clock pass the arrival, come back.
|
|
await page.close();
|
|
const later = await context.newPage();
|
|
await advanceTo(later, flight.arrivalAt);
|
|
await later.goto("/");
|
|
|
|
const summary = (await state(later)).summaries.find((s) => s.dispatchId === dispatchId)!;
|
|
await expect(logbook(later)).toContainText(`Delivered ${summary.massTonnes} t`);
|
|
const after = await state(later);
|
|
// Credits went up by the delivery's net payout; the ship is at the destination.
|
|
expect(after.company.credits).toBe(before.company.credits + summary.credits);
|
|
expect(after.ships.find((s) => s.id === flight.shipId)!.locationId).toBe(flight.destinationId);
|
|
});
|
|
});
|