You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/06/09 19:05:38 UTC

(superset) 01/01: test(dashboard): migrate standalone mode Cypress spec to RTL

This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch dashboard-load-rtl
in repository https://gitbox.apache.org/repos/asf/superset.git

commit e6d770d1ddec4a15502b0d9e0eb59ef54f6b5e15
Author: Joe Li <jo...@preset.io>
AuthorDate: Tue Jun 9 12:05:09 2026 -0700

    test(dashboard): migrate standalone mode Cypress spec to RTL
    
    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) <no...@anthropic.com>
---
 .../DashboardBuilder/DashboardBuilder.test.tsx           | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
index 726aab0a0ef..a4dcf86f14b 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
@@ -165,6 +165,22 @@ describe('DashboardBuilder', () => {
     expect(header).toBeInTheDocument();
   });
 
+  test('should hide DashboardHeader when standalone mode hides nav and title (?standalone=2)', () => {
+    // React-level equivalent of the legacy `cy.get('#app-menu').should('not.exist')`
+    // Cypress assertion. The `#app-menu` node lives in Flask's spa.html template,
+    // gated by `{% if standalone_mode %}`, so RTL cannot reach it directly.
+    // `?standalone=2` maps to DashboardStandaloneMode.HideNavAndTitle, which the
+    // DashboardBuilder honours by suppressing the React-side DashboardHeader.
+    const originalSearch = window.location.search;
+    window.history.replaceState({}, '', '/?standalone=2');
+    try {
+      const { queryByTestId } = setup();
+      expect(queryByTestId('dashboard-header-container')).not.toBeInTheDocument();
+    } finally {
+      window.history.replaceState({}, '', `/${originalSearch}`);
+    }
+  });
+
   test('should render a Sticky top-level Tabs if the dashboard has tabs', async () => {
     const { findAllByTestId } = setup({
       dashboardLayout: undoableDashboardLayoutWithTabs,