Split browser workflows from presentation

This commit is contained in:
ms2k 2026-07-20 03:37:35 +09:00
commit 0c2d992224

View file

@ -0,0 +1,37 @@
import assert from 'node:assert/strict';
import { readFile, readdir } from 'node:fs/promises';
import path from 'node:path';
import test from 'node:test';
test('Svelte components own neither HTTP nor browser persistence policy', async () => {
const sources = await sourceFiles('src');
const svelte = sources.filter((file) => file.endsWith('.svelte'));
for (const file of svelte) {
const source = await readFile(file, 'utf8');
assert.doesNotMatch(source, /\bfetch\s*\(/, file);
assert.doesNotMatch(source, /\blocalStorage\b/, file);
assert.doesNotMatch(source, /\bon:/, file);
assert.doesNotMatch(source, /\$:/, file);
}
const storageOwners = [];
for (const file of sources) {
const source = await readFile(file, 'utf8');
if (source.includes('nuthatch-recursive-delete')) storageOwners.push(file);
}
assert.deepEqual(storageOwners, [
path.resolve('src/workflows/recursive-delete-persistence.ts')
]);
});
async function sourceFiles(directory) {
const entries = await readdir(directory, { withFileTypes: true });
return (
await Promise.all(
entries.map((entry) => {
const target = path.resolve(directory, entry.name);
return entry.isDirectory() ? sourceFiles(target) : [target];
})
)
).flat();
}