|
6 | 6 | * or a tab close asks first, as it does for every other held Studio edit. |
7 | 7 | * |
8 | 8 | * 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. |
13 | 11 | */ |
14 | 12 |
|
15 | 13 | import '@testing-library/jest-dom/vitest'; |
@@ -55,26 +53,20 @@ vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => nul |
55 | 53 | import { StudioDesignSurface } from './StudioDesignSurface'; |
56 | 54 | import { AppNavCanvas } from '../metadata-admin/previews/AppNavCanvas'; |
57 | 55 |
|
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; |
63 | 58 | (globalThis as { ResizeObserver?: unknown }).ResizeObserver = |
64 | 59 | (globalThis as { ResizeObserver?: unknown }).ResizeObserver ?? class { observe() {} unobserve() {} disconnect() {} }; |
65 | 60 |
|
66 | 61 | beforeEach(() => { |
67 | 62 | for (const fn of Object.values(mockClient)) (fn as unknown as { mockClear: () => void }).mockClear(); |
68 | 63 | mockClient.layered.mockImplementation(async (type: string) => { |
69 | 64 | 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 }; |
71 | 66 | }); |
72 | 67 | vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, json: async () => [] })) as unknown as typeof fetch); |
73 | 68 | }); |
74 | | -afterEach(() => { |
75 | | - cleanup(); |
76 | | - vi.unstubAllGlobals(); |
77 | | -}); |
| 69 | +afterEach(() => (cleanup(), vi.unstubAllGlobals())); |
78 | 70 |
|
79 | 71 | /** Whether a reload / tab close would be asked about. */ |
80 | 72 | function reloadAsks(): boolean { |
|
0 commit comments