Skip to content

Commit c28e9f5

Browse files
committed
fix(ci): remove unused imports and fix stale dates in tests
Four TypeScript errors in claudeup-core caused by unused imports: - conventions-integration.test.ts: remove unused `removeGitignoreEntries` - doctor.test.ts: remove unused `vi` - conventions-manager.ts: remove unused `existsSync` - doctor.ts: remove unused `InstalledPluginEntry` type Stats plugin tests were failing because hardcoded "2026-03-26" dates are now >7 days old and get filtered out by getSessionSummary/getTopTools 7-day window queries. Replace with dynamic TODAY/YESTERDAY/TWO_DAYS_AGO constants so tests remain correct as time passes. https://claude.ai/code/session_01XtXHbiPQXTyT8xsZTgp11P
1 parent 4b44218 commit c28e9f5

6 files changed

Lines changed: 31 additions & 27 deletions

File tree

plugins/stats/tests/db.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ describe("db", () => {
3535
}
3636
});
3737

38-
function makeSession(id: string, project = "/test/project", date = "2026-03-26"): SessionMetrics {
38+
const TODAY = new Date().toISOString().slice(0, 10);
39+
40+
function makeSession(id: string, project = "/test/project", date = TODAY): SessionMetrics {
3941
return {
4042
session_id: id,
4143
date,
@@ -48,14 +50,14 @@ describe("db", () => {
4850
duration_ms: 50,
4951
success: true,
5052
activity_category: "research",
51-
timestamp: "2026-03-26T10:00:00.000Z",
53+
timestamp: `${date}T10:00:00.000Z`,
5254
},
5355
{
5456
tool_name: "Write",
5557
duration_ms: 30,
5658
success: true,
5759
activity_category: "coding",
58-
timestamp: "2026-03-26T10:01:00.000Z",
60+
timestamp: `${date}T10:01:00.000Z`,
5961
},
6062
],
6163
activity_counts: {
@@ -193,8 +195,8 @@ describe("db", () => {
193195

194196
test("getSessionSummary returns aggregate stats", () => {
195197
const db = openDb(dbPath);
196-
insertSession(db, makeSession("s1", "/test/project", "2026-03-26"));
197-
insertSession(db, makeSession("s2", "/test/project", "2026-03-26"));
198+
insertSession(db, makeSession("s1", "/test/project", TODAY));
199+
insertSession(db, makeSession("s2", "/test/project", TODAY));
198200

199201
const summary = getSessionSummary(db, 7, "/test/project");
200202
expect(summary.session_count).toBe(2);
@@ -228,7 +230,7 @@ describe("db", () => {
228230
insertToolCalls(db, metrics.tool_calls, "old-session");
229231

230232
// Insert a recent session
231-
const recent = makeSession("recent-session", "/test/project", "2026-03-26");
233+
const recent = makeSession("recent-session", "/test/project", TODAY);
232234
insertSession(db, recent);
233235

234236
const { deletedCount } = deleteOldSessions(db, 90);

plugins/stats/tests/integration.test.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ function makeTempDir(): string {
6868
return dir;
6969
}
7070

71+
const TODAY = new Date().toISOString().slice(0, 10);
72+
const YESTERDAY = new Date(Date.now() - 86400000).toISOString().slice(0, 10);
73+
const TWO_DAYS_AGO = new Date(Date.now() - 2 * 86400000).toISOString().slice(0, 10);
74+
7175
function makeSession(
7276
id: string,
7377
project = "/test/project",
74-
date = "2026-03-26",
78+
date = TODAY,
7579
overrides: Partial<SessionMetrics> = {}
7680
): SessionMetrics {
7781
return {
@@ -113,7 +117,7 @@ function makeSessionRow(
113117
): SessionRow {
114118
return {
115119
id,
116-
date: "2026-03-26",
120+
date: TODAY,
117121
project: "/test/project",
118122
duration_sec: 600,
119123
total_tool_calls: 10,
@@ -123,7 +127,7 @@ function makeSessionRow(
123127
testing_calls: 1,
124128
delegation_calls: 1,
125129
other_calls: 1,
126-
created_at: "2026-03-26T10:00:00.000Z",
130+
created_at: `${TODAY}T10:00:00.000Z`,
127131
...overrides,
128132
};
129133
}
@@ -378,8 +382,8 @@ describe("Database: schema, CRUD, retention, queries", () => {
378382
const db = openDb(dbPath);
379383

380384
// Insert 2 sessions with known tool counts
381-
insertSession(db, makeSession("s1", "/test/project", "2026-03-26"));
382-
insertSession(db, makeSession("s2", "/test/project", "2026-03-26"));
385+
insertSession(db, makeSession("s1", "/test/project", TODAY));
386+
insertSession(db, makeSession("s2", "/test/project", TODAY));
383387
insertToolCalls(db, makeSession("s1").tool_calls, "s1");
384388
insertToolCalls(db, makeSession("s2").tool_calls, "s2");
385389

@@ -412,7 +416,7 @@ describe("Database: schema, CRUD, retention, queries", () => {
412416
// Old session (well beyond 90 days)
413417
insertSession(db, makeSession("old", "/test/project", "2024-01-01"));
414418
// Recent session
415-
insertSession(db, makeSession("recent", "/test/project", "2026-03-26"));
419+
insertSession(db, makeSession("recent", "/test/project", TODAY));
416420

417421
const { deletedCount } = deleteOldSessions(db, 90);
418422

@@ -443,7 +447,7 @@ describe("Database: schema, CRUD, retention, queries", () => {
443447

444448
test("deleteOldSessions returns 0 when no sessions are old enough", () => {
445449
const db = openDb(dbPath);
446-
insertSession(db, makeSession("recent", "/test/project", "2026-03-26"));
450+
insertSession(db, makeSession("recent", "/test/project", TODAY));
447451

448452
const { deletedCount } = deleteOldSessions(db, 90);
449453

@@ -454,14 +458,14 @@ describe("Database: schema, CRUD, retention, queries", () => {
454458

455459
test("getTopTools returns tools ranked by call count", () => {
456460
const db = openDb(dbPath);
457-
insertSession(db, makeSession("s1", "/test/project", "2026-03-26"));
461+
insertSession(db, makeSession("s1", "/test/project", TODAY));
458462

459463
const calls: ToolCallRecord[] = [
460-
{ tool_name: "Read", duration_ms: 10, success: true, activity_category: "research", timestamp: "2026-03-26T10:00:00.000Z" },
461-
{ tool_name: "Read", duration_ms: 20, success: true, activity_category: "research", timestamp: "2026-03-26T10:01:00.000Z" },
462-
{ tool_name: "Read", duration_ms: 15, success: true, activity_category: "research", timestamp: "2026-03-26T10:02:00.000Z" },
463-
{ tool_name: "Write", duration_ms: 30, success: true, activity_category: "coding", timestamp: "2026-03-26T10:03:00.000Z" },
464-
{ tool_name: "Bash", duration_ms: 100, success: true, activity_category: "other", timestamp: "2026-03-26T10:04:00.000Z" },
464+
{ tool_name: "Read", duration_ms: 10, success: true, activity_category: "research", timestamp: `${TODAY}T10:00:00.000Z` },
465+
{ tool_name: "Read", duration_ms: 20, success: true, activity_category: "research", timestamp: `${TODAY}T10:01:00.000Z` },
466+
{ tool_name: "Read", duration_ms: 15, success: true, activity_category: "research", timestamp: `${TODAY}T10:02:00.000Z` },
467+
{ tool_name: "Write", duration_ms: 30, success: true, activity_category: "coding", timestamp: `${TODAY}T10:03:00.000Z` },
468+
{ tool_name: "Bash", duration_ms: 100, success: true, activity_category: "other", timestamp: `${TODAY}T10:04:00.000Z` },
465469
];
466470
insertToolCalls(db, calls, "s1");
467471

@@ -484,10 +488,10 @@ describe("Database: schema, CRUD, retention, queries", () => {
484488
test("getDurationTrend returns daily data in ASC date order", () => {
485489
const db = openDb(dbPath);
486490

487-
// Insert sessions on different dates
488-
insertSession(db, makeSession("s1", "/test/project", "2026-03-24"));
489-
insertSession(db, makeSession("s2", "/test/project", "2026-03-25"));
490-
insertSession(db, makeSession("s3", "/test/project", "2026-03-26"));
491+
// Insert sessions on different dates (all within the 14-day window)
492+
insertSession(db, makeSession("s1", "/test/project", TWO_DAYS_AGO));
493+
insertSession(db, makeSession("s2", "/test/project", YESTERDAY));
494+
insertSession(db, makeSession("s3", "/test/project", TODAY));
491495

492496
const trend = getDurationTrend(db, 14, "/test/project");
493497

tools/claudeup-core/src/__tests__/integration/conventions-integration.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { tmpdir } from 'node:os';
3232
import {
3333
// Gitignore operations
3434
ensureGitignoreEntries,
35-
removeGitignoreEntries,
3635
checkGitignoreEntries,
3736
// CLAUDE.md operations
3837
parseClaudeMdSections,

tools/claudeup-core/src/__tests__/unit/doctor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* with real plugin.json files. runDoctor is tested by mocking the registry.
1111
*/
1212

13-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
13+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1414
import { mkdtemp, rm, writeFile, readFile, mkdir } from 'node:fs/promises';
1515
import { existsSync } from 'node:fs';
1616
import { tmpdir } from 'node:os';

tools/claudeup-core/src/services/conventions-manager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
import { readFile, writeFile, stat, rename, unlink, open } from 'node:fs/promises';
17-
import { existsSync } from 'node:fs';
1817
import { randomUUID } from 'node:crypto';
1918
import { dirname, basename, join, resolve } from 'node:path';
2019
import { homedir } from 'node:os';

tools/claudeup-core/src/services/doctor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
removeClaudeMdSection,
2727
} from './conventions-manager.js';
2828
import { parsePluginId } from '../utils/string-utils.js';
29-
import type { PluginConventions, InstalledPluginEntry } from '../types/index.js';
29+
import type { PluginConventions } from '../types/index.js';
3030

3131
// ============================================================
3232
// TYPES

0 commit comments

Comments
 (0)