Skip to content

Commit d04fea5

Browse files
Address PR review feedback on frontend test coverage
Enforce a 50% line-coverage floor in vitest.config.js so the static/js/ gain cannot silently regress. Restore mocks after export tests to prevent createElement spy leakage, and document fixture shapes plus the search.js no-highlight behavior for future maintainers.
1 parent 9f6fa32 commit d04fea5

5 files changed

Lines changed: 11 additions & 1 deletion

File tree

static/js/export.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, describe, expect, it, vi } from 'vitest';
1+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
22
import { bulkExport, downloadSession } from './export.js';
33

44
vi.mock('./projects.js', () => ({ showProjects: vi.fn() }));
@@ -29,6 +29,10 @@ describe('export', () => {
2929
showProjects.mockClear();
3030
});
3131

32+
afterEach(() => {
33+
vi.restoreAllMocks();
34+
});
35+
3236
async function confirmExport() {
3337
const ok = document.querySelector('.confirm-ok');
3438
expect(ok).not.toBeNull();

static/js/projects.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
22
import { showProjects } from './projects.js';
33

4+
// ProjectDict[] — mirrors models/project.py.
45
const PROJECT_FIXTURE = [
56
{
67
name: 'alpha',

static/js/search.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
22
import { showSearchPage, doSearch } from './search.js';
33

4+
// SearchHitDict[] — mirrors models/search.py (no highlight wrapper in search.js; snippets are escaped text only).
45
const SEARCH_HITS = [
56
{
67
project: 'alpha',

static/js/sessions.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
22
import { state } from './shared/state.js';
33
import { showWorkspace, loadSession, selectSession, copyAll } from './sessions.js';
44

5+
// Session list + detail shapes mirror models/session.py (ProjectSessionRowDict / SessionDict).
56
const SESSION_LIST = [
67
{
78
id: 'sess-1',

vitest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export default defineConfig({
99
reporter: ['text', 'lcov'],
1010
include: ['static/js/**/*.js'],
1111
exclude: ['static/js/**/*.test.js'],
12+
thresholds: {
13+
lines: 50,
14+
},
1215
},
1316
},
1417
});

0 commit comments

Comments
 (0)