test(app): cover Code panel import errors

This commit is contained in:
Danila Poyarkov 2026-06-06 17:30:36 +03:00
parent 3f1a5ce779
commit ce1bcb3434

View file

@ -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('<div class="card">Broken DOM</div>')
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('<div class="card">Recovered</div>')
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()