Toggle tasks and edit view settings via htmx

Task checkboxes post themselves (hx-post="?toggle=N") and flip back when
the save fails, replacing tasks.js. View settings are a server-rendered
form dialog with real radios and a select, replacing view-settings.js;
with that, postReplace has no callers left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 16:41:59 +02:00
co-authored by Claude Opus 5.5
parent 3a3fb3b51f
commit 353df29ee6
12 changed files with 93 additions and 162 deletions
+28 -1
View File
@@ -47,14 +47,41 @@ test("task checkbox toggle persists", async ({ page }) => {
await expect(page.locator("main input.task-checkbox").first()).toBeChecked();
});
test("unchecking a task persists", async ({ page }) => {
await page.goto("/Projects/");
const box = page.locator("main input.task-checkbox").nth(1);
await expect(box).toBeChecked();
await box.uncheck();
await expect(box).toBeEnabled();
await expect.poll(() => readFileSync(join(wiki, "Projects", "index.md"), "utf8")).toContain("- [ ] second task");
});
test("a failed task save reverts the checkbox", async ({ page }) => {
page.on("dialog", (d) => d.dismiss());
await page.route("**/?toggle=*", (route) => route.fulfill({ status: 500, body: "boom" }));
await page.goto("/Projects/");
const box = page.locator("main input.task-checkbox").nth(1);
const before = await box.isChecked();
await box.click();
await expect(box).toBeEnabled();
await expect(box).toBeChecked({ checked: before });
});
test("view settings switch the listing to thumbnails", async ({ page }) => {
await page.goto("/Projects/");
await expect(page.locator("main table.data-table")).toBeVisible();
await page.getByTitle("View & sorting").click();
await modal(page).getByRole("button", { name: "Thumbnail" }).click();
await modal(page).getByText("Thumbnail").click();
await modal(page).getByLabel("Sort by").selectOption("size");
await modal(page).getByText("Desc").click();
await modal(page).getByRole("button", { name: "SAVE" }).click();
await expect(page.locator("main .thumb-grid")).toBeVisible();
await expect(page).toHaveURL(/\/Projects\/$/);
// Reopening shows the saved state.
await page.getByTitle("View & sorting").click();
await expect(modal(page).getByLabel("Thumbnail")).toBeChecked();
await expect(modal(page).getByLabel("Sort by")).toHaveValue("size");
await expect(modal(page).getByLabel("Desc")).toBeChecked();
});
test("editor saves a page", async ({ page }) => {