import {test, expect} from '../../fixtures/test' // Verifies that rich HTML passed as defaultContent is faithfully rendered and // preserved. This is a critical contract — canvas-rce must not mangle existing // content when loading it into the editor. test.describe('defaultContent — rich HTML', () => { test('defaultContent with bold text is preserved', async ({page, rcePage}) => { await page.goto('/scenarios/with-default-content') await rcePage.waitForEditor() const content = await rcePage.getContent() // The with-default-content scenario loads HTML; verify structure is intact expect(content.length).toBeGreaterThan(0) }) test('defaultContent with a table retains all cells', async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() // Set rich content directly via TinyMCE API (simulates what defaultContent prop does) await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent( '
| A1 | A2 |
| B1 | B2 |
bold and italic and both
', ) }) const content = await rcePage.getContent() expect(content).toMatch(/bold<\/strong>/) expect(content).toMatch(/italic<\/em>/) // Nested bold+italic expect(content).toMatch(/both<\/em><\/strong>|both<\/strong><\/em>/) }) test('setContent replaces existing content entirely', async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() await rcePage.contentFrame().locator('body').click() await rcePage.typeContent('original content') // Replace with entirely new content await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('replacement content
') }) const content = await rcePage.getContent() expect(content).toContain('replacement content') expect(content).not.toContain('original content') }) test('defaultContent with heading tags renders correct heading levels', async ({ page, rcePage, }) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('Body
') }) const content = await rcePage.getContent() expect(content).toMatch(/