deadhead-space-freight-tycoon/packages/engine/test/ported/tutorial-v2-three-runs.test.ts

37 lines
1.2 KiB
TypeScript

// Ported from apps/server/test (CR-014 Step 14.5): now runs on the engine.
import { describe, expect, it, vi } from "vitest";
import { useTestApp, signUp, getState, flyTutorialRun } from "../support";
// The deal after three runs instead of four: the loaner is then at the Moon.
vi.mock("@deadhead/content", async (importOriginal) => {
const original = await importOriginal<typeof import("@deadhead/content")>();
return {
...original,
content: {
...original.content,
config: { ...original.content.config, tutorialRunsBeforeDeal: 3 },
},
};
});
const testApp = useTestApp();
describe("deal availability with tutorialRunsBeforeDeal = 3", () => {
it("waits until a fourth run returns the loaner to Earth", async () => {
const guest = await signUp(testApp().app);
for (let run = 1; run <= 3; run++) await flyTutorialRun(testApp(), guest);
expect((await getState(testApp().app, guest)).tutorial).toMatchObject({
runsCompleted: 3,
loanerLocationId: "moon",
dealAvailable: false,
});
const state = await flyTutorialRun(testApp(), guest);
expect(state.tutorial).toMatchObject({
runsCompleted: 4,
loanerLocationId: "earth",
dealAvailable: true,
});
});
});