docs: custom records and import-as-sync invariants

Document the two Task 1-9 features in CLAUDE.md invariants and README
features. Also closes two review gaps: a Go test proving importResponse
marshals created/removed as [] (never null) on a no-op import, and a
frontend test-race fix in DomainsPage.test.tsx where the import button
was clicked before its disabled state cleared.
This commit is contained in:
2026-08-19 18:45:52 +07:00
parent d6d91f8826
commit 58a57ff4d0
4 changed files with 40 additions and 0 deletions
+29
View File
@@ -531,6 +531,35 @@ func TestImportZones_BadAccountUUID(t *testing.T) {
}
}
// TestImportResponseEmptyMarshalsToArrays guards the same белый-экран class
// of bug as TestChangesetResponseEmptyMarshalsToArrays (api_test.go), but for
// the import endpoint: a sync that created and removed nothing (empty zone
// list from the provider) must still marshal created/removed as [], not
// null — the frontend's .length/.map calls on the response would otherwise
// crash right after a no-op import.
func TestImportResponseEmptyMarshalsToArrays(t *testing.T) {
a, ts := newTenantTestAPI()
accID := uuid.New()
ts.accounts = []store.Account{{ID: accID, Provider: "selectel", SecretEnc: "ENC(token)"}}
a.Reg = &mockRegistry{zones: nil}
router := NewRouter(a)
req := requestWithSessionCookie(http.MethodPost, "/api/v1/projects/"+testPID+"/accounts/"+accID.String()+"/import", nil)
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
if w.Code != http.StatusCreated {
t.Fatalf("status %d body %s", w.Code, w.Body.String())
}
body := w.Body.String()
if !strings.Contains(body, `"created":[]`) {
t.Fatalf("expected \"created\":[] in %s", body)
}
if !strings.Contains(body, `"removed":[]`) {
t.Fatalf("expected \"removed\":[] in %s", body)
}
}
func TestCreateDomain_BadProjectUUID(t *testing.T) {
a, _ := newTenantTestAPI()
router := NewRouter(a)