Walking the site as a student (desktop, a phone-width screen, dark) found these. Each is small; together they are what got in the way. Defects: - Opening a problem in the Bridge saved the generated Mojo over the exercise's own program. The workspace fills every pane's editor as it opens, the editor reported that as typing, and the Bridge's read-only Mojo pane holds the generated text. Developer then showed generated Mojo labeled "your edits", and the problem counted as edited. The value setter now marks its change as a load, the change listener leaves loads out, and a Bridge session refuses a Mojo edit. - A page opened at #/#problems or #/#reference stopped about 45px past the heading: the fonts arrived after the place was computed. A page built this moment goes straight to its section and finds it again when the fonts are in; a page already on screen still scrolls there. The workspace: - With no run to step, the Run view said "Nothing to run yet." It and the stepper now give one reason (src/core/norun.ts): how many problems the stepped pane has and the first with its line, with a button to the line and the Problems list; or that the pane is empty. - In the Bridge the dock starts at about a quarter of the height (it holds a call, a line of output, a short list), so the code and the run get the room. Developer keeps a third for the compiler's answer. A double-click on a divider returns to the area's default, not to the student's last position. - The reason a pane is not in step wraps instead of ending in an ellipsis, and a button in the pane's head keeps its words on one line. - A problem that does not exist keeps the site's navigation and links the problem list. - Help, the theme switch and the stepper's first, back, step and last buttons have names a screen reader can say. A phone-width screen: - The toolbar is three rows in every area and on every tab (it was four or five): the mark, the area, help and the theme; the problem, Versions and Reset; the actions. About 30px more of the code shows. An embedded workspace keeps its own toolbar. - The Share dialog puts each row's name above what it holds (a note had been squeezed to a word per line), and the Versions menu opens across the screen instead of running off its right edge. - The stepper's speed label stays with its slider. Checked by hand, in headless Chromium at 1440x900, 1366x768, 390x844 and 320x640, light and dark: each state above before and after; the editor has line numbers and highlighting; the stepper steps; embeds (playground, trace, Developer) are unchanged; 31 smoke scenarios clean but the ones that err on purpose.
43 lines
2.6 KiB
JavaScript
43 lines
2.6 KiB
JavaScript
// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// Every code pane is the CodeMirror editor (src/ui/editor.ts), never a plain <textarea>.
|
|
// A textarea loses highlighting, line numbers, the teaching gutter (diagnostics, breakpoints,
|
|
// run counts, the current line), hover help, and search, so these checks fail loudly if a
|
|
// refactor swaps one in or the vendored CodeMirror stops being built.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
|
|
const src = (p) => fs.readFileSync(new URL(`../${p}`, import.meta.url), 'utf8');
|
|
|
|
test('the editor is CodeMirror 6, vendored and built into dist/', () => {
|
|
assert.match(src('src/ui/editor.ts'), /from '\.\.\/vendor\/codemirror\.js'/);
|
|
assert.ok(fs.existsSync(new URL('../dist/vendor/codemirror.js', import.meta.url)), 'dist/vendor/codemirror.js is missing: the build no longer ships the editor');
|
|
assert.ok(fs.statSync(new URL('../dist/vendor/codemirror.js', import.meta.url)).size > 100_000, 'dist/vendor/codemirror.js is too small to be CodeMirror');
|
|
});
|
|
|
|
test('the workspace and the embeds make their code panes with Editor', () => {
|
|
for (const f of ['src/ui/shell.ts', 'src/ui/embed.ts']) {
|
|
const text = src(f);
|
|
assert.match(text, /import \{[^}]*\bEditor\b[^}]*\} from '\.\/editor\.js'/, `${f} no longer imports Editor`);
|
|
assert.match(text, /new Editor\(/, `${f} no longer makes an Editor`);
|
|
}
|
|
});
|
|
|
|
test('textareas are only for the small setup and input boxes, never for code', () => {
|
|
for (const f of ['src/ui/shell.ts', 'src/ui/embed.ts']) {
|
|
for (const m of src(f).matchAll(/el\('textarea',\s*\{([^}]*)\}/g)) {
|
|
assert.match(m[1], /setup-ta/, `${f} makes a textarea that is not a setup or input box: ${m[0].slice(0, 80)}`);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('text the app loads into an editor is not reported as the student typing', () => {
|
|
// the value setter and setSynced mark their change (the `load` and `sync` user events), and the listener that
|
|
// reports edits leaves both out; without it, filling the Bridge's read-only Mojo pane saved the generated Mojo
|
|
const text = src('src/ui/editor.ts');
|
|
assert.match(text, /set value\(v: string\) \{[\s\S]{0,700}?userEvent: 'load'/, 'the value setter no longer marks its change as a load');
|
|
assert.match(text, /setSynced\(v: string\): void \{[\s\S]{0,700}?userEvent: 'sync'/, 'setSynced no longer marks its change as a sync');
|
|
assert.match(text, /!tr\.isUserEvent\('sync'\) && !tr\.isUserEvent\('load'\)\)\) this\.opts\.onChange/, 'the change listener reports loads or syncs as edits');
|
|
});
|