Fix issue #49: Unify folder system
Some checks failed
Test / test (push) Failing after 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-15 12:11:19 +00:00
parent 0106c13835
commit cd92a2d112
19 changed files with 875 additions and 127 deletions

View File

@@ -290,16 +290,18 @@ test("an item the world moved out of a folder follows it to the root", async ()
assert.equal(sync.models["../models/Item"].rows[0].folder, null);
});
test("item folders stay out of the note tree", () => {
// The note routes share the Folder model, so each of them asks for "anything but
// item": note folders made before the target field existed keep matching that.
test("every folder listing says which campaign list it belongs to", () => {
// The sidebar's four lists share the Folder model, so a listing that names no target
// would show folders of the other lists between its own rows. The note routes and
// `/folder/list` ask through `Folder.filterForTarget`, which for the notes names every
// other section instead of the notes' own target: note folders made before the target
// field existed carry none at all. tests/entry-folders.test.js runs these routes.
for (const route of ["note.js", "folder.js"]) {
const source = read("backend", "src", "routes", route);
const listings = source.match(/Folder\.find\(\{[^}]*\}\)/g) ?? [];
const listings = source.match(/Folder\.find\(/g) ?? [];
assert.ok(listings.length, `${route} lists folders`);
for (const listing of listings) {
assert.match(listing, /target:\s*\{\s*\$ne:\s*['"]item['"]\s*\}/, `${route} leaks item folders: ${listing}`);
}
const filtered = source.match(/Folder\.find\(\{[^{]*Folder\.filterForTarget\((?:'note'|target)\)/g) ?? [];
assert.equal(filtered.length, listings.length, `${route} has a folder listing that names no campaign list`);
}
});
@@ -582,9 +584,9 @@ test("an item whose folder is gone, or a folder nested in itself, reads as a roo
assert.equal(rows.filter(([kind]) => kind === "folder").length, 2, "a broken tree is walked once, not forever");
});
test("every locale labels the item folder row", () => {
test("every locale labels the folder row", () => {
for (const locale of ["en", "es", "ca"]) {
const campaigns = JSON.parse(read("frontend", "i18n", "locales", locale, "campaigns.json"));
assert.ok(campaigns.item?.["folder-toggle"], `${locale} is missing campaigns.item.folder-toggle`);
assert.ok(campaigns.folders?.["toggle"], `${locale} is missing campaigns.folders.toggle`);
}
});