refactor(characters): drive shared UI from active character
This commit is contained in:
@@ -2,7 +2,9 @@ import { act, type Dispatch } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { getCharacterBySlug } from "@/data/constants/character";
|
||||
import type { LoginStatus } from "@/data/schemas/auth";
|
||||
import { CharacterProvider } from "@/providers/character-provider";
|
||||
import { getCharacterRoutes } from "@/router/routes";
|
||||
import type { PrivateRoomEvent } from "@/stores/private-room";
|
||||
import type { PrivateRoomUnlockPaywallRequest } from "@/stores/private-room/private-room-state";
|
||||
@@ -80,7 +82,7 @@ describe("Private Room paywall navigation", () => {
|
||||
renderHarness(root, "guest", roomDispatch);
|
||||
|
||||
expect(mocks.openAuth).toHaveBeenCalledWith(
|
||||
getCharacterRoutes("elio").privateRoom,
|
||||
getCharacterRoutes("maya").privateRoom,
|
||||
);
|
||||
expect(mocks.openSubscription).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -91,9 +93,13 @@ function renderHarness(
|
||||
loginStatus: LoginStatus,
|
||||
roomDispatch: Dispatch<PrivateRoomEvent>,
|
||||
): void {
|
||||
const character = getCharacterBySlug("maya");
|
||||
if (!character) throw new Error("Missing Maya character fixture");
|
||||
act(() => {
|
||||
root.render(
|
||||
<Harness loginStatus={loginStatus} roomDispatch={roomDispatch} />,
|
||||
<CharacterProvider character={character}>
|
||||
<Harness loginStatus={loginStatus} roomDispatch={roomDispatch} />
|
||||
</CharacterProvider>,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user