import {test, expect} from '../../fixtures/test'
// Multiple consecutive
tags are used for vertical spacing in legacy
// content authored without CSS (common in old Canvas pages and Word imports).
// TinyMCE may collapse them; tests verify that surrounding text is never lost
// and document the actual normalization behavior.
test.describe('multiple consecutive
tags', () => {
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('text before and after two
tags is preserved', async ({page}) => {
const content = await setAndGet(page, 'Line A
Line B
')
expect(content).toContain('Line A')
expect(content).toContain('Line B')
})
test('text around five consecutive
tags is preserved', async ({page}) => {
const content = await setAndGet(
page,
'Top text
Bottom text
',
)
expect(content).toContain('Top text')
expect(content).toContain('Bottom text')
})
test('
at start of paragraph — text still present', async ({page}) => {
const content = await setAndGet(page, '
Text after leading br
')
expect(content).toContain('Text after leading br')
})
test('
at end of paragraph — text still present', async ({page}) => {
const content = await setAndGet(page, 'Text before trailing br
')
expect(content).toContain('Text before trailing br')
})
test('multiple
between paragraphs — both paragraphs preserved', async ({page}) => {
const content = await setAndGet(page, 'Para one
Para two
')
expect(content).toContain('Para one')
expect(content).toContain('Para two')
})
test('
inside a list item — text preserved', async ({page}) => {
const content = await setAndGet(
page,
'- First line
Second line in same item
',
)
expect(content).toContain('First line')
expect(content).toContain('Second line in same item')
})
})