Build Seth's changes C1 to C11 (Gitea issues 1, 8, 18, 23, 24, 25, 27, 31, 32, 33, 36)
ci / frontend (pull_request) Successful in 57s
ci / server (pull_request) Successful in 12m33s
ci / image (pull_request) Skipped
ci / e2e (pull_request) Successful in 5m4s

- C1 (issue 1): over target follows VISUAL ticket hours, not the timer.
- C2 (issue 24): a Q.C. reject always needs a reason; accept needs an NCR number after a reject without one.
- C3 (issue 25): an incomplete unit ITP blocks filing.
- C4 (issue 27): prints open the print dialog on the page, no new tab.
- C5 (issue 31): filing is blocked while VISUAL shows a work order open; the feed sets vclosed on VISUAL packets.
- C6 (issue 8): the data book leaves out the history pages.
- C7 (issue 18): the supervisor approves each received short; accept and filing wait for it.
- C8 (issue 23): per-department checklists, edited by the department supervisor or Admin, frozen at START.
- C9 (issue 32): Q.C. and Clerical may run the stamp check.
- C10 (issue 33): the PM screen and reports are for PS-ProjectMgmt and Admin only.
- C11 (issue 36): the Stall screen lists the packets assigned to the welder, at the supervisor's stall.

Migration 0011. Docs: PLAN (also issue 9 confirmed, issue 4 asked), POLICY, SECURITY, SCHEMA, FEED, README, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-30 13:33:51 -06:00
co-authored by Claude Opus 5.5
parent 1ae6819289
commit 1cd6688247
101 changed files with 3871 additions and 1098 deletions
@@ -1,94 +1,35 @@
import { fireEvent, screen, waitFor } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { fireEvent, screen, waitFor, within } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { adminBase } from "../../test/admin";
import { renderApp } from "../../test/auth";
import { callsTo, mockFetch } from "../../test/fetchMock";
import { memoryStorage } from "../supervisor/memoryStorage";
const VALUE = {
weld: [
{ group: "Before welding", key: "dwg", text: "Drawing {drawing} Rev {rev} matches the packet" },
{ group: "Before welding", key: "wps", text: "WPS reviewed: {wps}" },
{ group: "After welding", key: "vt", text: "Visual inspection of all welds acceptable" },
],
plain: [{ group: "Before starting", key: "dwg", text: "Drawing {drawing} Rev {rev} matches the packet" }],
};
const DEFAULTS = { weld: VALUE.weld.slice(0, 2), plain: VALUE.plain };
const ITEMS = [{ group: "Before welding", key: "dwg", text: "Drawing {drawing} Rev {rev} matches the packet" }];
async function openTab() {
renderApp("/admin");
fireEvent.click(await screen.findByRole("tab", { name: "Checklists" }));
return screen.findByLabelText("Weld item 1 text");
}
beforeEach(() => {
vi.stubGlobal("localStorage", memoryStorage());
});
describe("Admin Checklists tab", () => {
it("edits, adds, reorders and removes items, checks them, and saves with the version", async () => {
it("shows the department editor on the new endpoints and links the Checklists screen", async () => {
const fetch = mockFetch({
...adminBase(),
"GET /api/admin/checklists": { body: { value: VALUE, defaults: DEFAULTS, version: 4 } },
"PUT /api/admin/checklists": { body: { value: VALUE, defaults: DEFAULTS, version: 5 } },
});
await openTab();
expect(screen.getByLabelText("Weld item 1 key")).toHaveAttribute("readonly");
expect(screen.getByLabelText("Plain item 1 group")).toHaveValue("Before starting");
fireEvent.change(screen.getByLabelText("Weld item 3 text"), { target: { value: "Visual check of every weld" } });
fireEvent.click(screen.getByRole("button", { name: "Move weld item 3 up" }));
fireEvent.click(screen.getByRole("button", { name: "Remove weld item 1" }));
fireEvent.click(screen.getByRole("button", { name: "Add weld item" }));
const key = screen.getByLabelText("Weld item 3 key");
expect(key).not.toHaveAttribute("readonly");
fireEvent.change(key, { target: { value: "Clean" } });
fireEvent.change(screen.getByLabelText("Weld item 3 text"), { target: { value: "Slag removed near {part}" } });
fireEvent.click(screen.getByRole("button", { name: "Save checklists" }));
expect(await screen.findByRole("alert")).toHaveTextContent("Weld list, item 3: the key is lower case");
fireEvent.change(key, { target: { value: "clean" } });
fireEvent.click(screen.getByRole("button", { name: "Save checklists" }));
expect(await screen.findByRole("alert")).toHaveTextContent("only {drawing}, {rev} and {wps}");
fireEvent.change(screen.getByLabelText("Weld item 3 text"), { target: { value: "Slag removed" } });
fireEvent.click(screen.getByRole("button", { name: "Save checklists" }));
expect(await screen.findByText(/Checklists saved/)).toBeInTheDocument();
expect(callsTo(fetch, "PUT", "/api/admin/checklists")).toEqual([
{
version: 4,
value: {
weld: [
{ group: "After welding", key: "vt", text: "Visual check of every weld" },
{ group: "Before welding", key: "wps", text: "WPS reviewed: {wps}" },
{ group: "Before welding", key: "clean", text: "Slag removed" },
],
plain: VALUE.plain,
},
"GET /api/checklists": {
body: [
{ dept_code: "03", dept_name: "Weld Parts", weld: true, custom: false, version: 0, editable: true },
{ dept_code: "14", dept_name: "Electrical", weld: false, custom: true, version: 2, editable: true },
],
},
]);
});
it("loads the other version after a 409", async () => {
let gets = 0;
const fetch = mockFetch({
...adminBase(),
"GET /api/admin/checklists": () => {
gets += 1;
return { body: { value: gets > 1 ? { ...VALUE, plain: [{ ...VALUE.plain[0], text: "Changed by Bob" }] } : VALUE, defaults: DEFAULTS, version: 3 + gets } };
"GET /api/checklists/03": {
body: { dept_code: "03", dept_name: "Weld Parts", weld: true, custom: false, version: 0, editable: true, items: ITEMS, defaults: ITEMS },
},
"PUT /api/admin/checklists": { status: 409, body: { detail: "Changed by someone else", code: "version_conflict" } },
});
await openTab();
fireEvent.change(screen.getByLabelText("Plain item 1 text"), { target: { value: "Mine" } });
fireEvent.click(screen.getByRole("button", { name: "Save checklists" }));
expect(await screen.findByRole("alert")).toHaveTextContent("Someone else saved the checklists first.");
await waitFor(() => expect(screen.getByLabelText("Plain item 1 text")).toHaveValue("Changed by Bob"));
expect(callsTo(fetch, "GET", "/api/admin/checklists")).toHaveLength(2);
});
it("copies the default list in", async () => {
mockFetch({ ...adminBase(), "GET /api/admin/checklists": { body: { value: VALUE, defaults: DEFAULTS, version: 1 } } });
await openTab();
expect(screen.getByLabelText("Weld item 3 text")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Use the default weld list" }));
expect(screen.queryByLabelText("Weld item 3 text")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Discard changes" }));
expect(screen.getByLabelText("Weld item 3 text")).toBeInTheDocument();
renderApp("/admin");
fireEvent.click(await screen.findByRole("tab", { name: "Checklists" }));
expect(await screen.findByLabelText("Item 1 text")).toHaveValue(ITEMS[0]?.text);
expect(within(screen.getByRole("main")).getByRole("link", { name: "Checklists" })).toHaveAttribute("href", "/checklists");
expect(screen.getByRole("combobox", { name: "Department" })).toHaveValue("03");
await waitFor(() => expect(callsTo(fetch, "GET", "/api/admin/checklists")).toHaveLength(0));
});
});