From a4f275913c0e9f2a00a0770879a2a7cb928fed58 Mon Sep 17 00:00:00 2001 From: Joe Li Date: Mon, 23 Feb 2026 12:04:18 -0800 Subject: [PATCH] fix(alerts): replace stale-anchor UI check with payload-level assertion Trigger save after stale anchor is processed and inspect the PUT request body to verify extra.dashboard.anchor is undefined. This directly asserts the component state through its API boundary rather than checking DOM elements or i18n-dependent UI copy. Co-Authored-By: Claude Opus 4.6 --- .../features/alerts/AlertReportModal.test.tsx | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx index 8566a5b54c8..9827807ffde 100644 --- a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx +++ b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx @@ -1222,12 +1222,29 @@ test('stale JSON array anchor is cleared without crash or toast', async () => { ), ).toBe(false); - // Verify anchor was cleared: the stale anchor value should not appear - // as a selected item anywhere (antd TreeSelect sets title={value} on - // selection items; absent title means updateAnchorState(undefined) ran) + // Verify anchor was cleared at the payload level: trigger save and + // inspect the PUT body to confirm extra.dashboard.anchor is undefined + const updateEndpoint = 'glob:*/api/v1/report/1'; + fetchMock.put(updateEndpoint, { id: 1, result: {} }, { name: 'put-report-1' }); + + const saveButton = screen.getByRole('button', { name: /save/i }); + expect(saveButton).not.toBeDisabled(); + userEvent.click(saveButton); + await waitFor(() => { - expect(screen.queryByTitle(staleAnchor)).not.toBeInTheDocument(); + const putCalls = fetchMock.callHistory + .calls() + .filter(c => c.url.includes('/api/v1/report/') && c.options?.method === 'put'); + expect(putCalls).toHaveLength(1); }); + + const putCall = fetchMock.callHistory + .calls() + .find(c => c.url.includes('/api/v1/report/') && c.options?.method === 'put'); + const body = JSON.parse(putCall!.options?.body as string); + expect(body.extra.dashboard.anchor).toBeUndefined(); + + fetchMock.removeRoute('put-report-1'); } finally { restoreAnchorMocks(); }