Initial commit
Build, test, deploy / site (push) Failing after 15m13s

This commit is contained in:
alexm committed 2026-11-12 22:24:02 -05:00
commit e092cb029c
252 files changed
+35037

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
// SPDX-License-Identifier: Apache-2.0
// The structure a screen reader navigates by, on the pages that render outside a browser: one main landmark, a
// labeled navigation, a footer, one h1, and headings that do not skip a level. (The workspaces are checked by axe in
// a browser: their main, header and h1 come from src/ui/shell.ts.)
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { installDocument } from '../dist/quarto/dom.js';
installDocument();
const store = new Map();
globalThis.localStorage = { getItem: (k) => store.get(k) ?? null, setItem: (k, v) => store.set(k, String(v)), removeItem: (k) => store.delete(k), key: () => null, get length() { return store.size; } };
const { homeView } = await import('../dist/ui/home.js');
const { libraryView } = await import('../dist/ui/library.js');
const { messagePage } = await import('../dist/ui/notice.js');
const { highlighted } = await import('../dist/quarto/render.js');
function outline(root) {
// every heading in document order (the small document's querySelectorAll returns one list per selector)
const out = [];
const walk = (n) => { for (const c of n.children ?? []) { if (/^h[1-6]$/.test(c.localName)) out.push(Number(c.localName[1])); walk(c); } };
walk(root);
return out;
}
for (const [name, view] of [['home', () => homeView()], ['library', () => libraryView()], ['a library routine', () => libraryView('md.LennardJones')]]) {
test(`${name}: one main, a labeled nav, a footer, one h1, and no heading skips a level`, () => {
const root = view();
assert.equal(root.querySelectorAll('main').length, 1);
const nav = root.querySelectorAll('nav').filter((n) => n.getAttribute('class')?.includes('home-nav'));
assert.equal(nav.length, 1);
assert.equal(nav[0].getAttribute('aria-label'), 'Site');
assert.equal(root.querySelectorAll('footer').length, 1);
const levels = outline(root);
assert.equal(levels.filter((l) => l === 1).length, 1, `one h1 in ${levels.join(' ')}`);
assert.equal(levels[0], 1);
for (let i = 1; i < levels.length; i++) assert.ok(levels[i] <= levels[i - 1] + 1, `h${levels[i - 1]} then h${levels[i]} at heading ${i}`);
});
}
test('a message page is a main landmark with its h1', () => {
const page = messagePage('No such problem', 'text');
assert.equal(page.querySelectorAll('main').length, 1);
assert.equal(page.querySelector('h1').textContent, 'No such problem');
});
test('a listing that scrolls can be reached from the keyboard; so can an editor that is read-only', () => {
assert.equal(highlighted('OUTPUT 1', 'pseudo').getAttribute('tabindex'), '0');
assert.match(readFileSync(new URL('../src/ui/editor.ts', import.meta.url), 'utf8'), /contentAttributes\.of\(\{.*tabindex: '0' \}\)/);
const shell = readFileSync(new URL('../src/ui/shell.ts', import.meta.url), 'utf8');
assert.match(shell, /el\('header', \{ class: 'toolbar' \}\)/, 'the toolbar is the workspace\'s banner');
assert.match(shell, /el\('main', \{ class: 'workspace'/, 'the workspace is its main landmark');
assert.match(shell, /el\('h1', \{ class: 'sr-only' \}/, 'and it has an h1');
const embed = readFileSync(new URL('../src/ui/embed.ts', import.meta.url), 'utf8');
assert.match(embed, /const root = el\('main', \{ class: 'embed' \}\)/, 'an embedded view is a main landmark');
assert.match(embed, /el\('h1', \{ class: 'sr-only' \}/, 'with an h1');
});