import {test, expect} from '../../fixtures/test' // Inline SVG is used for diagrams, icons, and mathematical figures in course // content. TinyMCE may preserve, strip, or sanitize SVG markup. // Tests document actual behavior — specifically that text inside SVG ( // elements and title/desc for accessibility) and surrounding paragraph text // survive the round-trip regardless of what TinyMCE does to SVG structure. test.describe('inline SVG content', () => { 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 inline SVG is preserved', async ({page}) => { const content = await setAndGet( page, '

Before SVG.

After SVG.

', ) expect(content).toContain('Before SVG') expect(content).toContain('After SVG') }) test('SVG with accessibility text — surrounding content preserved', async ({page}) => { const content = await setAndGet( page, '<p>Diagram below:</p><svg><title>Bar chart showing sales data

End of diagram.

', ) expect(content).toContain('Diagram below') expect(content).toContain('End of diagram') }) test('SVG with embedded element — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

Label:

A

Caption text here.

', ) expect(content).toContain('Label') expect(content).toContain('Caption text here') }) test('SVG inline does not crash the editor', async ({page}) => { const content = await setAndGet( page, '

Start

End

', ) expect(typeof content).toBe('string') expect(content).toContain('Start') expect(content).toContain('End') }) test('SVG with xlink:href — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

Icon:

Confirmed.

', ) expect(content).toContain('Icon') expect(content).toContain('Confirmed') }) })