import { content } from "@deadhead/content"; import { expect, test } from "@playwright/test"; import { advanceTo, dismissLogbook, dispatchFromEarthBoard, logbook, playToDeal, state, } from "./support"; test.describe("end to end (Phase 12)", () => { test("12.3: tutorial runs, the deal, then a contract that repays the loan", async ({ page }) => { const owner = await playToDeal(page); // The deal (CR-001, CR-013): Courier crewed by the avatar and Clipper by the veteran, at Earth. expect(owner.tutorial).toBeNull(); expect(owner.bays.map((b) => b.locationId)).toEqual(["earth"]); expect(owner.company.loanBalance).toBe(content.dealLoanAmount); const avatar = owner.pilots.find((p) => p.isAvatar)!; const veteran = owner.pilots.find((p) => p.isVeteran)!; expect(owner.ships.map((s) => [s.modelId, s.locationId, s.pilotId])).toEqual([ ["courier", "earth", avatar.id], ["clipper", "earth", veteran.id], ]); // One contract, dispatched in the UI and resolved. const dispatchId = await dispatchFromEarthBoard(page); const flight = (await state(page)).activeDispatches.find((d) => d.id === dispatchId)!; await advanceTo(page, flight.arrivalAt); await page.reload(); // The net, after the lender's cut (CR-025); the cut itself is in the Logbook. await expect(logbook(page)).toContainText(/delivered .+ to Moon, \+[\d,]+ cr/); await dismissLogbook(page); const after = await state(page); expect(after.activeDispatches).toEqual([]); expect(after.company.loanBalance).toBeLessThan(content.dealLoanAmount); }); });