import {test, expect} from '../../fixtures/test'
//
(horizontal rule) is a thematic break element used to separate content
// sections. It can appear after headings, between paragraphs, and inside
// containers. Tests verify that text above and below
always survives
// and that
itself doesn't corrupt surrounding content structure.
test.describe('
horizontal rule in various contexts', () => {
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('
between two paragraphs — both preserved', async ({page}) => {
const content = await setAndGet(
page,
'First section content.
Second section content.
',
)
expect(content).toContain('First section content')
expect(content).toContain('Second section content')
})
test('
after a heading — heading and following text preserved', async ({page}) => {
const content = await setAndGet(
page,
'Chapter Title
Chapter introduction text.
',
)
expect(content).toContain('Chapter Title')
expect(content).toContain('Chapter introduction text')
})
test('multiple
elements divide sections — all text preserved', async ({page}) => {
const content = await setAndGet(
page,
'Section A
Section B
Section C
',
)
expect(content).toContain('Section A')
expect(content).toContain('Section B')
expect(content).toContain('Section C')
})
test('
inside a blockquote — text preserved', async ({page}) => {
const content = await setAndGet(
page,
'First quote part.
Second quote part.
',
)
expect(content).toContain('First quote part')
expect(content).toContain('Second quote part')
})
test('
with style attribute — surrounding text preserved', async ({page}) => {
const content = await setAndGet(
page,
'Above
Below
',
)
expect(content).toContain('Above')
expect(content).toContain('Below')
})
test('
at the very start of content — following text preserved', async ({page}) => {
const content = await setAndGet(page, '
Text after leading rule.
')
expect(content).toContain('Text after leading rule')
})
})