fix(web): gate zone-records fetch to no-template case; wait for domains load before branching

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-05 12:28:07 +07:00
parent c2832348f8
commit 137113cbe6
3 changed files with 44 additions and 3 deletions
+27
View File
@@ -49,6 +49,7 @@ test("apply sends applyPrunes=false by default, true only after opting in", asyn
readOnly: [], inSyncCount: 0,
})
const applySpy = vi.spyOn(api, "applyDomain").mockResolvedValue({ updates: [], prunes: [], readOnly: [], inSyncCount: 0 })
const zoneRecordsSpy = vi.spyOn(api, "zoneRecords")
const user = userEvent.setup()
renderPage()
@@ -63,6 +64,32 @@ test("apply sends applyPrunes=false by default, true only after opting in", asyn
await user.click(screen.getByRole("button", { name: /apply/i }))
await waitFor(() => expect(applySpy).toHaveBeenCalledTimes(2))
expect(applySpy.mock.calls[1]).toEqual([PROJECT_ID, "d1", { applyUpdates: true, applyPrunes: true }])
// домен с шаблоном: записи зоны не нужны для диффа — запрос не должен уходить к провайдеру
expect(zoneRecordsSpy).not.toHaveBeenCalled()
})
test("пока список доменов грузится — показан общий лоадер, а не баннер об отсутствии шаблона", async () => {
let resolveListDomains: (domains: Domain[]) => void
vi.spyOn(api, "listDomains").mockReturnValue(
new Promise((resolve) => {
resolveListDomains = resolve
}),
)
const checkSpy = vi.spyOn(api, "checkDomain").mockResolvedValue({
updates: [], prunes: [], readOnly: [], inSyncCount: 0,
})
const zoneRecordsSpy = vi.spyOn(api, "zoneRecords")
renderPage()
expect(await screen.findByText(/загрузка/i)).toBeInTheDocument()
expect(screen.queryByText(/шаблон не привязан/i)).not.toBeInTheDocument()
expect(checkSpy).not.toHaveBeenCalled()
expect(zoneRecordsSpy).not.toHaveBeenCalled()
resolveListDomains!([domainWithTemplate])
expect(await screen.findByRole("button", { name: /apply/i })).toBeInTheDocument()
})
test("домен без шаблона показывает записи зоны и не вызывает check", async () => {