Files
stack/packages/webui/tests/w15-integration-browser.test.mjs

32 lines
2.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { w15Fixture, ids } from './w15-fixture.mjs';
test('integrated project settings and conversation mounts use authorized context', { timeout: 90000 }, async t => {
const scenario = {
'/api/config': { send: true, requests: true, projectRemotes: true, projectRemoteWrites: true },
[`GET /api/chat/rooms/${ids.project}/messages?limit=100`]: {status:503,body:{error:'fixture-unavailable'}},
'GET /api/project-files?project=fixture-repository': {status:503,body:{error:'fixture-unavailable'}},
'GET /api/project-file?project=fixture-repository&path=spec%2Fnorth-star.md': {status:503,body:{error:'fixture-unavailable'}},
'/api/project-remotes/fixture-repository': { project: ids.repository, remote: null, revision: 'a'.repeat(64), firstSaveAllowed: true },
};
const { f, b, wait } = await w15Fixture(t, { scenario });
await b.viewport(390, 1000);
await b.navigate(f.base + `/#/projects/${ids.project}/settings`);
await wait('!!document.querySelector("#project-remote-url")');
assert.equal(await b.evaluate('document.querySelector("#project-context .context-project")?.getAttribute("href")'), `#/projects/${ids.project}`);
assert.equal(await b.evaluate('[...document.querySelectorAll("link")].some(x => x.getAttribute("href") === "/requests.css") && typeof MosaicFiles.mount === "function"'), true);
const route = `#/projects/threads/${ids.thread}/sessions/${ids.session}`;
await b.evaluate(`location.hash=${JSON.stringify(route)}`);
await wait(`document.querySelector('.chat-conversation')?.dataset.session===${JSON.stringify(ids.session)}`);
assert.equal(await b.evaluate(`!!document.querySelector('.project-tabs a[href$="/files"]') && !document.querySelector('[data-chat-files]')`), true);
assert.match(await b.evaluate('document.querySelector("#project-context").textContent'), /Active project.*Project conversation/s);
assert.equal(await b.evaluate('document.querySelector("#project-context .context-conversation").getAttribute("href")'), route);
await b.viewport(1440, 1000);
await wait('document.querySelector("#processing-controls").parentElement.id === "dashboard-processing"');
assert.equal(await b.evaluate('document.querySelector("#processing-controls").parentElement.id'), 'dashboard-processing');
assert.deepEqual(await b.evaluate('window.__errors'), []);
assert.deepEqual(await b.evaluate('window.__writes'), []);
assert.deepEqual(await b.evaluate('window.__unexpected'), []);
});