drawings: VISUAL's rev is the source of truth; attach it when M-Files holds it Effective or Retired
When M-Files' Effective rev differs from the rev VISUAL calls, the drawing job looks that rev up (MFilesKit DrawingLookup.revision). If M-Files has it as Effective or Retired, the job copies it into drawing_revisions and attaches it to the draft with no flag and no Clerical approval, so the draft can auto-release. Past draft, already attached or with a hand drawing: unchanged, no flag and no change order. Any other status, or no document at that rev, still flags rev_mismatch with a note saying why. Packet Station only ever attaches Effective or Retired drawings. rev_approve stays for that case only. This replaces the "Use rev V as VISUAL calls it" choice from #46: the use=called path in rev-approve and its button are removed. A packet that already kept the rev that way keeps it, since that rev is now used anyway. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -116,29 +116,31 @@ describe("Packet page, VISUAL box", () => {
|
||||
expect(await screen.findByText("Rev 3 approved and attached.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("offers the retired rev VISUAL calls next to the latest, and keeps it with use=called", async () => {
|
||||
const called = { rev: "2", controlled: "Retired", state: "Superseded", name: "M00543 r2.pdf", asset_id: "as-r2", pages: 1 };
|
||||
const draft = visualDraft({ visual: { ...visualDraft().visual, staged_rev: { rev: 3, name: "M00543 r3.pdf", asset_id: "as-r3" }, called } });
|
||||
const kept = visualDraft({
|
||||
version: 4,
|
||||
it("says when the rev VISUAL calls is attached although M-Files has retired it", async () => {
|
||||
const page = { n: 1, type: "drawing", asset_id: "as-r2", pn: 1, dwg: "M00543", rev: "2", void: null, url: "/_blob/as-r2" };
|
||||
const attached = visualDraft({
|
||||
flags: [],
|
||||
flag: null,
|
||||
drawing_state: "attached",
|
||||
visual: { rev_ok: { rev: "2", vis_rev: "2", use: "called", latest: "3", controlled: "Retired", reason: "Lot 1 builds to rev 2" } },
|
||||
pages: [page] as unknown as PacketRead["pages"],
|
||||
visual: {
|
||||
appr: { ok: true, rev: 3, vrev: "2", name: "M00543 r3.pdf", note: "" },
|
||||
vault: { asset_id: "as-r2", name: "M00543 r2.pdf", rev: 2, controlled: "Retired" },
|
||||
},
|
||||
});
|
||||
const fetch = mockFetch({ ...base(draft, LEO), "POST /api/packets/1/rev-approve": { body: kept } });
|
||||
mockFetch({ ...base(attached, LEO) });
|
||||
renderApp("/packets/1");
|
||||
expect(await screen.findByRole("button", { name: "Use latest rev 3" })).toBeInTheDocument();
|
||||
expect(screen.getByText(/retired \(Superseded\) in M-Files/)).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Use rev 2 as VISUAL calls it" }));
|
||||
const ask = await screen.findByRole("dialog", { name: "Use rev 2 for M00543" });
|
||||
fireEvent.change(within(ask).getByLabelText("Reason"), { target: { value: "Lot 1 builds to rev 2" } });
|
||||
fireEvent.click(within(ask).getByRole("button", { name: "Use rev 2" }));
|
||||
await sign();
|
||||
expect(callsTo(fetch, "POST", "/api/packets/1/rev-approve")).toEqual([
|
||||
{ reason: "Lot 1 builds to rev 2", use: "called", sign: { factor: "password", secret: "pw-1" } },
|
||||
]);
|
||||
expect(await screen.findByText("Rev 2 attached as VISUAL calls it.")).toBeInTheDocument();
|
||||
expect(await screen.findByText("Rev 2 attached as VISUAL calls it")).toBeInTheDocument();
|
||||
expect(screen.getByText(/retired in M-Files, which has rev 3 as Effective/)).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: /Approve rev/ })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("explains why the rev VISUAL calls is not attached when its status is not Effective or Retired", async () => {
|
||||
const draft = visualDraft({ visual: { ...visualDraft().visual, called: { rev: "2", controlled: "Obsolete", refused: true } } });
|
||||
mockFetch({ ...base(draft, LEO) });
|
||||
renderApp("/packets/1");
|
||||
expect(await screen.findByText(/VISUAL calls rev 2, which is obsolete in M-Files/)).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Approve rev 3 for this packet" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("uploads a hand BOM as multipart with the signature fields", async () => {
|
||||
|
||||
Reference in New Issue
Block a user