Repository navigation
test(SAL-3525): router and route wiring coverage #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
salahmyn
merged 3 commits into
feature/quality-gates-twig-parity-audit
from
test/SAL-3525-router-and-registry-coverage
Oct 27, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
|
|
||
| const e = vi.hoisted(() => ({ | ||
| hydrateRoot: vi.fn(), | ||
| removeEdgeInjections: vi.fn(), | ||
| initThemeSentry: vi.fn(), | ||
| bootClient: vi.fn(), | ||
| createStart: vi.fn((factory: () => unknown) => factory()), | ||
| twilightMiddleware: vi.fn(() => 'twilight'), | ||
| earlyHintsMiddleware: vi.fn(() => 'early-hints'), | ||
| withThemeSentry: vi.fn((handler: unknown, name: string) => ({ handler, name })), | ||
| })); | ||
|
|
||
| vi.mock('react-dom/client', () => ({ hydrateRoot: e.hydrateRoot })); | ||
| vi.mock('@tanstack/react-start/client', () => ({ StartClient: () => null })); | ||
| vi.mock('@salla.sa/twilight-theme-engine/sentry/client', () => ({ | ||
| initThemeSentry: e.initThemeSentry, | ||
| })); | ||
| vi.mock('@salla.sa/twilight-theme-engine/dom', () => ({ | ||
| removeEdgeInjections: e.removeEdgeInjections, | ||
| })); | ||
| vi.mock('@salla.sa/twilight-theme-engine/boot', () => ({ bootClient: e.bootClient })); | ||
| vi.mock('@salla.sa/twilight-theme-engine/sentry/server', () => ({ | ||
| withThemeSentry: e.withThemeSentry, | ||
| })); | ||
| vi.mock('@tanstack/react-start/server-entry', () => ({ default: 'server-handler' })); | ||
| vi.mock('@tanstack/react-start', () => ({ createStart: e.createStart })); | ||
| vi.mock('@salla.sa/twilight-theme-engine/tanstack', () => ({ | ||
| twilightMiddleware: e.twilightMiddleware, | ||
| earlyHintsMiddleware: e.earlyHintsMiddleware, | ||
| })); | ||
| vi.mock('../../app/hydrate', () => ({ hydrate: 'hydrate-fn' })); | ||
| vi.mock('../../app/styles/app.css?url', () => ({ default: '/app.css' })); | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| vi.resetModules(); | ||
| }); | ||
|
|
||
| describe('client entry', () => { | ||
| it('boots the client with the app stylesheet and the lazily loaded hydrator', async () => { | ||
| await import('../../app/client'); | ||
| const options = e.bootClient.mock.calls[0][0]; | ||
| expect(options.stylesheet).toBe('/app.css'); | ||
| expect((await options.load()).hydrate).toBe('hydrate-fn'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('hydrate', () => { | ||
| it('reports errors to the theme Sentry project', async () => { | ||
| await vi.importActual('../../app/hydrate'); | ||
| expect(e.initThemeSentry).toHaveBeenCalledWith('raed'); | ||
| }); | ||
|
|
||
| it('strips edge-injected nodes, then hydrates the whole document', async () => { | ||
| const { hydrate } = | ||
| await vi.importActual<typeof import('../../app/hydrate')>('../../app/hydrate'); | ||
| hydrate(); | ||
| expect(e.removeEdgeInjections).toHaveBeenCalledTimes(1); | ||
| await vi.waitFor(() => expect(e.hydrateRoot).toHaveBeenCalledTimes(1)); | ||
| expect(e.hydrateRoot.mock.calls[0][0]).toBe(document); | ||
| }); | ||
| }); | ||
|
|
||
| describe('start and server entries', () => { | ||
| it('runs the twilight and early-hints middleware on every request', async () => { | ||
| const { startInstance } = await import('../../app/start'); | ||
| expect(startInstance).toEqual({ requestMiddleware: ['twilight', 'early-hints'] }); | ||
| }); | ||
|
|
||
| it('wraps the server handler with theme Sentry', async () => { | ||
| const mod = await import('../../app/server'); | ||
| expect(mod.default).toEqual({ handler: 'server-handler', name: 'raed' }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('routes manifest', () => { | ||
| it('declares no custom routes', async () => { | ||
| const { routes } = await import('../../app/routes'); | ||
| expect(routes).toEqual([]); | ||
| }); | ||
| }); | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test checks that both functions run, but not that
removeEdgeInjectionsruns beforehydrateRoot. Reversing those calls would still pass despite the test's “then hydrates” claim.The repository requires assertions to check the claimed behavior. Before merging, compare their recorded call order to protect cleanup before hydration.
Rule Used: What: Reject assertions that don't actually validate the expected behavior or outcome. Why: Fake assertions give false confidence in test coverage and fail to catch real bugs. Good: ```python def test_user_creation(): user = create_user("John",... (source)
Knowledge Base Used: Runtime entrypoints
Prompt To Fix With AI