]*>Versions<\/caption>/)
expect(html).toMatch(/| ]*scope="row"[^>]*>1<\/th> | ]*>application\/pdf<\/td> | ]*>1234<\/td>/)
expect(html).toContain("Add a version")
expectLabelled(html, 1)
expect(html).toContain("Place a legal hold")
expect(html).toContain("Dispose")
const editor = await render(["doc_1"], documentAnswers, EDITOR)
expect(editor).toContain("Add a version")
expect(editor).not.toContain("Place a legal hold")
const viewer = await render(["doc_1"], documentAnswers, VIEWER)
expect(viewer).not.toContain("Add a version")
})
it("offers nothing on a disposed document", async () => {
const disposed = { ...document, status: "disposed", disposed: true, disposedAt: "2026-12-01T10:00:00.000Z" }
const html = await render(["doc_1"], { "archive.document.get": { document: disposed, versions: [version] } })
expect(html).toContain("Disposed")
expect(html).not.toContain("Add a version")
expect(html).not.toContain("Place a legal hold")
})
it("lists the retention classes and what is due, with the form for an administrator", async () => {
const html = await render(["retention"], retentionAnswers)
expect(html).toMatch(/]*>Retention<\/h1>/)
expect(html).toMatch(
/| ]*scope="row"[^>]*>contracts<\/th> | ]*>P10Y<\/td> | ]*>When the document is registered<\/td>/,
)
expect(html).toMatch(/]*>Disposal due<\/caption>/)
expect(html).toContain("New retention class")
expectLabelled(html, 3)
expect(html.match(/data-slot="field-description"/g)).toHaveLength(1)
expect(await render(["retention"], retentionAnswers, EDITOR)).not.toContain("New retention class")
})
it.each([
["service_not_enabled", "This service is not enabled for your organization."],
["service_permission_missing", "This app is not allowed to use this service. Ask an administrator to grant it."],
["business_unavailable", "The service did not answer. Try again later."],
])("shows the typed state %s", async (code, text) => {
const refused = new AppError({ type: `/problems/${code}`, title: "Refused", status: 503, code, detail: "why" })
const html = await render([], { ...listAnswers, "archive.document.list": refused })
expect(html).toContain(`data-state="${code}"`)
expect(html).toContain('role="status"')
expect(html).toContain(text)
expect(html).not.toContain(" {
const code = "service_not_enabled"
const refused = new AppError({ type: `/problems/${code}`, title: "Refused", status: 404, code })
const data = await archivePage.load({
slugs,
segments: [],
search: {},
caller: callerOf({ ...listAnswers, "archive.document.list": refused }),
i18n: lithuanian,
container: new Container(),
})
expect(data).toMatchObject({
kind: "state",
notice: { code, text: "Ši paslauga jūsų organizacijai neįjungta." },
})
})
it("leaves a document that is not there, and a path it does not have, to the shell", async () => {
const missing = new AppError({ type: "/problems/not_found", title: "Not found", status: 404, code: "not_found" })
await expect(render(["doc_2"], { "archive.document.get": missing })).rejects.toMatchObject({
problem: { code: "not_found" },
})
await expect(render(["doc_1", "x"], {})).rejects.toMatchObject({ problem: { status: 404 } })
await expect(render(["retention", "x"], {})).rejects.toMatchObject({ problem: { status: 404 } })
await expect(render(["%2Fetc"], {})).rejects.toMatchObject({ problem: { status: 404 } })
await expect(render(["%E0%A4%A"], {})).rejects.toMatchObject({ problem: { status: 404 } })
})
it("is listed for the shell", async () => {
await expect(modulePages.archive?.()).resolves.toBe(archivePage)
})
})
// Explicit synthetic admission: module-local fixtures exercise the selected module.
vi.mock("../../inclusion.json", () => ({
default: { schemaVersion: 1, selected: ["archive"], everAdopted: ["archive"] },
}))
| |