Skip to content

Commit 2a69d1e

Browse files
pajomaclaude
andcommitted
test(navigation): avoid large historical offset in calendar-mode test
Using 2025-03-08 as a fixed anchor produced a -432-day offset that could misfire via daysBetween → generateDate round-trip on CI. Switch to yesterday → today so the offset is always -1 with no DST exposure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ed20bdd commit 2a69d1e

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/test/suite/commands-prev-next.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,30 @@ suite('Issue #144 — Open Previous / Open Next navigation', () => {
262262
const config = vscode.workspace.getConfiguration('journal');
263263
await config.update('navigation.mode', 'calendar', vscode.ConfigurationTarget.Workspace);
264264

265-
const anchorPath = await seedEntry(tmpBase, 2025, 3, 8);
265+
// Use yesterday as anchor so next = today; offset is -1 (no large DST-sensitive arithmetic).
266+
const yesterday = new Date();
267+
yesterday.setDate(yesterday.getDate() - 1);
268+
const anchorPath = await seedEntry(
269+
tmpBase,
270+
yesterday.getFullYear(),
271+
yesterday.getMonth() + 1,
272+
yesterday.getDate(),
273+
);
266274
const anchorDoc = await vscode.workspace.openTextDocument(vscode.Uri.file(anchorPath));
267275
await vscode.window.showTextDocument(anchorDoc);
268276

269277
const cmdInstance = new (OpenNextEntryCommand as any)(ctrl);
270278
await cmdInstance.run();
271279

272-
const expected = vscode.Uri.file(path.join(tmpBase, '2025', '03', '09.md'));
280+
const today = new Date();
281+
const expectedPath = path.join(
282+
tmpBase,
283+
String(today.getFullYear()).padStart(4, '0'),
284+
String(today.getMonth() + 1).padStart(2, '0'),
285+
`${String(today.getDate()).padStart(2, '0')}.md`,
286+
);
273287
try {
274-
const stat = await vscode.workspace.fs.stat(expected);
288+
const stat = await vscode.workspace.fs.stat(vscode.Uri.file(expectedPath));
275289
assert.ok(stat, 'expected next-day entry to exist on disk');
276290
} catch (err) {
277291
assert.fail(`next-day entry was not created: ${err}`);

0 commit comments

Comments
 (0)