A UX pass over the workspace, and two defects it turned up
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.
This commit is contained in:
14 files changed
+302
-39
No files matched your search
+20
-1
@@ -9,7 +9,7 @@ import assert from 'node:assert/strict';
|
||||
import { Session } from '../dist/core/session.js';
|
||||
import { PROBLEMS, stateForProblem, problemById } from '../dist/core/catalog.js';
|
||||
import { SyncHub } from '../core/dist/sync/hub.js';
|
||||
import { normalize } from '../dist/core/state.js';
|
||||
import { normalize, editedFrom } from '../dist/core/state.js';
|
||||
import { GENERATED_HEADER } from '../core/dist/sync/header.js';
|
||||
|
||||
globalThis.localStorage = { getItem() { return null; }, setItem() { }, removeItem() { } };
|
||||
@@ -27,6 +27,25 @@ test('in the Bridge the Mojo pane is the generated Mojo, not the stored Mojo; el
|
||||
assert.equal(new Session(stateForProblem(problemById('count-base')), { storageId: null }).source('mojo'), own, 'a session with no area (an embed of one pane) shows the state\'s own Mojo');
|
||||
});
|
||||
|
||||
test('nothing given to the Bridge\'s Mojo pane is stored: opening a problem there leaves the exercise\'s own Mojo', () => {
|
||||
// the workspace fills every pane's editor as it opens; the generated Mojo, loaded into the Bridge's read-only
|
||||
// pane, had been reported as typing and saved over the exercise's program, which Developer then called "your edits"
|
||||
const own = stateForProblem(problemById('count-base')).sources.mojo;
|
||||
const s = open('count-base', 'bridge');
|
||||
let told = 0;
|
||||
s.onChange(() => told++);
|
||||
s.setSource('mojo', s.source('mojo'));
|
||||
s.setSource('mojo', 'def main():\n pass\n');
|
||||
assert.equal(s.state.sources.mojo, own, 'the stored Mojo is still the exercise\'s');
|
||||
assert.equal(s.state.mojoOrigin, undefined);
|
||||
assert.equal(told, 0, 'and nothing was announced as a change');
|
||||
assert.equal(editedFrom(s.state, stateForProblem(problemById('count-base'))), false, 'so the problem does not count as edited');
|
||||
// elsewhere the Mojo pane is the student's
|
||||
const d = open('count-base', 'dev');
|
||||
d.setSource('mojo', 'def main():\n pass\n');
|
||||
assert.equal(d.state.sources.mojo, 'def main():\n pass\n');
|
||||
});
|
||||
|
||||
test('the Bridge\'s Mojo follows an edit in any linked pane, and every view of it reads the generated source', () => {
|
||||
const s = open('count-base');
|
||||
const before = s.source('mojo');
|
||||
|
||||
@@ -31,3 +31,12 @@ test('textareas are only for the small setup and input boxes, never for code', (
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
@@ -35,3 +35,20 @@ test('the shell offers the parts, and Run, Compile & run and a diagnostic\'s lin
|
||||
assert.match(shell, /if \(open\) this\.setNarrow\('dock'\);/, 'opening the dock (Compile & run) shows it');
|
||||
assert.match(shell, /reveal: \(lang, line\) => \{\n\s*this\.setNarrow\('code'\);/, 'a line in the code shows the code');
|
||||
});
|
||||
|
||||
test('a phone-width toolbar is three rows: the classes its rules order are the ones the shell gives', () => {
|
||||
// the mark, the area, help and the theme; the problem, its versions and Reset; the actions. A wide screen keeps the
|
||||
// toolbar's one row, so every one of these rules is inside the 700px query and none applies to an embed's toolbar.
|
||||
const shell = readFileSync(new URL('../src/ui/shell.ts', import.meta.url), 'utf8');
|
||||
const narrow = blocks(css).filter(([p]) => /^@media \(max-width: 700px\)$/.test(p)).map(([, b]) => b).join('\n');
|
||||
for (const cls of ['tool-help', 'tool-reset', 'brand-name', 'icon-btn', 'versions']) {
|
||||
assert.match(shell, new RegExp(`['\` ]${cls}['\` $]`), `the shell no longer gives .${cls}`);
|
||||
assert.match(narrow, new RegExp(`\\.shell:not\\(\\.shell-embed\\) > \\.toolbar[^{]*\\.${cls}\\b`), `no narrow rule for .${cls}`);
|
||||
}
|
||||
assert.match(shell, /class: 'shell' \+ \(this\.embed \? ' shell-embed' : ''\)/, 'an embedded workspace is marked, so its toolbar keeps its own order');
|
||||
assert.match(narrow, /\.toolbar::before, \.shell:not\(\.shell-embed\) > \.toolbar::after \{[^}]*flex-basis: 100%/, 'the two line breaks between the rows');
|
||||
// the short label of the Best practices switch is for a small phone only
|
||||
assert.match(shell, /class: 'tool-wide' \}, 'Best practices'\), el\('span', \{ class: 'tool-tight' \}, 'Practices'\)/);
|
||||
const outside = blocks(css).filter(([p]) => !p.startsWith('@media')).map(([p, b]) => `${p}{${b}}`.replace(/\s+/g, ' '));
|
||||
assert.ok(outside.some((r) => /^\.tool-tight\s*\{ display: none; \}$/.test(r)), '.tool-tight is hidden on a normal screen');
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// When there is no run to step, the stepper and the Run view say what is in the way (src/core/norun.ts): how many
|
||||
// problems the stepped pane has and the first one, what an engine said when it stopped, or that the pane is empty.
|
||||
// "Nothing to run yet." alone told a student with a typo nothing.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { Session } from '../dist/core/session.js';
|
||||
import { stateForProblem, problemById } from '../dist/core/catalog.js';
|
||||
import { whyNoRun } from '../dist/core/norun.js';
|
||||
|
||||
globalThis.localStorage = { getItem() { return null; }, setItem() { }, removeItem() { } };
|
||||
const open = (id, area) => new Session(stateForProblem(problemById(id)), { area, storageId: null });
|
||||
|
||||
test('a pane with problems says how many, and names the first with its line', () => {
|
||||
const s = open('count-base', 'bridge');
|
||||
s.setLang('pseudo');
|
||||
s.setSource('pseudo', s.source('pseudo') + '\nTotal <- Totl + \n');
|
||||
assert.equal(s.trace(), null);
|
||||
const why = whyNoRun(s);
|
||||
assert.equal(why.lang, 'pseudo');
|
||||
assert.ok(why.errors >= 2, `${why.errors} errors`);
|
||||
assert.equal(why.headline, `No run yet: the pseudo pane has ${why.errors} problems to fix first.`);
|
||||
const first = s.diagnostics('pseudo').find((d) => d.severity === 'error');
|
||||
assert.equal(why.detail, `Line ${first.line}: ${first.message}`);
|
||||
assert.equal(why.line, first.line);
|
||||
});
|
||||
|
||||
test('one problem is "a problem", and Mojo\'s own errors are counted the same way', () => {
|
||||
const s = open('count-base', 'dev');
|
||||
s.setLang('mojo');
|
||||
s.setSource('mojo', 'def main():\n var s = String("hi")\n var t = s^\n print(s)\n');
|
||||
assert.equal(s.trace(), null);
|
||||
assert.deepEqual(whyNoRun(s), { headline: 'No run yet: the Mojo pane has a problem to fix first.', detail: "Line 4: use of uninitialized value 's'", errors: 1, lang: 'mojo', line: 4 });
|
||||
});
|
||||
|
||||
test('an empty pane says it is empty', () => {
|
||||
const s = open('count-base', 'dev');
|
||||
s.setLang('mojo');
|
||||
s.setSource('mojo', ' \n');
|
||||
assert.equal(s.trace(), null);
|
||||
assert.deepEqual(whyNoRun(s), { headline: 'Nothing to run yet: the Mojo pane is empty.', detail: null, errors: 0, lang: 'mojo', line: null });
|
||||
});
|
||||
|
||||
test('a pane that runs has no such reason to give: the views ask only when trace() is null', () => {
|
||||
const s = open('count-base', 'bridge');
|
||||
s.setLang('pseudo');
|
||||
assert.ok(s.trace());
|
||||
for (const f of ['src/ui/views/run.ts', 'src/ui/views/trace.ts']) {
|
||||
const text = fs.readFileSync(new URL(`../${f}`, import.meta.url), 'utf8');
|
||||
assert.match(text, /whyNoRun\(session\)/, `${f} no longer asks whyNoRun`);
|
||||
assert.doesNotMatch(text, /'Nothing to run yet\.'/, `${f} has its own "Nothing to run yet." again`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user