Skip to content

Commit 301cf9f

Browse files
committed
test: trim the nav rename held suite
Claude-Session: https://claude.ai/code/session_01L6bhgXU26UBEjd1KKHgNEx Co-authored-by: Claude <noreply@anthropic.com>
1 parent e814dd1 commit 301cf9f

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.navRenameHeld-27464.test.tsx‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
* or a tab close asks first, as it does for every other held Studio edit.
77
*
88
* The canvas reports the pending rename and the pillar folds it into the one
9-
* held-edit report the surface already reads (`useHeldEditReport`), so the
10-
* surface's single `beforeunload` guard covers it. Rendered through the REAL
11-
* `StudioDesignSurface` on the real route shape. A bare `AppNavCanvas` (the
12-
* `AppPreview` caller passes no report) renames as before.
9+
* held-edit report the surface already reads, so its one `beforeunload` guard
10+
* covers it. A bare `AppNavCanvas` (the `AppPreview` caller) renames as before.
1311
*/
1412

1513
import '@testing-library/jest-dom/vitest';
@@ -55,26 +53,20 @@ vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => nul
5553
import { StudioDesignSurface } from './StudioDesignSurface';
5654
import { AppNavCanvas } from '../metadata-admin/previews/AppNavCanvas';
5755

58-
window.matchMedia = ((query: string) => ({
59-
matches: false, media: query, onchange: null,
60-
addEventListener: () => {}, removeEventListener: () => {}, addListener: () => {}, removeListener: () => {},
61-
dispatchEvent: () => false,
62-
})) as unknown as typeof window.matchMedia;
56+
const noop = () => {};
57+
window.matchMedia = ((media: string) => ({ matches: false, media, addEventListener: noop, removeEventListener: noop })) as unknown as typeof window.matchMedia;
6358
(globalThis as { ResizeObserver?: unknown }).ResizeObserver =
6459
(globalThis as { ResizeObserver?: unknown }).ResizeObserver ?? class { observe() {} unobserve() {} disconnect() {} };
6560

6661
beforeEach(() => {
6762
for (const fn of Object.values(mockClient)) (fn as unknown as { mockClear: () => void }).mockClear();
6863
mockClient.layered.mockImplementation(async (type: string) => {
6964
const effective = type === 'app' ? { name: 'acme_app', label: 'Acme', navigation: NAV } : type === 'page' ? HOME : null;
70-
return { code: null, overlay: effective, overlayScope: effective ? 'env' : null, effective, editable: true };
65+
return { code: null, overlay: null, overlayScope: null, effective, editable: true };
7166
});
7267
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, json: async () => [] })) as unknown as typeof fetch);
7368
});
74-
afterEach(() => {
75-
cleanup();
76-
vi.unstubAllGlobals();
77-
});
69+
afterEach(() => (cleanup(), vi.unstubAllGlobals()));
7870

7971
/** Whether a reload / tab close would be asked about. */
8072
function reloadAsks(): boolean {

0 commit comments

Comments
 (0)