51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import {
|
|
addCredits,
|
|
advanceTo,
|
|
board,
|
|
dismissLogbook,
|
|
logbook,
|
|
nextMarsWindow,
|
|
playToDeal,
|
|
serverNow,
|
|
state,
|
|
tryDispatch,
|
|
} from "./support";
|
|
|
|
test.describe("end to end (Phase 12)", () => {
|
|
test("12.5: a first contact to Mars discovers it, opens its board and lets you lease there", async ({
|
|
page,
|
|
}) => {
|
|
const owner = await playToDeal(page);
|
|
const clipper = owner.ships.find((s) => s.modelId === "clipper")!;
|
|
const veteran = owner.pilots.find((p) => p.isVeteran)!;
|
|
|
|
// A date when the Clipper can reach Mars, Long Haul for the trip, and fuel money.
|
|
await advanceTo(page, nextMarsWindow(await serverNow(page)));
|
|
await page.goto("/pilots");
|
|
const raise = page.getByRole("button", { name: `Raise Long Haul for ${veteran.name}` });
|
|
while ((await state(page)).pilots.find((p) => p.id === veteran.id)!.skillPointsAvailable > 0) {
|
|
await raise.click();
|
|
}
|
|
await addCredits(page, 100_000);
|
|
|
|
// The board offers a first contact the Clipper can fly (decision 0.5.85).
|
|
const offer = (await board(page, "earth")).contracts.find(
|
|
(c) => c.firstContact && c.destinationId === "mars",
|
|
);
|
|
expect(offer, "a first contact to Mars on the Earth board").toBeDefined();
|
|
const flight = await tryDispatch(page, offer!.id, clipper.id, veteran.id);
|
|
expect(flight, "the Clipper and veteran can take it").not.toBeNull();
|
|
await advanceTo(page, flight!.arrivalAt);
|
|
await page.goto("/");
|
|
await expect(logbook(page)).toContainText("Discovered Mars!");
|
|
await dismissLogbook(page);
|
|
|
|
// Mars is discovered on the Locations screen and can be leased; its board is open without a bay (CR-002).
|
|
await page.goto("/locations");
|
|
await expect(page.getByRole("button", { name: "Lease bay at Mars" })).toBeEnabled();
|
|
expect((await board(page, "mars")).contracts.length).toBeGreaterThan(0);
|
|
expect((await state(page)).bays.map((b) => b.locationId)).toEqual(["earth"]);
|
|
});
|
|
});
|