summaryrefslogtreecommitdiff
path: root/test/web/catalog_ui.mjs
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-12 17:15:03 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:16 -0300
commit7a07e24916cd5bc762996d81aa1faf550177cd6f (patch)
tree4530a8562fb3f068cc4340f1fab1f6c599721735 /test/web/catalog_ui.mjs
parentf9ca3fb5ba767300bec3f1fbb13fc5e6552a90e3 (diff)
downloadcloud9-7a07e24916cd5bc762996d81aa1faf550177cd6f.tar.gz
cloud9-7a07e24916cd5bc762996d81aa1faf550177cd6f.zip
9web: serve prefixed sites through the composed 9P namespace
Post only the pure site/control/discovery tree, with a separate host-only adapter and no duplicate supervision. Serve websites, metadata and legacy controls through the ordinary 9P mux; retain whole-root filesystem browsing and compatibility paths. Pin public file descriptors across publication. Add opt-in build-time HTML/CSS prefix packaging with separate atomic preview generations and unchanged JavaScript/default output. Optional compatibility ports use ?u16. Deploy all five workstation sites on [::]:8090, with /mnt/9p/9web controls. Document Plan 9 references, companion build commits, shared-origin trust and live validation. Validated catalogue, host/FUSE, HTTP FS, mux, prefix and Chromium suites; original E2E 32 scenarios; all five live sites, blog navigation, IPv4/IPv6 and real cafe build through 9P.
Diffstat (limited to 'test/web/catalog_ui.mjs')
-rw-r--r--test/web/catalog_ui.mjs29
1 files changed, 24 insertions, 5 deletions
diff --git a/test/web/catalog_ui.mjs b/test/web/catalog_ui.mjs
index eed6c0a..9f4aca5 100644
--- a/test/web/catalog_ui.mjs
+++ b/test/web/catalog_ui.mjs
@@ -48,12 +48,12 @@ try {
const root = path.join(work, 'public'); await fs.mkdir(root);
await fs.writeFile(path.join(root, 'index.html'), '<h1>Fixture</h1>');
await fs.writeFile(path.join(work, 'large.txt'), 'x'.repeat(180000));
- const dashboard = await port(), sitePort = await port(), debugPort = await port();
+ const dashboard = await port(), debugPort = await port();
const runtime = path.join(work, 'runtime');
await fs.mkdir(path.join(runtime, '9p'), { recursive: true });
start(path.resolve('zig-out/bin/9proc-demo'), ['--unix', path.join(runtime, '9p', 'fixture')]);
await wait(() => fs.stat(path.join(runtime, '9p', 'fixture')), '9P fixture posted');
- await fs.writeFile(path.join(work, 'config.json'), JSON.stringify({ filesystem: '/', sites: [{ name: 'fixture', title: 'Fixture notes', cwd: work, root, port: sitePort, build: ['sh', '-c', 'echo integrated-build'], inputs: ['public/index.html'] }] }));
+ await fs.writeFile(path.join(work, 'config.json'), JSON.stringify({ filesystem: '/', sites: [{ name: 'fixture', title: 'Fixture notes', cwd: work, root, build: ['sh', '-c', 'echo integrated-build'], inputs: ['public/index.html'] }] }));
const startWeb = () => start(path.resolve('zig-out/bin/9ns'), ['--mntgen', '--', binary, '--listen', `127.0.0.1:${dashboard}`, '--catalog', path.join(work, 'config.json'), '--catalog-socket', path.join(work, 'catalog.sock'), '--state-dir', path.join(work, 'state')], { ...process.env, XDG_RUNTIME_DIR: runtime });
const web = startWeb();
const url = `http://127.0.0.1:${dashboard}`;
@@ -106,7 +106,7 @@ try {
await fs.writeFile('.zig-cache/catalog-ui/files.png', Buffer.from((await cdp('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
await view('sites'); await readySites();
assert.equal(await evaluate(`document.title`), 'sites — 9web');
- assert.equal(await evaluate(`document.querySelector('#sites-entries .site-name').href`), `http://127.0.0.1:${sitePort}/`);
+ assert.equal(await evaluate(`document.querySelector('#sites-entries .site-name').href`), `${url}/sites/fixture/`);
assert.equal(await evaluate(`document.querySelectorAll('link[rel=stylesheet]').length`), 1);
assert.equal(await evaluate(`document.querySelector('link[rel=stylesheet]').getAttribute('href')`), '/_cloud9/style.css');
// Build button writes through the same /fs tree as the normal file browser.
@@ -161,16 +161,35 @@ try {
web.kill('SIGTERM'); await once(web, 'exit');
await fs.unlink(path.join(work, 'catalog.sock'));
startWeb();
- await wait(async () => (await fetch(url)).ok && (await fetch(`http://127.0.0.1:${sitePort}`)).ok, 'immediate restart with recent HTTP traffic');
+ await wait(async () => (await fetch(url)).ok && (await fetch(`${url}/sites/fixture/`)).ok, 'immediate restart with recent HTTP traffic');
// Opt-in, read-only smoke navigation against an installed workstation.
if (process.env.NINE_WEB_LIVE) {
- for (const pathname of ['/mnt/9p', '/mnt/9p/agents', '/mnt/9p/agents/codex/history', '/mnt/9p/zmx/daybreak/command', '/mnt/9p/zmx/daybreak/cwd', '/usr/bin']) {
+ for (const pathname of ['/mnt/9p', '/mnt/9p/9web', '/mnt/9p/9web/sites/entomology', '/mnt/9p/agents', '/mnt/9p/agents/codex/history', '/mnt/9p/zmx/daybreak/command', '/mnt/9p/zmx/daybreak/cwd', '/usr/bin']) {
await cdp('Page.navigate', { url: process.env.NINE_WEB_LIVE + pathname });
await wait(() => evaluate(`document.getElementById('path')?.value === ${JSON.stringify(pathname)} && (document.getElementById('status').textContent === 'File loaded.' || document.getElementById('status').textContent.includes('entries'))`), 'live navigation: ' + pathname, 30000).catch(async error => {
throw new Error(error.message + ': ' + await evaluate(`document.getElementById('status')?.textContent`));
});
console.log('live browser navigation passed:', pathname);
}
+ for (const site of ['entomology', 'cafe', 'standards', 'pardes', 'cafe-hub']) {
+ const target = `${process.env.NINE_WEB_LIVE}/sites/${site}/`;
+ await cdp('Page.navigate', { url: target });
+ await wait(() => evaluate(`location.href === ${JSON.stringify(target)} && document.readyState === 'complete' && document.body.textContent.length > 50`), 'live website: ' + site, 60000);
+ const images = await evaluate(`Array.from(document.images).filter(i => new URL(i.src).origin === location.origin && i.getAttribute('loading') !== 'lazy').map(i => ({src:i.src, ok:i.complete && i.naturalWidth > 0}))`);
+ assert.deepEqual(images.filter(i => !i.ok), [], `${site}: failed same-origin images`);
+ const unprefixed = await evaluate(`Array.from(document.querySelectorAll('a[href],img[src],script[src],link[href]')).map(e => e.getAttribute('href') || e.getAttribute('src')).filter(u => u?.startsWith('/') && !u.startsWith('//') && !u.startsWith('/sites/${site}/'))`);
+ assert.deepEqual(unprefixed, [], `${site}: unresolved absolute URLs`);
+ console.log('live prefixed website passed:', site, `(${images.length} local images)`);
+ if (site === 'cafe') {
+ await cdp('Page.navigate', { url: target + 'blog/' });
+ await wait(() => evaluate(`location.pathname === '/sites/cafe/blog/' && document.readyState === 'complete' && document.querySelectorAll('a[href^="/sites/cafe/blog/"]').length > 0`), 'cafe blog navigation', 30000);
+ const article = await evaluate(`Array.from(document.querySelectorAll('a[href^="/sites/cafe/blog/"]')).map(a=>a.href).find(h=>new URL(h).pathname !== '/sites/cafe/blog/')`);
+ assert.ok(article);
+ await cdp('Page.navigate', { url: article });
+ await wait(() => evaluate(`location.href === ${JSON.stringify(article)} && document.readyState === 'complete' && document.body.textContent.length > 100`), 'cafe pretty article', 30000);
+ console.log('live cafe blog and pretty article passed:', article);
+ }
+ }
}
console.log('catalog_ui: shared shell/style, tab history, file/log navigation, build control, focus, dirty edits and mobile layout passed');
} catch (e) {