Split browser workflows from presentation
This commit is contained in:
parent
c9642f4067
commit
0c2d992224
1 changed files with 1683 additions and 854 deletions
37
web/test/browser-boundaries.test.mjs
Normal file
37
web/test/browser-boundaries.test.mjs
Normal 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();
|
||||
}
|
||||
Loading…
Reference in a new issue