Skip to content

Commit 89529bf

Browse files
Programcodeclaude
andauthored
chore: remove dead code and tautological tests (#29)
* chore: remove dead code and tautological tests Dead code (zero references anywhere, including tests): - src/lib/ai/prompts/index.ts (165 lines) — prompt building moved server-side to supabase/functions/_shared/prompts.ts - useKeyboardShortcuts, useResolvedTheme hooks - isUrlSafe (validateUrl is the live entry point) - requireAdmin in _shared/auth.ts — admin/index.ts does its own inline user_roles lookups - getAppRedirectUrl in native.ts - mockSparringResponse/mockSparringScore aliases - buildSearchQueries wrapper — inlined the one-line .map into its two callers, which were both tests Tests that assert nothing about our code: - example.test.ts: expect(true).toBe(true) - utils.test.ts: 11 tests over cn(), a one-line clsx+tailwind-merge pass-through — tested the libraries, not us - providers.test.ts: 14 of 15 tests re-asserted that a static const is still a static const; kept the duplicate-model-ID check, which guards real routing behavior - i18n.test.ts: "locale has keys" tautologies and a key-count check subsumed by the bidirectional key-set comparisons - export-utils-extended.test.ts: 6 "typeof x === function" tests - pages/HistoryPage smoke tests asserting document.body is defined - settings-store-branches: the `afterRehydrate(undefined)` call existed only to hit an `if (!state) return` line Preserved deliberately: setActiveEnv/IS_STAGING in supabase/env.ts (reserved by plans/supabase-staging.md for the admin env switcher), and security-hardening/runtime-contracts/vercel-deployment-config tests, which guard invariants from PRs #26/#27. Verified: 921 tests pass, lint clean, tsc clean, build succeeds, coverage thresholds still met (statements 90.45/90, branches 82.91/80, functions 91.46/89, lines 94.04/90). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test: give CI expect assertions room for lazy route chunks The e2e suite runs against the Vite dev server, which transforms lazily-imported route modules on demand. The first assertion after navigating to a lazy route therefore races that transform waterfall. Trace timings from the failing CI run on this branch: 22:16:35.139 GET /app/sparring (document) 22:16:38.463 SparringPage.tsx (+3.3s) 22:16:38.755 SparringSetup.tsx (+3.6s, owns the heading) Against the 5s Playwright default, with two workers sharing a runner, that overruns. The failure screenshot shows the heading rendered correctly -- the budget simply expired first. Raise the expect timeout to 15s under CI only, leaving local runs at the 5s default so genuine hangs still surface quickly. No assertion is weakened: every expectation still has to pass, it just gets a budget that reflects what the dev server actually costs on a shared runner. Pre-existing, not caused by the dead-code removal in this branch: PR 28 recorded the same test as flaky, and it reproduces on base 79b65ca with these changes absent. Verified under 12 busy-loop jobs on 8 cores, 18-test sample: 5s (control): 1 flaky, 17 passed 15s (fixed): 18 passed Full suite on a clean machine: 124 passed, 0 flaky. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 79b65ca commit 89529bf

19 files changed

Lines changed: 13 additions & 533 deletions

‎playwright.config.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export default defineConfig({
2828
retries: process.env.CI ? 2 : 0,
2929
workers: process.env.CI ? 2 : undefined,
3030
reporter: process.env.CI ? [['github'], ['html', { open: 'never' }]] : 'list',
31+
// The dev server transforms lazily-imported route modules on demand, so the
32+
// first assertion after navigating to a lazy route races that waterfall. On a
33+
// shared CI runner it has measured over 3.5s from document to the component
34+
// that owns the heading, which overruns the 5s default.
35+
expect: { timeout: process.env.CI ? 15_000 : 5_000 },
3136
use: {
3237
baseURL,
3338
trace: 'retain-on-failure',

‎src/hooks/use-keyboard-shortcuts.ts‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎src/hooks/use-resolved-theme.ts‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎src/lib/ai/prompts/index.ts‎

Lines changed: 0 additions & 165 deletions
This file was deleted.

‎src/lib/ai/providers/mock-provider.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,5 +508,3 @@ export async function mockJudgeSparringSession(input: SparringScoreInput): Promi
508508
}
509509

510510
// Names kept short for callers that treat the mock provider as a feature adapter.
511-
export const mockSparringResponse = mockGenerateSparringTurn;
512-
export const mockSparringScore = mockJudgeSparringSession;

‎src/lib/native.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ export function isNativeApp(): boolean {
99
return Capacitor.isNativePlatform();
1010
}
1111

12-
export function getAppRedirectUrl(path = '/app'): string {
13-
if (isNativeApp()) return `${NATIVE_URL_SCHEME}://${path.replace(/^\/+/, '')}`;
14-
return `${window.location.origin}${path}`;
15-
}
16-
1712
export function getWebAppRedirectUrl(path = '/app'): string {
1813
const origin = isNativeApp() ? PUBLIC_WEB_APP_ORIGIN : window.location.origin;
1914
return `${origin}${path}`;

‎src/lib/validation/url.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,3 @@ export function validateUrl(url?: string): string | undefined {
5555
return undefined;
5656
}
5757
}
58-
59-
/**
60-
* Checks if a URL is safe without normalizing it.
61-
* Useful for validation-only scenarios.
62-
*/
63-
export function isUrlSafe(url?: string): boolean {
64-
return validateUrl(url) !== undefined;
65-
}

‎src/test/example.test.ts‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎src/test/export-utils-extended.test.ts‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -225,29 +225,4 @@ describe('Export Utils - Extended', () => {
225225
});
226226
});
227227

228-
describe('PDF export functions exist', () => {
229-
it('exportCaseToDocx is a function', () => {
230-
expect(typeof exportCaseToDocx).toBe('function');
231-
});
232-
233-
it('exportAttackToDocx is a function', () => {
234-
expect(typeof exportAttackToDocx).toBe('function');
235-
});
236-
237-
it('exportBrainstormToDocx is a function', () => {
238-
expect(typeof exportBrainstormToDocx).toBe('function');
239-
});
240-
241-
it('exportFactoidsToDocx is a function', () => {
242-
expect(typeof exportFactoidsToDocx).toBe('function');
243-
});
244-
245-
it('exportCaseToGoogleDocs is a function', () => {
246-
expect(typeof exportCaseToGoogleDocs).toBe('function');
247-
});
248-
249-
it('exportBrainstormToGoogleDocs is a function', () => {
250-
expect(typeof exportBrainstormToGoogleDocs).toBe('function');
251-
});
252-
});
253228
});

‎src/test/i18n.test.ts‎

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,6 @@ describe('i18n locale files', () => {
3232
const esKeys = flattenKeys(es);
3333
const huKeys = flattenKeys(hu);
3434

35-
it('en.json has keys', () => {
36-
expect(enKeys.length).toBeGreaterThan(0);
37-
});
38-
39-
it('es.json has keys', () => {
40-
expect(esKeys.length).toBeGreaterThan(0);
41-
});
42-
43-
it('hu.json has keys', () => {
44-
expect(huKeys.length).toBeGreaterThan(0);
45-
});
46-
47-
it('all 3 locale files have same number of keys', () => {
48-
expect(enKeys.length).toBe(esKeys.length);
49-
expect(enKeys.length).toBe(huKeys.length);
50-
});
51-
5235
it('all keys in en.json exist in es.json', () => {
5336
const esKeySet = new Set(esKeys);
5437
const missing = enKeys.filter(k => !esKeySet.has(k));
@@ -100,15 +83,9 @@ describe('i18n locale files', () => {
10083
});
10184

10285
describe('i18n runtime', () => {
103-
it('i18n.t returns correct English value for nav.home', () => {
86+
it('i18n.t resolves English nav values', () => {
10487
expect(i18n.t('nav.home')).toBe('Home');
105-
});
106-
107-
it('i18n.t returns correct English value for nav.generate', () => {
10888
expect(i18n.t('nav.generate')).toBe('Generate');
109-
});
110-
111-
it('i18n.t returns correct English value for nav.settings', () => {
11289
expect(i18n.t('nav.settings')).toBe('Settings');
11390
});
11491

@@ -124,11 +101,6 @@ describe('i18n runtime', () => {
124101
await i18n.changeLanguage('en');
125102
});
126103

127-
it('i18n.changeLanguage back to en', async () => {
128-
await i18n.changeLanguage('en');
129-
expect(i18n.language).toBe('en');
130-
});
131-
132104
it('interpolation works for limitModal.limitReachedDesc', () => {
133105
const result = i18n.t('limitModal.limitReachedDesc', { current: 5, limit: 10 });
134106
expect(result).toContain('5');

0 commit comments

Comments
 (0)