Compare commits

...

3 Commits

Author SHA1 Message Date
Joe Li
8230b7efa5 test(dashboard): cover combined edit+standalone URL params
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>
2026-06-09 16:42:28 -07:00
Joe Li
63e60bc331 test(dashboard): save/restore full URL in standalone mode test
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>
2026-06-09 16:29:26 -07:00
Joe Li
e6d770d1dd 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) <noreply@anthropic.com>
2026-06-09 12:05:09 -07:00

View File

@@ -165,6 +165,42 @@ 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 originalHref = window.location.href;
window.history.replaceState({}, '', '/?standalone=2');
try {
const { queryByTestId } = setup();
expect(queryByTestId('dashboard-header-container')).not.toBeInTheDocument();
} finally {
window.history.replaceState({}, '', originalHref);
}
});
test('should apply editing class and hide header when both edit and standalone params are set', () => {
// Combined-params analogue of the legacy `?edit=true&standalone=true` Cypress
// mount. The two URL params are orthogonal on the React side: standalone=2
// suppresses DashboardHeader regardless of editMode, while editMode still
// drives the `dashboard--editing` class on the wrapper.
const originalHref = window.location.href;
window.history.replaceState({}, '', '/?edit=true&standalone=2');
try {
const { getByTestId, queryByTestId } = setup({
dashboardState: { ...mockState.dashboardState, editMode: true },
});
expect(getByTestId('dashboard-content-wrapper')).toHaveClass(
'dashboard dashboard--editing',
);
expect(queryByTestId('dashboard-header-container')).not.toBeInTheDocument();
} finally {
window.history.replaceState({}, '', originalHref);
}
});
test('should render a Sticky top-level Tabs if the dashboard has tabs', async () => {
const { findAllByTestId } = setup({
dashboardLayout: undoableDashboardLayoutWithTabs,