fix(ui): восстанавливать задачу выпуска без повторной операции

This commit is contained in:
Denozordec committed 2026-10-01 14:29:56 +07:00
1 parent 97526bf06f
commit f5a71728ac
10 files changed
+322 -81

No files matched your search

+29 -1
View File
@@ -1,6 +1,7 @@
import {test,expect} from "@playwright/test"
import {certificate as container,server,certificateState as state} from "./fixtures/certificates"
const headers={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,OPTIONS","access-control-allow-headers":"Content-Type,Authorization"}
import {openIssue,issueJob} from "./fixtures/certificate-issue"
const headers={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,PUT,OPTIONS","access-control-allow-headers":"Content-Type,Authorization"}
for(const change of ["backend","mode"])for(const fails of [false,true])test("Сертификаты: позднее чтение/"+change+"/"+fails,async({page})=>{
let started=false,completed=false,release!:()=>void;const gate=new Promise<void>(r=>release=r)
await page.route("**/health",r=>r.fulfill({headers,json:{ok:true}}));await page.route("**/api/**",r=>{const p=new URL(r.request().url()).pathname;return r.fulfill({headers,json:p==="/api/auth/config"?{required:false}:p==="/api/servers"?[server]:p==="/api/certificates/state"?state():{directoryUrl:"https://acme.example.test/directory",tokenConfigured:false,enabled:false,intervalSec:300,renewBeforeDays:30}})})
@@ -51,3 +52,30 @@ for (const fails of [false, true]) test("Сертификаты: позднее
await expect(directory).toHaveValue("https://acme.example.test/directory"); await expect(page.getByText("СТАРОЕ СОХРАНЕНИЕ ACME ОТКАЗ", { exact: true })).toHaveCount(0)
await expect(page.getByText("Настройки ACME сохранены", { exact: true })).toHaveCount(0)
})
for (const change of ["backend", "mode"]) for (const stage of ["POST", "poll"]) for (const fails of [false, true]) test("Сертификаты: поздний выпуск/" + change + "/" + stage + "/" + fails, async ({ page }) => {
let request: Record<string, unknown> = {}, started = false, completed = false, release!: () => void; const gate = new Promise<void>(r => release = r)
await page.route("**/health", r => r.fulfill({ headers, json: { ok: true } }))
await page.route("**/api/**", r => {
const path = new URL(r.request().url()).pathname
return r.fulfill({ headers, json: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? [server] : path === "/api/certificates/state" ? state() : path === "/api/certificates/renew-settings" ? { enabled: true, intervalSec: 21600, renewBeforeDays: 30 } : { directoryUrl: "https://acme.example.test/directory", tokenConfigured: true } })
})
await page.route("**/api/certificates/issue", async r => {
request = r.request().postDataJSON()
if (stage !== "POST") return r.fulfill({ headers, json: { jobId: request.requestId } })
started = true; await gate
try { await r.fulfill(fails ? { headers, status: 503, json: { error: "СТАРЫЙ ВЫПУСК ОТКАЗ" } } : { headers, json: { jobId: request.requestId } }) } catch {} finally { completed = true }
})
await page.route("**/api/certificates/issue/*", async r => {
if (stage !== "poll") return r.fulfill({ headers, json: issueJob(request) })
started = true; await gate
try { await r.fulfill(fails ? { headers, status: 503, json: { error: "СТАРЫЙ ВЫПУСК ОТКАЗ" } } : { headers, json: issueJob(request) }) } catch {} finally { completed = true }
})
const dialog = await openIssue(page); await dialog.getByRole("button", { name: "Выпустить", exact: true }).click(); await expect.poll(() => started).toBe(true)
await page.goto("/settings")
if (change === "backend") { const input = page.getByPlaceholder("http://localhost:8000"); await input.fill("http://localhost:8101"); await input.press("Enter") } else await page.getByRole("button", { name: "Моковые", exact: true }).click()
await page.goto("/certificates"); release(); await expect.poll(() => completed).toBe(true)
await expect(page.getByRole("button", { name: "Задача выпуска", exact: true })).toHaveCount(0)
await expect(page.getByText("API подтвердил завершение задачи выпуска", { exact: true })).toHaveCount(0)
await expect(page.getByText(/СТАРЫЙ ВЫПУСК ОТКАЗ/)).toHaveCount(0)
})