import {test, expect} from '../../fixtures/test'
// Horizontal rules (
) are a valid structural element in course content.
// TinyMCE exposes InsertHorizontalRule via execCommand; canvas-rce must not
// strip or transform
elements during serialization.
test.describe('horizontal rule', () => {
test.beforeEach(async ({page, rcePage}) => {
await page.goto('/scenarios/basic')
await rcePage.waitForEditor()
await rcePage.contentFrame().locator('body').click()
})
test('InsertHorizontalRule command inserts an
element', async ({page, rcePage}) => {
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.execCommand('InsertHorizontalRule')
})
const content = await rcePage.getContent()
expect(content).toMatch(/
is preserved when set via setContent', async ({page, rcePage}) => {
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent('above
below
')
})
const content = await rcePage.getContent()
expect(content).toMatch(/
appears between content in correct position', async ({page, rcePage}) => {
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent('above
below
')
})
const content = await rcePage.getContent()
const hrIdx = content.indexOf('
elements is preserved', async ({page, rcePage}) => {
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent(
'section 1
section 2
section 3
',
)
})
const content = await rcePage.getContent()
const hrCount = (content.match(/
is not stripped by XSS sanitization', async ({page, rcePage}) => {
//
is a safe element and must survive the sanitization pipeline
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.insertContent('
')
})
const content = await rcePage.getContent()
expect(content).toMatch(/