diff --git a/tests/e2e/code/panel.spec.ts b/tests/e2e/code/panel.spec.ts index fa1d7b7f5..0d0bdc05c 100644 --- a/tests/e2e/code/panel.spec.ts +++ b/tests/e2e/code/panel.spec.ts @@ -99,6 +99,32 @@ test('switching back to Design tab works', async () => { ).toBeVisible() }) +test('shows import errors in the Code panel', async () => { + await codeTab().click() + await editor.page.getByTestId('code-panel-import-toggle').click() + await editor.page.evaluate(() => { + const store = window.openPencil?.getStore?.() + if (!store) throw new Error('OpenPencil store not initialized') + const importDOMText = store.importDOMText + store.importDOMText = async () => { + store.importDOMText = importDOMText + throw new Error('CSS import failed') + } + }) + + await editor.page.getByTestId('code-panel-import-html').fill('
Broken DOM
') + await editor.page.getByTestId('code-panel-import').click() + + await expect(editor.page.getByTestId('code-panel-import-error')).toBeVisible() + await expect(editor.page.getByTestId('code-panel-import-error')).toContainText( + 'CSS import failed' + ) + + await editor.page.getByTestId('code-panel-import-html').fill('
Recovered
') + await expect(editor.page.getByTestId('code-panel-import-error')).toBeHidden() + await editor.page.getByTestId('code-panel-import-toggle').click() +}) + test('imports HTML and CSS into the canvas', async () => { await codeTab().click() await editor.page.getByTestId('code-panel-import-toggle').click()