This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..');
|
||||
|
||||
async function read(relativePath) {
|
||||
return fs.readFile(path.join(root, relativePath), 'utf8');
|
||||
}
|
||||
|
||||
async function readIfExists(relativePath) {
|
||||
try {
|
||||
return await read(relativePath);
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') return '';
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
test('route activation timestamp is available for editor draft handling', async () => {
|
||||
const schema = await readIfExists('database/schema.sql');
|
||||
const migration = await read('database/migrations/20260901_add_route_activated_at.sql');
|
||||
const schemaDefinesColumn = /\bactivated_at\s+DATETIME\s+NULL\b/i.test(schema);
|
||||
const migrationDefinesColumn = /ALTER\s+TABLE\s+routes\s+ADD\s+COLUMN\s+activated_at\s+DATETIME\s+NULL/i.test(migration);
|
||||
|
||||
assert.ok(schemaDefinesColumn || migrationDefinesColumn);
|
||||
assert.match(migration, /Neue Strecken bleiben unveröffentlicht|unpublished|activated_at is NULL/i);
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..');
|
||||
|
||||
async function read(relativePath) {
|
||||
return fs.readFile(path.join(root, relativePath), 'utf8');
|
||||
}
|
||||
|
||||
test('route editor entry point, dialog and forms are present', async () => {
|
||||
const html = await read('public/index.html');
|
||||
const css = await read('public/css/editor.css');
|
||||
const ui = await read('public/js/editor-ui.js');
|
||||
|
||||
assert.match(html, /id="editor-button"/);
|
||||
assert.match(html, /aria-label="Streckeneditor öffnen"/);
|
||||
assert.match(html, /<dialog id="editor-dialog"/);
|
||||
assert.match(html, /id="editor-route-list"/);
|
||||
assert.match(html, /id="editor-route-form"/);
|
||||
assert.match(html, /id="editor-poi-form"/);
|
||||
assert.match(html, /id="editor-poi-audio"[^>]+accept="audio\/\*"/);
|
||||
assert.match(html, /id="editor-poi-images"[^>]+accept="image\/\*"[^>]+multiple/);
|
||||
assert.match(html, /Neue Strecken bleiben unveröffentlicht/);
|
||||
|
||||
assert.match(css, /\.editor-entry-panel/);
|
||||
assert.match(css, /\.editor-dialog/);
|
||||
assert.match(css, /\.editor-poi-list/);
|
||||
|
||||
assert.match(ui, /pointerup/);
|
||||
assert.doesNotMatch(ui, /addEventListener\(['"]click['"]/);
|
||||
});
|
||||
|
||||
test('route editor references all static editor classes for the project markup checks', async () => {
|
||||
const html = await read('public/index.html');
|
||||
const ui = await read('public/js/editor-ui.js');
|
||||
const classNames = [...html.matchAll(/class="([^"]*\beditor-[^"]*)"/g)]
|
||||
.flatMap(match => match[1].split(/\s+/))
|
||||
.filter(name => name.startsWith('editor-'));
|
||||
|
||||
for (const className of new Set(classNames)) {
|
||||
assert.match(ui, new RegExp(className), `editor class is not referenced by editor-ui.js: ${className}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('route editor supports route creation, route editing, POI sorting and POI media uploads', async () => {
|
||||
const ui = await read('public/js/editor-ui.js');
|
||||
|
||||
assert.match(ui, /readJson\('\/routes'\)/);
|
||||
assert.match(ui, /readJson\(`\/routes\/\$\{encodeURIComponent\(id\)\}`\)/);
|
||||
assert.match(ui, /const method = id \? 'PUT' : 'POST'/);
|
||||
assert.match(ui, /const method = currentPoiId \? 'PUT' : 'POST'/);
|
||||
assert.match(ui, /move-poi-up/);
|
||||
assert.match(ui, /move-poi-down/);
|
||||
assert.match(ui, /sortOrder: index/);
|
||||
assert.match(ui, /uploadPoiMedia/);
|
||||
assert.match(ui, /\/audio`/);
|
||||
assert.match(ui, /\/images`/);
|
||||
});
|
||||
Reference in New Issue
Block a user