diff --git a/packages/renderer/src/lib/image/PushManifestModal.spec.ts b/packages/renderer/src/lib/image/PushManifestModal.spec.ts index 38ecea6412829..67a09d399331e 100644 --- a/packages/renderer/src/lib/image/PushManifestModal.spec.ts +++ b/packages/renderer/src/lib/image/PushManifestModal.spec.ts @@ -39,23 +39,10 @@ vi.mock('@xterm/xterm', () => { }; }); -const getConfigurationValueMock = vi.fn(); -const pushManifestMock = vi.fn(); - beforeAll(() => { - (window.events as unknown) = { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - receive: (_channel: string, func: any) => { - func(); - }, - }; - (window as any).ResizeObserver = vi.fn().mockReturnValue({ observe: vi.fn(), unobserve: vi.fn() }); - (window as any).getImageInspect = vi.fn().mockImplementation(() => Promise.resolve({})); - (window as any).logsContainer = vi.fn().mockResolvedValue(undefined); - (window as any).refreshTerminal = vi.fn(); - (window as any).getConfigurationValue = getConfigurationValueMock; - (window as any).showMessageBox = vi.fn(); - (window as any).pushManifest = pushManifestMock; + Object.defineProperty(window, 'dispatchEvent', { + value: vi.fn(), + }); }); const fakedManifest: ImageInfoUI = { @@ -95,4 +82,14 @@ test('Expect to render PushManifestModal correctly with Push manifest button', a // Be able to click it fireEvent.click(pushButton); + + // expect resize event to be dispatched + const event: Event = await vi.waitFor(() => { + expect(window.dispatchEvent).toHaveBeenCalled(); + const calls = vi.mocked(window.dispatchEvent).mock.calls; + expect(calls).toHaveLength(1); + expect(calls[0][0]).toBeInstanceOf(Event); + return calls[0][0]; + }); + expect(event.type).toBe('resize'); }); diff --git a/packages/renderer/src/lib/image/PushManifestModal.svelte b/packages/renderer/src/lib/image/PushManifestModal.svelte index 6e0f317ab1118..770e79d8c3065 100644 --- a/packages/renderer/src/lib/image/PushManifestModal.svelte +++ b/packages/renderer/src/lib/image/PushManifestModal.svelte @@ -20,6 +20,7 @@ let logsPush: Terminal; async function pushManifest() { initTerminal = true; await tick(); + window.dispatchEvent(new Event('resize')); logsPush?.reset(); pushInProgress = true; @@ -58,8 +59,8 @@ async function pushManifestFinished() { {/if}

{/if} -