This is an automated email from the ASF dual-hosted git repository.
jli pushed a commit to branch fix-alert-report-tab-error
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/fix-alert-report-tab-error by
this push:
new fe993013133 fix(alerts): restore mock symmetry and replace brittle
test selectors
fe993013133 is described below
commit fe993013133395cca9ea3fd2e51e04b8b0785eae
Author: Joe Li <[email protected]>
AuthorDate: Thu Feb 19 22:39:45 2026 -0800
fix(alerts): restore mock symmetry and replace brittle test selectors
Add FETCH_CHART_ENDPOINT restore to restoreAnchorMocks for setup/teardown
symmetry. Replace .ant-tree-select and .rc-virtual-list class selectors
with RTL-native queries (queryByTitle, findByRole). Replace i18n-copy-
dependent placeholder assertion with structural title-absence check.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
.../src/features/alerts/AlertReportModal.test.tsx | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
index 3fee7eecd34..73423dec7f2 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.test.tsx
@@ -854,6 +854,12 @@ const restoreAnchorMocks = () => {
{ result: generateMockPayload(true) },
{ name: FETCH_DASHBOARD_ENDPOINT },
);
+ fetchMock.removeRoute(FETCH_CHART_ENDPOINT);
+ fetchMock.get(
+ FETCH_CHART_ENDPOINT,
+ { result: generateMockPayload(false) },
+ { name: FETCH_CHART_ENDPOINT },
+ );
fetchMock.removeRoute(tabsEndpoint);
fetchMock.get(
tabsEndpoint,
@@ -987,14 +993,11 @@ test('stale JSON array anchor is cleared without crash or
toast', async () => {
),
).toBe(false);
- // Verify anchor was cleared: TreeSelect shows placeholder (only visible
- // when value is undefined, i.e. updateAnchorState(undefined) was called)
+ // 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)
await waitFor(() => {
- const treeSelect = document.querySelector('.ant-tree-select');
- expect(treeSelect).toBeInTheDocument();
- expect(
- within(treeSelect as HTMLElement).getByText('Select a tab'),
- ).toBeInTheDocument();
+ expect(screen.queryByTitle(staleAnchor)).not.toBeInTheDocument();
});
} finally {
restoreAnchorMocks();
@@ -1197,9 +1200,8 @@ test('anchor tab with scoped filters loads filter options
correctly', async () =
});
userEvent.click(filterDropdown);
- const filterOption = await waitFor(() => {
- const virtualList = document.querySelector('.rc-virtual-list');
- return within(virtualList as HTMLElement).getByText('Tab Scoped Filter');
+ const filterOption = await screen.findByRole('option', {
+ name: /Tab Scoped Filter/,
});
expect(filterOption).toBeInTheDocument();