commit compras4 2711
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-27 19:13:31 +02:00
parent 9cf9764710
commit 7486007fcf
41 changed files with 1270 additions and 66 deletions
@@ -0,0 +1,85 @@
import { App } from "@inertiajs/react";
import { renderToStaticMarkup } from "react-dom/server";
import { expect, test } from "vitest";
import Expiry from "../../resources/js/pages/requisitions/expiry";
function render(extra: object) {
return renderToStaticMarkup(
<App
initialComponent={Expiry}
initialPage={{
component: "requisitions/expiry",
url: "/requisicoes/1/prazos",
version: null,
clearHistory: false,
encryptHistory: true,
props: {
errors: {},
requisition: {
id: 1,
number: "REQ-QA",
status: "draft",
process_version: 4,
approval_cycle: 2,
},
deadline: {
state: "inactive",
step_id: null,
expires_at: null,
basis_hash: null,
},
canExpire: false,
canCheck: false,
canEdit: true,
actorId: 1,
tenantId: 1,
history: {
data: [
{
id: 1,
data: { cycle: 1, next_cycle: 2 },
reason: "<script>synthetic</script>",
request: { number: "REQ-QA" },
steps: [
{
id: 1,
position: 1,
role: "department_head",
decision: "approved",
},
],
},
],
prev_page_url: null,
next_page_url: null,
},
...extra,
},
}}
/>,
);
}
test("returned owner sees the same draft and preserved approval without expiry controls", () => {
const html = render({});
expect(html).toContain("/requisicoes/1/editar");
expect(html).toContain("Aprovação preservada");
expect(html).toContain("&lt;script&gt;synthetic&lt;/script&gt;");
expect(html).not.toContain("<form");
});
test("a pending configured deadline exposes due actions only when allowed", () => {
const html = render({
canEdit: false,
canCheck: true,
deadline: {
state: "running",
step_id: 2,
expires_at: "2026-11-27T12:30:00Z",
basis_hash: "a".repeat(64),
},
});
expect(html).toContain("Verificar e executar acções devidas");
expect(html).not.toContain("Rever rascunho");
expect(html).not.toContain("Devolver ao requisitante</button>");
});