14 test files took the path of `new URL(rel, import.meta.url).pathname`, which on Windows is "/C:/..." and cannot be resolved (esbuild "Could not resolve"). Strip the leading slash before the drive letter. No behavior change on macOS/Linux. Went from 14 whole-file failures to 6 real test failures (listed in the S0 notes). Easy to drop if the owner would rather have a different fix. Follow-up to the owner's rebuild branch strata/rebuild-2026-10 (small, test-only).
50 lines
2.6 KiB
JavaScript
50 lines
2.6 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { build } from 'esbuild';
|
|
import { createRequire } from 'node:module';
|
|
|
|
const { outputFiles } = await build({ entryPoints: [new URL('../src/lib/router.ts', import.meta.url).pathname.replace(/^\/([A-Za-z]:)/,'$1')], bundle: true, write: false, platform: 'node', format: 'cjs' });
|
|
const browserWindow = { location: { hash: '#/chat/a' }, matchMedia: () => ({ matches: false }) };
|
|
let transitions = 0;
|
|
const documentStub = { documentElement: { dataset: {} }, startViewTransition: () => { transitions++; return { ready: Promise.resolve(), updateCallbackDone: Promise.resolve(), finished: Promise.resolve() }; } };
|
|
const module = { exports: {} };
|
|
new Function('require', 'module', 'exports', 'window', 'document', outputFiles[0].text)(createRequire(import.meta.url), module, module.exports, browserWindow, documentStub);
|
|
const router = module.exports;
|
|
|
|
test('Settings retains the page, chat id and existing query, and reopening is idempotent', () => {
|
|
const opened = router.settingsHref('#/chat/chat-a?preview=project-brief');
|
|
assert.equal(opened, '#/chat/chat-a?preview=project-brief&settings=1');
|
|
assert.equal(router.settingsHref(opened), opened);
|
|
assert.equal(router.settingsHref('#/tuning'), '#/tuning?settings=1');
|
|
const location = router.parseLocation(opened);
|
|
assert.equal(location.route, 'chat');
|
|
assert.equal(location.param, 'chat-a');
|
|
assert.equal(location.query.get('preview'), 'project-brief');
|
|
});
|
|
|
|
test('a Settings bookmark opens over chat; closing restores only the background URL', () => {
|
|
const bookmark = router.parseLocation('#/settings');
|
|
assert.equal(bookmark.route, 'chat');
|
|
assert.equal(bookmark.query.get('settings'), '1');
|
|
browserWindow.location.hash = '#/chat/chat-a?preview=project-brief&settings=1';
|
|
router.closeSettings();
|
|
assert.equal(browserWindow.location.hash, '#/chat/chat-a?preview=project-brief');
|
|
browserWindow.location.hash = '#/monitor';
|
|
router.navigate('settings');
|
|
assert.equal(browserWindow.location.hash, '#/monitor?settings=1');
|
|
router.closeSettings();
|
|
assert.equal(browserWindow.location.hash, '#/monitor');
|
|
});
|
|
|
|
|
|
test('Settings opens and closes immediately without snapshotting the background page', () => {
|
|
browserWindow.location.hash = '#/chat/a';
|
|
router.navigate('settings');
|
|
assert.equal(browserWindow.location.hash, '#/chat/a?settings=1');
|
|
router.closeSettings();
|
|
assert.equal(browserWindow.location.hash, '#/chat/a');
|
|
assert.equal(transitions, 0);
|
|
router.navigate('models');
|
|
assert.equal(transitions, 1, 'ordinary screen navigation still uses its view transition');
|
|
});
|