Files
Wegwichtel/test/editor-database-schema.test.js
T
Florian Zumpe d6228e7e32
Sonarqube Scanner / Build and analyze (push) Failing after 1m54s
added css reference and test case
2026-09-02 00:21:18 +02:00

30 lines
1.1 KiB
JavaScript

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);
});