Skip to content

test(dashboard): migrate standalone mode Cypress spec to RTL#40914

Draft
sadpandajoe wants to merge 3 commits into
masterfrom
dashboard-load-rtl
Draft

test(dashboard): migrate standalone mode Cypress spec to RTL#40914
sadpandajoe wants to merge 3 commits into
masterfrom
dashboard-load-rtl

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

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 in DashboardBuilder.test.tsx. Part of the Cypress→Playwright/RTL migration epic.

The original Cypress spec opened ?edit=true&standalone=true and asserted three things. Two are already covered by existing unit tests; the new RTL test covers the third:

Original assertion Where covered
?edit=truediscard-changes-button visible URL→state in extractUrlParams.test.ts; state→DOM in Header.test.tsx (should render the "Discard changes" button under editMode: true).
?standalone=true#app-menu not in DOM #app-menu lives in Flask's spa.html and is gated server-side by {% if standalone_mode %} — out of RTL's reach. The React-side equivalent is ?standalone=2 (DashboardStandaloneMode.HideNavAndTitle), which makes DashboardBuilder suppress <DashboardHeader />. Net-new RTL test added.
Log emission (originally skipped as flaky) Already covered by logger.test.ts (should POST an event to /superset/log/ when called).

The literal ?standalone=true parses to 1 (HideNav), which only hides the Flask-rendered app menu. Using standalone=2 documents 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:

  • `should hide DashboardHeader when standalone mode hides nav and title (?standalone=2)`

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

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

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.14%. Comparing base (8eda626) to head (8230b7e).
⚠️ Report is 47 commits behind head on master.

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           
Flag Coverage Δ
javascript 67.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit e6d770d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a28640d5028980008fc38f6
😎 Deploy Preview https://deploy-preview-40914--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the DashboardHeader in DashboardBuilder.

@bito-code-review

Copy link
Copy Markdown
Contributor

The suggestion to capture and restore the full window.location.href is appropriate. This approach ensures that the pathname and hash are preserved, preventing potential state leakage to subsequent tests. Below is the recommended update for the test setup:

const originalHref = window.location.href;
// ... test logic ...
window.history.replaceState({}, '', originalHref);

superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx

const originalHref = window.location.href;
// ... test logic ...
window.history.replaceState({}, '', originalHref);

sadpandajoe and others added 2 commits June 9, 2026 16:29
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>
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants