import {test, expect} from '../../fixtures/test' // TinyMCE normalizes legacy presentational elements to semantic equivalents: // → , → , → /. // canvas-rce must preserve this normalization — a refactor must not revert // to outputting the deprecated presentational tags or lose the content. test.describe('legacy element normalization (b→strong, i→em)', () => { 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(' is preserved or normalized to , content survives', async ({page}) => { const content = await setAndGet(page, '

bold text

') expect(content).toContain('bold text') // TinyMCE normalizes to expect(content).toMatch(/bold text<\/strong>|bold text<\/b>/) }) test(' is preserved or normalized to , content survives', async ({page}) => { const content = await setAndGet(page, '

italic text

') expect(content).toContain('italic text') expect(content).toMatch(/italic text<\/em>|italic text<\/i>/) }) test(' is normalized to or similar, content survives', async ({page}) => { const content = await setAndGet(page, '

struck text

') expect(content).toContain('struck text') // May become , , text-decoration:line-through, or expect(typeof content).toBe('string') }) test(' monospace is handled without losing content', async ({page}) => { const content = await setAndGet(page, '

teletype text

') expect(content).toContain('teletype text') }) test(' and nested: both content words survive', async ({page}) => { const content = await setAndGet(page, '

bold italic

') expect(content).toContain('bold italic') }) test(' input is preserved as (not double-wrapped)', async ({page}) => { const content = await setAndGet(page, '

already semantic

') expect(content).toMatch(/already semantic<\/strong>/) // Must not become expect(content).not.toMatch(//) }) test(' input is preserved as (not double-wrapped)', async ({page}) => { const content = await setAndGet(page, '

already semantic

') expect(content).toMatch(/already semantic<\/em>/) expect(content).not.toMatch(//) }) test('mixed legacy and semantic tags in same paragraph', async ({page}) => { const content = await setAndGet( page, '

bold and strong and italic and em

', ) expect(content).toContain('bold') expect(content).toContain('strong') expect(content).toContain('italic') expect(content).toContain('em') }) })