94 lines
3.3 KiB
TypeScript
94 lines
3.3 KiB
TypeScript
import { content } from "@deadhead/content";
|
|
import { expect, test } from "@playwright/test";
|
|
import {
|
|
acknowledgeAll,
|
|
addCredits,
|
|
advance,
|
|
advanceTo,
|
|
assignPilot,
|
|
board,
|
|
buyShip,
|
|
flyUntil,
|
|
hirePilot,
|
|
playToDeal,
|
|
state,
|
|
} from "./support";
|
|
|
|
test.describe("end to end (Phase 12)", () => {
|
|
test("12.6: a pilot levels up, learns Heavy Cargo and can take a Heavy job; Long Haul lengthens duty", async ({
|
|
page,
|
|
}) => {
|
|
const owner = await playToDeal(page);
|
|
const bay = owner.bays[0]!;
|
|
await addCredits(page, 100_000);
|
|
const { ship } = await buyShip(page, "lighter", bay.id);
|
|
const { pilot } = await hirePilot(page, "earth");
|
|
await assignPilot(page, pilot.id, ship.id);
|
|
|
|
// Deliveries until the new pilot reaches level 1 (two skill points).
|
|
await flyUntil(
|
|
page,
|
|
ship.id,
|
|
pilot.id,
|
|
(s) => s.pilots.find((p) => p.id === pilot.id)!.level >= 1,
|
|
);
|
|
|
|
// Get the Lighter to the Moon, and wait for a Heavy Cargo 1 job it can carry there.
|
|
await flyUntil(
|
|
page,
|
|
ship.id,
|
|
pilot.id,
|
|
(s) => s.ships.find((x) => x.id === ship.id)!.locationId === "moon",
|
|
);
|
|
const heavyJob = async () =>
|
|
(await board(page, "moon")).contracts.find(
|
|
(c) =>
|
|
c.requiredSkill?.skillId === "heavy-cargo" &&
|
|
c.requiredSkill.level === 1 &&
|
|
c.massTonnes <= 80 &&
|
|
c.requiredLongHaulLevel === 0,
|
|
);
|
|
let job = await heavyJob();
|
|
for (let k = 0; !job && k < 60; k++) {
|
|
await advance(page, content.config.contractBoardPeriodRealMinutes * 60_000);
|
|
job = await heavyJob();
|
|
}
|
|
expect(job, "a Heavy Cargo 1 job at the Moon").toBeDefined();
|
|
await acknowledgeAll(page);
|
|
const resting = (await state(page)).pilots.find((p) => p.id === pilot.id)!.restEndsAt;
|
|
if (resting !== null) await advanceTo(page, resting);
|
|
|
|
// In the dispatch sheet the Lighter's pair is blocked by the skill...
|
|
const pairFor = async () => {
|
|
await page.goto("/contracts?location=moon");
|
|
const card = page
|
|
.getByRole("listitem")
|
|
.filter({ hasText: content.good(job!.goodId)!.name })
|
|
.filter({ hasText: `${job!.massTonnes} t` });
|
|
await card.getByRole("button", { name: "Dispatch" }).first().click();
|
|
return page.locator(`input[name="pair"][value="${ship.id}"]`);
|
|
};
|
|
await expect(await pairFor()).toBeDisabled();
|
|
await expect(page.getByText("Needs Heavy Cargo 1 (pilot has 0)")).toBeVisible();
|
|
|
|
// ...until the pilot spends a point in Heavy Cargo.
|
|
await page.goto("/pilots");
|
|
await page.getByRole("button", { name: `Raise Heavy Cargo for ${pilot.name}` }).click();
|
|
await expect
|
|
.poll(
|
|
async () =>
|
|
(await state(page)).pilots.find((p) => p.id === pilot.id)!.skills["heavy-cargo"],
|
|
)
|
|
.toBe(1);
|
|
await expect(await pairFor()).toBeEnabled();
|
|
|
|
// CR-004: Long Haul raises the duty limit.
|
|
const limitBefore = (await state(page)).pilots.find((p) => p.id === pilot.id)!.dutyLimit;
|
|
await page.goto("/pilots");
|
|
await page.getByRole("button", { name: `Raise Long Haul for ${pilot.name}` }).click();
|
|
await expect
|
|
.poll(async () => (await state(page)).pilots.find((p) => p.id === pilot.id)!.dutyLimit)
|
|
.toBe(limitBefore + content.config.longHaulDutyBonusGameHours);
|
|
});
|
|
});
|