import {test, expect} from '../../fixtures/test' // is an HTML5 scripting element for drawing graphics via JavaScript. // It has no meaningful static content — its visual output is JS-generated. // When included in course body content, canvas is either stripped (safe) or // preserved (inert without script). Surrounding text must always survive. test.describe(' element handling', () => { test.beforeEach(async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() }) async function setAndGet(page: any, html: string): Promise { return page.evaluate((content: string) => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent(content) // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent() }, html) } test('paragraph text around is preserved', async ({page}) => { const content = await setAndGet( page, '

Before canvas.

After canvas.

', ) expect(content).toContain('Before canvas') expect(content).toContain('After canvas') }) test(' fallback text is preserved', async ({page}) => { const content = await setAndGet( page, '

Chart:

Your browser does not support canvas.

End.

', ) expect(content).toContain('Chart') expect(content).toContain('End') }) test(' with id does not crash editor', async ({page}) => { const content = await setAndGet( page, '

Content after.

', ) expect(content).toContain('Content after') expect(typeof content).toBe('string') }) test(' inside a figure with caption — caption preserved', async ({page}) => { const content = await setAndGet( page, '
Dynamic chart (requires JavaScript)
', ) expect(content).toContain('Dynamic chart') expect(content).toContain('requires JavaScript') }) })