Copilot commented on code in PR #40914:
URL: https://github.com/apache/superset/pull/40914#discussion_r3383950392
##########
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}`);
+ }
Review Comment:
The test mutates the browser URL but only saves/restores
`window.location.search`. Since the test also changes the pathname to
`/?standalone=2`, restoring only the search can leave the pathname/hash
different from what it was before the test (and can leak state to subsequent
tests if the Jest URL ever changes or another test sets a non-root pathname).
Prefer capturing/restoring the full `window.location.href` (pattern used
elsewhere) and only change the query param while preserving the existing
pathname/hash.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]