Repository navigation
test(harness): import shared-state modules as the components do (#1211) - #1244
Merged
Merged
Conversation
On Windows, ChatInput.test.mjs rendered an empty composer: the drafts it set never reached the component. jiti keys its module cache by the resolved path string, and on Windows it is expected to resolve "@/lib/draft-store.ts" (with its extension) to a path with forward slashes but "@/lib/draft-store" (as ChatInput.tsx imports it) to one with backslashes, so the test wrote into a second copy of the store. This was traced through jiti's source and an emulation of Windows paths around the real jiti, not on Windows itself. Eleven newer component tests imported "@/hooks/useI18n.tsx" the same way, which gives a second I18n context there (the failure #588 fixed for the older tests). The tests now import these modules exactly as the components do, including AppShell.workspace-memory.test.mjs's relative import of the draft store, and a small guard test fails when a test names useI18n or the draft store any other way. SessionSidebar.tabs.test.mjs writes its alias key in forward slashes with an upper-case drive letter, the form jiti compares alias keys with. No product code changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…r#1211) (agegr#1244) On Windows, ChatInput.test.mjs rendered an empty composer: the drafts it set never reached the component. jiti keys its module cache by the resolved path string, and on Windows it is expected to resolve "@/lib/draft-store.ts" (with its extension) to a path with forward slashes but "@/lib/draft-store" (as ChatInput.tsx imports it) to one with backslashes, so the test wrote into a second copy of the store. This was traced through jiti's source and an emulation of Windows paths around the real jiti, not on Windows itself. Eleven newer component tests imported "@/hooks/useI18n.tsx" the same way, which gives a second I18n context there (the failure agegr#588 fixed for the older tests). The tests now import these modules exactly as the components do, including AppShell.workspace-memory.test.mjs's relative import of the draft store, and a small guard test fails when a test names useI18n or the draft store any other way. SessionSidebar.tabs.test.mjs writes its alias key in forward slashes with an upper-case drive letter, the form jiti compares alias keys with. No product code changes. Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…r#1211) (agegr#1244) On Windows, ChatInput.test.mjs rendered an empty composer: the drafts it set never reached the component. jiti keys its module cache by the resolved path string, and on Windows it is expected to resolve "@/lib/draft-store.ts" (with its extension) to a path with forward slashes but "@/lib/draft-store" (as ChatInput.tsx imports it) to one with backslashes, so the test wrote into a second copy of the store. This was traced through jiti's source and an emulation of Windows paths around the real jiti, not on Windows itself. Eleven newer component tests imported "@/hooks/useI18n.tsx" the same way, which gives a second I18n context there (the failure agegr#588 fixed for the older tests). The tests now import these modules exactly as the components do, including AppShell.workspace-memory.test.mjs's relative import of the draft store, and a small guard test fails when a test names useI18n or the draft store any other way. SessionSidebar.tabs.test.mjs writes its alias key in forward slashes with an upper-case drive letter, the form jiti compares alias keys with. No product code changes. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1211. Test harness only, no product code changes.
Cause
jiti keys its module cache by the resolved path string. On Windows it is expected to resolve
@/lib/draft-store.ts(with its extension) to a forward-slash path but@/lib/draft-store(asChatInput.tsximports it) to a backslash path: with the extension, jiti's bundled resolver returns the existing file as is; without it, the resolver parsesC:/…as a URL with schemec:, fails, and jiti falls back to Node'srequire.resolve, which answers with backslashes. SoChatInput.test.mjswrote its draft into a second copy of the store and the composer rendered empty. Eleven newer component tests import@/hooks/useI18n.tsxthe same way, the failure #588 fixed for the older tests.This was traced through jiti 2.7.0's source and an emulation of win32 paths around the real jiti (which reproduces the empty composer). It has not been run on Windows.
Change
@/hooks/useI18nand@/lib/draft-storeexactly as the components do (12 files, plusAppShell.workspace-memory.test.mjs's relative import of the store).SessionSidebar.tabs.test.mjswrites its alias key with forward slashes and an upper-case drive letter, the form jiti compares alias keys with.components/test-imports.test.mjsfails when a test names those two modules any other way (extension, relative path).Verification
tsc --noEmit, eslint andnpm testpass on macOS. On Windows, @kcf7012 could confirm withnode --experimental-strip-types --test components/ChatInput.test.mjs components/BranchNavigator.test.mjs.🤖 Generated with Claude Code