fix: reject snapshot when template already attached (409); handle domains-load error; drop orphaned useDeleteDomain

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-05 12:54:52 +07:00
parent 137113cbe6
commit 9f0938daea
5 changed files with 80 additions and 17 deletions
+17 -2
View File
@@ -19,8 +19,7 @@ const domainWithTemplate: Domain = {
lastCheckStatus: "drift",
}
function renderPage() {
const qc = new QueryClient()
function renderPage(qc: QueryClient = new QueryClient()) {
return render(
<QueryClientProvider client={qc}>
<AuthProvider>
@@ -111,6 +110,22 @@ test("домен без шаблона показывает записи зон
expect(checkSpy).not.toHaveBeenCalled()
})
test("ошибка загрузки списка доменов показывает баннер ошибки и не уходит в ветку без шаблона", async () => {
vi.spyOn(api, "listDomains").mockRejectedValue(new Error("network down"))
const checkSpy = vi.spyOn(api, "checkDomain")
const zoneRecordsSpy = vi.spyOn(api, "zoneRecords")
// retry:false — иначе react-query переретраит listDomains с экспоненциальной
// задержкой и findByText не успевает дождаться финального isError.
renderPage(new QueryClient({ defaultOptions: { queries: { retry: false } } }))
expect(await screen.findByText(/не удалось загрузить список доменов/i)).toBeInTheDocument()
expect(screen.getByText("network down")).toBeInTheDocument()
expect(screen.queryByText(/шаблон не привязан/i)).not.toBeInTheDocument()
expect(checkSpy).not.toHaveBeenCalled()
expect(zoneRecordsSpy).not.toHaveBeenCalled()
})
test("создание шаблона из зоны вызывает templateFromZone", async () => {
vi.spyOn(api, "listDomains").mockResolvedValue([
{ id: "d1", providerAccountId: "acc1", zoneName: "example.com.", zoneId: "z1", templateId: null },