54 lines
4.8 KiB
JavaScript
54 lines
4.8 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { w15Fixture } from './w15-fixture.mjs';
|
|
|
|
const business = { id:'acme', human:'jason', arbiters:{delivery:'pm'}, projects:['stack'], vars:{region:'north'}, actions:['role.launch'], instances:[{instance:'pm',definition:'manager',holder:'sage',vars:{harness:'pi',model:'opus'},authority:{'role.launch':'within'}}], launch:{by:'pm',instances:['pm'],limits:{models:{fixture:{opus:1}}}}, credentials:[{service:'gitea',account:'bot-acme',role:'pm',dateKind:'expires',date:'2099-01-01',state:'valid'}] };
|
|
const opts={timeout:90000};
|
|
async function open(t, tester=false) {
|
|
const x=await w15Fixture(t,{scenario:{'/api/business':{business},'/api/config':{tester,send:!tester}}});
|
|
await x.b.navigate(x.f.base+'/#/settings/appearance');
|
|
await x.wait('!!document.querySelector("#settings-nav")');
|
|
return x;
|
|
}
|
|
|
|
test('Business moves from sidebar to first instance Settings section',opts,async t=>{
|
|
const {b}=await open(t);
|
|
assert.equal(await b.evaluate('[...document.querySelectorAll("#sections a")].filter(e=>e.getAttribute("href")==="#/business").length'),0);
|
|
assert.deepEqual(await b.evaluate('[...document.querySelectorAll("#settings-nav > *")].map(e=>e.textContent.trim()).slice(0,4)'),['Your browser','Appearance','This instance','Business']);
|
|
assert.equal(await b.evaluate('[...document.querySelectorAll("#settings-nav a")].find(e=>e.getAttribute("href")==="#/settings/business").nextElementSibling.textContent.trim()'),'Launch limits');
|
|
});
|
|
|
|
test('legacy Business bookmark replaces its history entry and retains its data',opts,async t=>{
|
|
const {b,wait}=await open(t);
|
|
await b.evaluate('location.hash="#/business"');
|
|
await wait('location.hash==="#/settings/business" && !!document.querySelector("#bz-creds")');
|
|
assert.equal(await b.evaluate('document.querySelector("#bus-view h1").textContent'),'Settings');
|
|
assert.equal(await b.evaluate('document.querySelector("#settings-page-title").textContent'),'Business');
|
|
assert.match(await b.evaluate('document.querySelector(".settings-helper").textContent'),/acme.*Console only reads/i);
|
|
assert.deepEqual(await b.evaluate('[...document.querySelectorAll("[aria-labelledby=bz-about] dt")].map(e=>[e.textContent,e.nextElementSibling.textContent])'),[['Human','jason'],['Arbiters','pm (delivery)'],['Projects','stack'],['Launcher','pm'],['May launch','pm'],['At most','1 fixture / opus'],['region','north']]);
|
|
const content=await b.evaluate('document.querySelector(".settings-business").textContent');
|
|
for(const field of ['jason','pm (delivery)','stack','manager','sage','pi','opus','role.launch','within','gitea','bot-acme','2099-01-01']) assert.ok(content.includes(field),field);
|
|
assert.equal(await b.evaluate('document.querySelector("#bz-about").textContent'),'Business file');
|
|
assert.equal(await b.evaluate('getComputedStyle(document.querySelector("[aria-labelledby=bz-about] h3")).marginTop'),'14px');
|
|
assert.equal(await b.evaluate('document.title'),'Settings · Business · Mosaic Console');
|
|
assert.deepEqual(await b.evaluate('[...document.querySelectorAll("#breadcrumbs a, #breadcrumbs [aria-current]")].map(e=>e.textContent)'),['Settings','Business']);
|
|
await b.evaluate('history.back()'); await wait('location.hash==="#/settings/appearance"');
|
|
});
|
|
|
|
test('mobile disclosure lists Business first in This instance',opts,async t=>{
|
|
const {b}=await open(t); await b.viewport(390,844);
|
|
await b.evaluate('document.querySelector("#settings-disclosure").click()');
|
|
assert.equal(await b.evaluate('document.querySelector("#settings-disclosure").getAttribute("aria-expanded")'),'true');
|
|
assert.deepEqual(await b.evaluate('[...document.querySelectorAll("#settings-nav > *")].map(e=>e.textContent.trim()).slice(0,4)'),['Your browser','Appearance','This instance','Business']);
|
|
assert.equal(await b.evaluate('[...document.querySelectorAll("#settings-nav a")].find(e=>e.getAttribute("href")==="#/settings/business").getClientRects().length>0'),true);
|
|
});
|
|
|
|
test('tester keeps Business access and palette routes directly to Settings',opts,async t=>{
|
|
const {b,wait}=await open(t,true); await wait('!!document.querySelector("#tester-banner")');
|
|
assert.equal(await b.evaluate('[...document.querySelectorAll("#settings-nav a")].find(e=>e.getAttribute("href")==="#/settings/business")?.textContent'),'Business');
|
|
await b.key('k','KeyK',2); await wait('document.querySelector("#cmdk-dialog").open');
|
|
assert.equal(await b.evaluate('[...document.querySelectorAll("#cmdk-list [data-href]")].find(e=>e.textContent.includes("Business"))?.dataset.href'),'#/settings/business');
|
|
await b.key('Escape'); await b.evaluate('location.hash="#/business"'); await wait('location.hash==="#/settings/business" && !!document.querySelector("#bz-creds")');
|
|
assert.match(await b.evaluate('document.querySelector("[aria-labelledby=bz-about]").textContent'),/jason/);
|
|
});
|