Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
} from "../src/shared/localvtt.js";

const api: LocalVttApi = {
isVisualSmokeTest: process.env.LOCALVTT_VISUAL_SMOKE_TEST === "1",
createCampaign: () => ipcRenderer.invoke("campaign:create") as Promise<CampaignSummary | null>,
openCampaign: () => ipcRenderer.invoke("campaign:open") as Promise<CampaignSummary | null>,
openRecentCampaign: (campaignPath: string) => ipcRenderer.invoke("campaign:openRecent", campaignPath) as Promise<CampaignSummary>,
Expand Down
1 change: 1 addition & 0 deletions src/renderer/devLocalVtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function installDevLocalVtt() {
};

const api: LocalVttApi = {
isVisualSmokeTest: false,
createCampaign: async () => {
campaign = createDevCampaign();
scenes.clear();
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/lib/player-view/playerIdleState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ export const PLAYER_BLACKOUT_STATE: PlayerIdleState = {
};

type PlayerIdleApi = {
isVisualSmokeTest?: boolean;
showPlayerIdle: (title: string, message: string, variant?: PlayerIdleState["variant"]) => Promise<unknown>;
};

export async function showDefaultPlayerHold(api: PlayerIdleApi = window.localVtt): Promise<void> {
if (api.isVisualSmokeTest) {
return;
}
await api.showPlayerIdle(DEFAULT_PLAYER_HOLD_STATE.title, DEFAULT_PLAYER_HOLD_STATE.message, DEFAULT_PLAYER_HOLD_STATE.variant);
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/localVttApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface PlayerDisplaySummary {
}

export interface LocalVttApi {
isVisualSmokeTest: boolean;
createCampaign: () => Promise<CampaignSummary | null>;
openCampaign: () => Promise<CampaignSummary | null>;
openRecentCampaign: (campaignPath: string) => Promise<CampaignSummary>;
Expand Down
8 changes: 8 additions & 0 deletions tests/renderer/playerIdleState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ describe("player idle state helpers", () => {
);
});

it("does not override visual smoke fixture state with the default hold state", async () => {
const api = { isVisualSmokeTest: true, showPlayerIdle: vi.fn().mockResolvedValue(undefined) };

await showDefaultPlayerHold(api);

expect(api.showPlayerIdle).not.toHaveBeenCalled();
});

it("shows the blackout state", async () => {
const api = { showPlayerIdle: vi.fn().mockResolvedValue(undefined) };

Expand Down