diff --git a/packages/webui/src/public/workspace.js b/packages/webui/src/public/workspace.js index 6f81ad2d7..b87141298 100644 --- a/packages/webui/src/public/workspace.js +++ b/packages/webui/src/public/workspace.js @@ -427,7 +427,12 @@ const READ_WHY = { 'channel-disabled': 'the chat channel is off', 'outcome-unknown': 'no answer', timeout: 'no answer in time' }; const missOf = (r, names) => { const n = r?.state === 'ok' && r.errors ? names.find(x => r.errors[x]) : null; return n ? READ_WHY[r.errors[n]] || String(r.errors[n]) : null; }; const missed = (o, names) => o.rows.filter(r => missOf(r, names)).map(r => `${esc(o.name(r.org))} (${esc(missOf(r, names))})`); - const missLine = (o, names, key) => { const m = missed(o, names); return m.length ? `

Not read in ${andList(m)}.

` : ''; }; + const missLine = (o, names, key, lead = 'Not read in') => { const m = missed(o, names); return m.length ? `

${lead} ${andList(m)}.

` : ''; }; + // The organizations that answered and made every read a figure is built from. Only these count + // toward it: a failed read reaches the merge as an empty list, so its zero is not a figure. + const readers = (o, names) => new Set(o.rows.filter(r => r.state === 'ok' && !missOf(r, names)).map(r => r.org)); + // Some organizations exist, and none of them could make these reads. + const noneRead = (o, names) => o.rows.length > 0 && !readers(o, names).size; function failedPage(cls, attr, title, err) { const why = err?.status === 403 ? 'This Console refused the read across organizations.' : err?.status === 0 ? 'You are signed out. Reload the page to sign in again.' : err?.status === 400 ? 'The read refused these filters. Clear them and try again.' : 'The read across organizations did not answer. The page tries again on its next refresh.'; return `

${title}

${why}

`; @@ -450,21 +455,23 @@ catch (err) { return failedPage('ws-home', 'data-ws-home', 'Dashboard', err); } const o = orgsOf(body), m = body.metrics, t = m?.totals, per = arr(m?.orgs); const inbox = arr(body.inbox), sessions = arr(body.sessions), projectRows = arr(body.projects), tasks = arr(body.tasks); - tellInbox(body.inbox); - const parts = f => per.map(x => ({ id: x.org, n: num(f(x)) })); + if (!noneRead(o, ['inbox'])) tellInbox(body.inbox); const sessN = s => num(s?.working) + num(s?.waiting) + num(s?.idle) + num(s?.live); - const SRC = { needs: ['inbox'], sessions: ['agents', 'claims', 'threads'], tasks: ['tasks'], projects: ['projects'] }; + // The reads each tile's figures come from (workspace-read.mjs orgRows). + const SRC = { needs: ['inbox'], sessions: ['agents', 'claims'], tasks: ['tasks'], projects: ['projects'] }; + // Per-organization figures name only the organizations that made the tile's reads. + const parts = (key, f) => { const ok = readers(o, SRC[key]); return per.filter(x => ok.has(x.org)).map(x => ({ id: x.org, n: num(f(x)) })); }; const answered = o.rows.filter(r => r.state === 'ok').length; const tile = (key, name, big, small, ps, delta) => { const m = missed(o, SRC[key]); - if (m.length && m.length === answered) return `
${name}Not read${andList(m)}
`; + if (!readers(o, SRC[key]).size) return `
${name}Not read${andList(m)}
`; return `
${name}${big}${small ? `${small}` : ''}${ps ? bar(o, ps) + by(o, ps) : ''}${delta}${m.length ? `Not read in ${andList(m)}` : ''}
`; }; - const tiles = t ? `
- ${tile('needs', 'Needs you', num(t.needsYou), t.needsYou === 1 ? 'item' : 'items', parts(x => x.needsYou), t.oldestNeedsYouAt ? `oldest ${span(t.oldestNeedsYouAt)}` : 'nothing waiting')} - ${tile('sessions', 'Sessions', sessN(t.sessions), `${num(t.sessions?.working)} working`, parts(x => sessN(x.sessions)), `${num(t.sessions?.waiting)} waiting on you · ${num(t.sessions?.idle)} idle${num(t.sessions?.live) ? ` · ${num(t.sessions.live)} live ${t.sessions.live === 1 ? 'thread' : 'threads'}` : ''}`)} - ${tile('tasks', 'Open tasks', num(t.openTasks), '', parts(x => x.openTasks), `${num(t.doneThisWeek)} done this week`)} - ${tile('projects', 'Projects', num(t.projects?.active) + num(t.projects?.archived), `${num(t.projects?.active)} active`, parts(x => num(x.projects?.active) + num(x.projects?.archived)), `${num(t.projects?.archived)} archived`)} + const tiles = t && answered ? `
+ ${tile('needs', 'Needs you', num(t.needsYou), t.needsYou === 1 ? 'item' : 'items', parts('needs', x => x.needsYou), t.oldestNeedsYouAt ? `oldest ${span(t.oldestNeedsYouAt)}` : 'nothing waiting')} + ${tile('sessions', 'Sessions', sessN(t.sessions), `${num(t.sessions?.working)} working`, parts('sessions', x => sessN(x.sessions)), `${num(t.sessions?.waiting)} waiting on you · ${num(t.sessions?.idle)} idle${num(t.sessions?.live) ? ` · ${num(t.sessions.live)} live ${t.sessions.live === 1 ? 'thread' : 'threads'}` : ''}`)} + ${tile('tasks', 'Open tasks', num(t.openTasks), '', parts('tasks', x => x.openTasks), `${num(t.doneThisWeek)} done this week`)} + ${tile('projects', 'Projects', num(t.projects?.active) + num(t.projects?.archived), `${num(t.projects?.active)} active`, parts('projects', x => num(x.projects?.active) + num(x.projects?.archived)), `${num(t.projects?.archived)} archived`)}
Model spendNo spend figures yetNo read prices model use today.
` : '

No organization answered, so there are no totals yet.

'; @@ -476,25 +483,26 @@ const recent = projectRows.filter(p => p.lastActivity).slice(0, 6); const STATE_WORD = { working: 'has a session working', waiting: 'is waiting on you', idle: 'has an idle session', none: 'no live session' }; - const trail = recent.length ? `
    ${recent.map(p => `
  1. ${av(o.meta(p.org))}${esc(p.name || p.key || p.id)} ${STATE_WORD[p.state] || ''}${p.needsYou ? `, ${plural(p.needsYou, 'item')} for you` : ''} · ${esc(o.name(p.org))}
  2. `).join('')}
` : '

No project activity yet

'; + const trail = recent.length ? `
    ${recent.map(p => `
  1. ${av(o.meta(p.org))}${esc(p.name || p.key || p.id)} ${STATE_WORD[p.state] || ''}${p.needsYou ? `, ${plural(p.needsYou, 'item')} for you` : ''} · ${esc(o.name(p.org))}
  2. `).join('')}
` : `

${noneRead(o, ['projects']) ? 'Projects not read' : 'No project activity yet'}

`; const open = tasks.filter(x => !x.done); const buckets = new Map(); for (const x of open) { const b = typeof x.bucket === 'string' && x.bucket ? x.bucket : ''; if (!buckets.has(b)) buckets.set(b, new Map()); const g = buckets.get(b); g.set(x.org, (g.get(x.org) || 0) + 1); } const srows = [...buckets.entries()].map(([b, g]) => ({ name: b ? titleCase(b) : 'No bucket', g, n: [...g.values()].reduce((a, c) => a + c, 0) })).sort((a, b) => b.n - a.n); - if (t) srows.push({ name: 'Done this week', g: new Map(per.map(x => [x.org, num(x.doneThisWeek)])), n: num(t.doneThisWeek) }); + const taskOrgs = readers(o, ['tasks']); + if (t && taskOrgs.size) srows.push({ name: 'Done this week', g: new Map(per.filter(x => taskOrgs.has(x.org)).map(x => [x.org, num(x.doneThisWeek)])), n: num(t.doneThisWeek) }); const max = Math.max(1, ...srows.map(s => s.n)); - const states = srows.length ? `
${srows.map(s => { const ps = [...s.g.entries()].filter(([, n]) => n > 0).map(([id, n]) => ({ id, n })); return `
${esc(s.name)}${s.n}${bar(o, ps, `width:${Math.max(4, Math.round((s.n / max) * 90))}%`)}${by(o, ps)}
`; }).join('')}
` : '

No open tasks

'; + const states = srows.length ? `
${srows.map(s => { const ps = [...s.g.entries()].filter(([, n]) => n > 0).map(([id, n]) => ({ id, n })); return `
${esc(s.name)}${s.n}${bar(o, ps, `width:${Math.max(4, Math.round((s.n / max) * 90))}%`)}${by(o, ps)}
`; }).join('')}
` : `

${noneRead(o, ['tasks']) ? 'Tasks not read' : 'No open tasks'}

`; const needs = inbox.slice(0, 5); - const needsList = needs.length ? `${inbox.length > needs.length ? `

${inbox.length - needs.length} more in the inbox

` : ''}` : '

Nothing needs you

'; + const needsList = needs.length ? `${inbox.length > needs.length ? `

${inbox.length - needs.length} more in the inbox

` : ''}` : `

${noneRead(o, ['inbox']) ? 'Decisions not read' : 'Nothing needs you'}

`; const now = sessions.filter(s => s.kind === 'thread' || s.state === 'working' || s.state === 'waiting'); const idle = sessions.length - now.length; const who = s => (s.kind === 'thread' ? s.instance || s.thread || 'thread' : s.role || 'agent'); const what = s => s.project?.name || s.task?.title || ''; const st = s => { const [cls, glyph, word] = s.kind === 'thread' ? ['s-working', '●', 'live'] : ACTIVITY[s.state] || ['s-unknown', '?', s.state || 'not reported']; return `${dot(cls, glyph, word === 'waiting on you' ? 'waiting' : word, true)}${s.state === 'waiting' ? ' on you' : s.since ? ` ${esc(span(s.since))}` : ''}`; }; - const sessTable = now.length ? `
${now.slice(0, 8).map(s => ``).join('')}
Agent and projectStatus
${av(o.meta(s.org), 'xs')}${esc(who(s))}${what(s) ? ` · ${esc(what(s))}` : ''}${st(s)}
${now.length > 8 ? `

${now.length - 8} more on Agents

` : ''}` : `

No session working right now${idle ? `; ${plural(idle, 'idle session')}` : ''}

`; + const sessTable = now.length ? `
${now.slice(0, 8).map(s => ``).join('')}
Agent and projectStatus
${av(o.meta(s.org), 'xs')}${esc(o.name(s.org))}: ${esc(who(s))}${what(s) ? ` · ${esc(what(s))}` : ''}${st(s)}
${now.length > 8 ? `

${now.length - 8} more on Agents

` : ''}` : `

${noneRead(o, ['agents', 'claims']) ? 'Sessions not read' : `No session working right now${idle ? `; ${plural(idle, 'idle session')}` : ''}`}

`; const total = t ? num(t.projects?.active) + num(t.projects?.archived) : null; const allRead = !o.unread.length; @@ -517,7 +525,7 @@ ${secH('Needs you', '', `Inbox`)} ${needsList}${missLine(o, ['inbox'], 'needs')} ${secH('Sessions now', '', `Agents`)} - ${sessTable}${missLine(o, ['agents', 'claims', 'threads'], 'sessions')} + ${sessTable}${missLine(o, ['agents', 'claims'], 'sessions')}
`; @@ -561,6 +569,11 @@ const ar = key => (f.sort === key ? `` : ''); const head = `${flat ? `Organization${ar('org')}` : ''}Project${ar('name')}Status${ar('status')}SessionsOpen tasksNeeds youLast activity${ar('activity')}Git`; const SESS = [['working', 's-working', '●', 'working'], ['waiting', 's-waiting', '◐', 'waiting'], ['idle', 's-idle', '–', 'idle']]; + // A row's figures come from more reads than its project list (workspace-read.mjs orgRows). A + // figure whose reads failed in the row's organization says "not read", never 0 or none. + const DEP = { sessions: ['agents', 'claims', 'threads', 'tasks'], tasks: ['tasks'], needs: ['inbox', 'tasks'], activity: ['tasks', 'inbox', 'agents', 'claims', 'threads'] }; + const notRead = (p, key) => missOf(o.rows.find(r => r.org === p.org), DEP[key]); + const nr = why => `not read`; const sessCell = p => { const s = p.sessions || {}, have = SESS.filter(([k]) => num(s[k]) > 0); if (!have.length) return 'none'; const [k, cls, glyph, word] = have[0]; return `${dot(cls, glyph, `${num(s[k])} ${word}`, true)}${have.length > 1 ? `${have.slice(1).map(([k2, , , w2]) => `${num(s[k2])} ${w2}`).join(' · ')}` : ''}`; }; const row = p => { const href = `${orgHref(p.org)}/projects/${enc(p.id)}`, active = p.status === 'active'; @@ -568,16 +581,16 @@ ${flat ? `${o.ref(p.org)}` : ''} ${av(o.meta(p.org), 'xs mob')}${esc(p.name || p.key || p.id)} in ${esc(o.name(p.org))}${p.key ? `${esc(p.key)}` : ''}${p.lastActivity ? esc(ago(p.lastActivity)) : 'No activity yet'} ${active ? dot('s-ok', '●', 'active', true) : dot('s-idle', '–', 'archived', true)} - ${sessCell(p)} - ${num(p.openTasks)} - ${p.needsYou ? `${num(p.needsYou)}` : '0'} - ${p.lastActivity ? `` : 'none yet'} + ${notRead(p, 'sessions') ? nr(notRead(p, 'sessions')) : sessCell(p)} + ${notRead(p, 'tasks') ? nr(notRead(p, 'tasks')) : num(p.openTasks)} + ${notRead(p, 'needs') ? nr(notRead(p, 'needs')) : p.needsYou ? `${num(p.needsYou)}` : '0'} + ${p.lastActivity ? `${notRead(p, 'activity') ? 'some reads missing' : ''}` : notRead(p, 'activity') ? nr(notRead(p, 'activity')) : 'none yet'} ${p.git ? `${esc(p.git)}` : 'none'} `; }; const unreadRow = r => `${dot(...orgState(r), true)} Not read${r.at ? ` at ${esc(hm(r.at))}` : ''}${r.reason ? `: ${esc(r.reason)}` : ''}`; let tbody; - if (flat) tbody = rows.length ? rows.map(row).join('') : `${f.org || f.state || f.name || f.status.join() !== 'active' ? 'No projects match these filters' : 'No projects yet'}`; + if (flat) tbody = rows.length ? rows.map(row).join('') : `${noneRead(o, ['projects']) ? 'Projects not read' : f.org || f.state || f.name || f.status.join() !== 'active' ? 'No projects match these filters' : 'No projects yet'}`; else { const groups = (f.sort === 'org' && f.order === 'desc' ? [...o.rows].reverse() : o.rows); tbody = groups.map(r => { @@ -588,7 +601,8 @@ }).join('') || `No organizations yet`; } const unreadNote = flat && o.unread.length ? `

Not in this list: ${andList(o.unread.map(stateWords))}.

` : ''; - const missNote = flat ? missLine(o, ['projects'], 'projects') : ''; + // Projects that were read can still lack figures from the other reads; the cells say "not read". + const missNote = (flat ? missLine(o, ['projects'], 'projects') : '') + missLine({ ...o, rows: o.rows.filter(r => !missOf(r, ['projects'])) }, DEP.activity, 'figures', 'Some figures not read in'); const shown = new Set(rows.map(p => p.org)).size; const sub = `${plural(rows.length, 'project')} in ${plural(shown, 'organization')}, sorted by ${SORT_WORD[f.sort]}${f.sort === 'activity' ? (f.order === 'desc' ? ', newest first' : ', oldest first') : f.order === 'desc' ? ', descending' : ''}. Each row names its organization by mark and colour edge.`; const statusVal = f.status.join(','); @@ -619,7 +633,7 @@ } catch (err) { return failedPage('ws-inbox', 'data-ws-inbox', 'Inbox', err); } const every = orgsOf(all || body), o = orgsOf(body); const everyRows = arr((all || body).inbox); - tellInbox(everyRows); + if (!noneRead(every, ['inbox'])) tellInbox(everyRows); const counts = new Map(); for (const d of everyRows) counts.set(d.org, (counts.get(d.org) || 0) + 1); const rows = arr(body.inbox); @@ -635,7 +649,7 @@ `; }; const unread = (o.unread.length ? `

Not in this list: ${andList(o.unread.map(stateWords))}.

` : '') + missLine(o, ['inbox'], 'inbox'); - const table = rows.length ? `
${rows.map(row).join('')}
Items that need you
SourceNeedsClassWaiting
` : `

${org ? 'Nothing needs you in these organizations' : 'Nothing needs you'}

`; + const table = rows.length ? `
${rows.map(row).join('')}
Items that need you
SourceNeedsClassWaiting
` : `

${noneRead(o, ['inbox']) ? 'Decisions not read' : org ? 'Nothing needs you in these organizations' : 'Nothing needs you'}

`; let insp = ''; if (picked) { const d = picked, id = esc(d.id); @@ -658,7 +672,7 @@ `; } const orgsWith = new Set(rows.map(d => d.org)).size; - const sub = rows.length ? `${plural(rows.length, 'item')} need${rows.length === 1 ? 's' : ''} you, from ${plural(orgsWith, 'organization')}. Each row names where it came from. An item leaves only when it is answered.` : `${missed(o, ['inbox']).length || o.unread.length ? 'Nothing needs you in the organizations that were read.' : 'Nothing needs you right now.'} An item leaves only when it is answered.`; + const sub = rows.length ? `${plural(rows.length, 'item')} need${rows.length === 1 ? 's' : ''} you, from ${plural(orgsWith, 'organization')}. Each row names where it came from. An item leaves only when it is answered.` : `${noneRead(o, ['inbox']) ? 'No organization\'s inbox could be read.' : missed(o, ['inbox']).length || o.unread.length ? 'Nothing needs you in the organizations that were read.' : 'Nothing needs you right now.'} An item leaves only when it is answered.`; return `

Inbox

${sub}

diff --git a/packages/webui/tests/org-archive-browser.test.mjs b/packages/webui/tests/org-archive-browser.test.mjs index 9f4960d10..6e51cf453 100644 --- a/packages/webui/tests/org-archive-browser.test.mjs +++ b/packages/webui/tests/org-archive-browser.test.mjs @@ -131,6 +131,7 @@ test('owner can start a down bus after setup recorded done and sees recovery gui const f = await fixture(t); await f.b.evaluate(`(()=>{const old=window.fetch;window.fetch=async (input,init={})=>{const u=String(input);if(u.endsWith('/setup') && (!init.method || init.method==='GET'))return new Response(JSON.stringify({notifications:{state:'done'},queue:{state:'done'},projects:[],bus:{state:'done',verb:'mosaic bus start alpha'}}),{status:200});if(u.endsWith('/setup/bus') && init.method==='POST')return new Response(JSON.stringify({error:'stale-lock',message:'stale bus host lock'}),{status:409});return old(input,init)}})()`); await f.open('alpha'); + // The setup steps render after the editor title, once the setup and organization list reads answer. await f.wait(`!!document.querySelector('[data-step="bus"] [data-run="bus"]:not(:disabled)')`); await f.b.evaluate(`document.querySelector('[data-step="bus"] [data-run="bus"]').click()`); await f.wait(`document.querySelector('[data-step="bus"]').innerText.includes('stale bus host lock')`); diff --git a/packages/webui/tests/workspace-pages-browser.test.mjs b/packages/webui/tests/workspace-pages-browser.test.mjs index 28cf3f143..7073bde2d 100644 --- a/packages/webui/tests/workspace-pages-browser.test.mjs +++ b/packages/webui/tests/workspace-pages-browser.test.mjs @@ -14,7 +14,7 @@ const at = minutesAgo => new Date(Date.now() - minutesAgo * 60000).toISOString() // acme and beta answer; gamma's bus is stopped. Decision ids are long so a shortened id would show. const ACME_DECISION = 'dec-acme-7f3c9a21-5b8e-4d1f-9c2a-0e6b7d8f9a10'; const BETA_DECISION = 'dec-beta-1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d'; -function fixture({ pollMs, fail = {} } = {}) { +function fixture({ pollMs, fail = {}, down = [] } = {}) { const LIST = [ { id: 'acme', label: 'Acme Studio', theme: 'cobalt', busHealthy: true }, { id: 'beta', label: 'Beta Works', theme: 'grove', busHealthy: true }, @@ -48,7 +48,8 @@ function fixture({ pollMs, fail = {} } = {}) { }); const member = org => ({ id: org.id, doc: { appearance: { theme: org.theme } }, - status: async () => (org.busHealthy ? { healthy: true, pid: 4242, boot: null } : { healthy: false, boot: { ok: false, at: at(90), lastGood: null, reason: 'stopped by the owner' } }), + // down: the cross-organization read finds these buses stopped; the page's own reads still answer. + status: async () => (org.busHealthy && !down.includes(org.id) ? { healthy: true, pid: 4242, boot: null } : { healthy: false, boot: { ok: false, at: at(90), lastGood: null, reason: 'stopped by the owner' } }), options: () => opts(org.id), }); return { @@ -68,8 +69,8 @@ function fixture({ pollMs, fail = {} } = {}) { }; } -async function setup(t, { viewport = [1440, 900], hash = '/', workspaceTimeoutMs, fail } = {}) { - const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture({ fail }), log: () => {}, ...(workspaceTimeoutMs ? { workspaceTimeoutMs } : {}) }); +async function setup(t, { viewport = [1440, 900], hash = '/', workspaceTimeoutMs, fail, down } = {}) { + const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture({ fail, down }), log: () => {}, ...(workspaceTimeoutMs ? { workspaceTimeoutMs } : {}) }); t.after(() => close(server)); const b = await browser({ machine: false }); t.after(() => b.close()); await b.viewport(...viewport); @@ -308,3 +309,60 @@ test('When every answering organization failed a read, its tile says Not read in assert.match(await text('[data-ws-tile=projects]'), /Not read/i); assert.equal(await text('[data-ws-tile=projects] .ws-big'), null); }); + +// Review P2 (org-u3): a project row's figures come from reads beyond the project list. +test('Project rows and per-organization figures say not read when the reads behind them failed', async t => { + const { b, wait, text } = await setup(t, { fail: { beta: ['inbox', 'tasks', 'agents', 'claims', 'threads'] }, hash: '/projects' }); + await wait('document.querySelector("[data-ws-project=\'beta:p-shop\']")'); + const cells = await b.evaluate(`[...document.querySelector("[data-ws-project='beta:p-shop']").cells].map(c => c.innerText.trim())`); + // Grouped columns: Project, Status, Sessions, Open tasks, Needs you, Last activity, Git. + assert.deepEqual(cells.slice(2, 5), ['not read', 'not read', 'not read'], 'sessions, open tasks and needs you'); + assert.match(cells[5], /some reads missing/); + const acme = await b.evaluate(`[...document.querySelector("[data-ws-project='acme:p-site']").cells].map(c => c.innerText.trim())`); + assert.equal(acme[3], '1'); assert.equal(acme[4], '1'); + assert.match(await text('[data-ws-miss=figures]'), /Some figures not read in Beta Works/); + // Dashboard: the per-organization figures leave Beta out instead of showing its 0. + await b.evaluate('location.hash = "#/orgs/acme/"'); + await wait('document.querySelector("[data-ws-tiles]")'); + for (const tile of ['needs', 'sessions', 'tasks']) { + const by = await b.evaluate(`document.querySelector('[data-ws-tile=${tile}] .ws-by')?.textContent ?? ''`); + assert.doesNotMatch(by, /Beta Works/, tile); + assert.match(await text(`[data-ws-tile=${tile}] [data-ws-miss=${tile}]`), /Not read in Beta Works/, tile); + } + assert.doesNotMatch(await b.evaluate(`[...document.querySelectorAll('[data-ws-states] .ws-srow')].find(r => /Done this week/.test(r.textContent))?.querySelector('.ws-by')?.textContent ?? ''`), /Beta Works/); +}); + +test('With every organization down the dashboard and inbox show no totals and no empty-list claims', async t => { + const { b, wait, text } = await setup(t, { down: ['acme', 'beta'] }); + await wait('document.querySelector("[data-ws-tiles]")'); + assert.equal(await b.evaluate('document.querySelectorAll("[data-ws-home] .ws-big").length'), 0); + assert.match(await text('[data-ws-tiles]'), /No organization answered/); + assert.equal(await text('[data-ws-needs]'), 'Decisions not read'); + assert.equal(await text('[data-ws-states]'), 'Tasks not read'); + assert.equal(await text('[data-ws-recent]'), 'Projects not read'); + assert.equal(await text('[data-ws-sessions]'), 'Sessions not read'); + await b.evaluate('location.hash = "#/orgs/acme/inbox"'); + await wait('document.querySelector("[data-ws-items]")'); + assert.equal(await text('[data-ws-items]'), 'Decisions not read'); + await b.evaluate('location.hash = "#/orgs/acme/projects?grouping=flat"'); + await wait('document.querySelector("[data-ws-table]")'); + await b.evaluate('document.querySelector("[data-ws-group=flat]").click()'); + await wait('document.querySelector("[data-ws-table][data-grouping=flat]")'); + assert.match(await text('[data-ws-table] tbody'), /Projects not read/); +}); + +test('When no organization could read its tasks, Tasks by state shows no Done this week figure', async t => { + const { wait, text } = await setup(t, { fail: { acme: ['tasks'], beta: ['tasks'] } }); + await wait('document.querySelector("[data-ws-states]")'); + assert.equal(await text('[data-ws-states]'), 'Tasks not read'); + assert.match(await text('[data-ws-tile=tasks]'), /Not read/); +}); + +// Review P3: the session's organization is in the accessible text, not only in the hidden avatar. +test('Sessions now names each session\'s organization for a screen reader', async t => { + const { b, wait } = await setup(t); + await wait('document.querySelector("[data-ws-sessions] td.who")'); + const who = await b.evaluate('[...document.querySelectorAll("[data-ws-sessions] td.who")].map(c => c.textContent)'); + assert.ok(who.some(w => /Acme Studio: coder/.test(w)), who.join('|')); + assert.ok(who.some(w => /Beta Works: pm/.test(w)), who.join('|')); +});