commit
e092cb029c
252 files changed
+35037
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// 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)}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user