test(dashboard): migrate standalone mode Cypress spec to RTL#40914
test(dashboard): migrate standalone mode Cypress spec to RTL#40914sadpandajoe wants to merge 3 commits into
Conversation
Replaces the standalone-mode assertion from the deleted Cypress spec `cypress-base/cypress/e2e/dashboard/_skip.load.test.ts` (removed in #40384) with a component-level RTL test in DashboardBuilder.test.tsx. The React-side contract is `?standalone=2` (HideNavAndTitle) suppressing `<DashboardHeader />`; the original Flask-template `#app-menu` selector is out of RTL's reach. Other assertions in the deleted spec are already covered by existing unit tests (extractUrlParams, Header, logger). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40914 +/- ##
=======================================
Coverage 64.14% 64.14%
=======================================
Files 2653 2653
Lines 143525 143525
Branches 33120 33120
=======================================
Hits 92063 92063
Misses 49851 49851
Partials 1611 1611
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Migrates the dashboard standalone-mode assertion from a removed Cypress _skip E2E spec into a React Testing Library component test, ensuring the React-side “standalone hides header” contract remains covered as part of the Cypress → RTL/Playwright migration effort.
Changes:
- Add an RTL test verifying
?standalone=2(HideNavAndTitle) suppresses theDashboardHeaderinDashboardBuilder.
|
The suggestion to capture and restore the full const originalHref = window.location.href;
// ... test logic ...
window.history.replaceState({}, '', originalHref);superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx |
Save window.location.href instead of just window.location.search so the finally block restores the original pathname and hash too, not just the query string. Prevents state leakage if the Jest base URL ever moves off the root path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the React-side analogue of the legacy `?edit=true&standalone=true` Cypress mount, asserting the two URL params remain orthogonal: standalone=2 hides DashboardHeader while editMode still drives the `dashboard--editing` wrapper class. Satisfies sc-107447 task 3. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SUMMARY
Migrates the dashboard standalone-mode scenario from the deleted Cypress spec
cypress-base/cypress/e2e/dashboard/_skip.load.test.ts(removed in #40384) to a component-level RTL test inDashboardBuilder.test.tsx. Part of the Cypress→Playwright/RTL migration epic.The original Cypress spec opened
?edit=true&standalone=trueand asserted three things. Two are already covered by existing unit tests; the new RTL test covers the third:?edit=true→discard-changes-buttonvisibleextractUrlParams.test.ts; state→DOM inHeader.test.tsx(should render the "Discard changes" buttonundereditMode: true).?standalone=true→#app-menunot in DOM#app-menulives in Flask'sspa.htmland is gated server-side by{% if standalone_mode %}— out of RTL's reach. The React-side equivalent is?standalone=2(DashboardStandaloneMode.HideNavAndTitle), which makesDashboardBuildersuppress<DashboardHeader />. Net-new RTL test added.logger.test.ts(should POST an event to /superset/log/ when called).The literal
?standalone=trueparses to1(HideNav), which only hides the Flask-rendered app menu. Usingstandalone=2documents the closest React-level contract and is called out in the test's comment.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — test-only change.
TESTING INSTRUCTIONS
```bash
cd superset-frontend
npm run test -- src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
```
All 25 tests should pass, including the new one:
ADDITIONAL INFORMATION