Files
romm/frontend/test/withInputModality.test.ts
Georges-Antoine AssiandClaude Opus 5.5 89c06c9836 refactor(storybook): pin input modality in useInputModality
simplify pass:
- useInputModality gains pin(), which gates setModality so pinned modes
  ignore the listeners (and useGamepad) instead of a watcher undoing their
  writes; drops the manual data-input write and the HMR dispose
- one INPUT_DEFAULT shared by initialGlobals and the decorator fallback
- the Input Navigation stories share one render on meta

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-25 21:19:50 -04:00

26 lines
944 B
TypeScript

import type { StoryContext } from "@storybook/vue3-vite";
import { mount } from "@vue/test-utils";
import { expect, it } from "vitest";
import { defineComponent, nextTick, reactive } from "vue";
import { useInputModality } from "@/v2/composables/useInputModality";
import { withInputModality } from "../.storybook/withInputModality";
it("pins the toolbar's mode over live input and follows a toolbar change", async () => {
useInputModality().install();
const globals = reactive({ input: "key" });
const story = defineComponent({ render: () => null });
mount(
withInputModality(
story as unknown as Parameters<typeof withInputModality>[0],
{ globals } as unknown as StoryContext,
),
);
window.dispatchEvent(new Event("touchstart"));
expect(document.documentElement.dataset.input).toBe("key");
globals.input = "touch";
await nextTick();
expect(document.documentElement.dataset.input).toBe("touch");
});