import {test, expect} from '../../fixtures/test' // HTML semantic elements (blockquote, abbr, cite, del, ins, mark) appear in // course content authored by instructors. canvas-rce must preserve these elements // so that semantic meaning and accessibility information reach students. test.describe('semantic HTML elements', () => { 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 with content', async ({page}) => { const content = await setAndGet(page, '

To be or not to be.

') expect(content).toMatch(/
and elements survive serialization', async ({page}) => { const content = await setAndGet(page, '

old text new text

') expect(content).toContain('old text') expect(content).toContain('new text') // At least one of del/ins should be preserved — TinyMCE config determines which const hasDel = content.includes(' element is preserved', async ({page}) => { const content = await setAndGet(page, '

As stated in The Elements of Style.

') expect(content).toContain('The Elements of Style') }) test(' element is preserved with title', async ({page}) => { const content = await setAndGet( page, '

HTML is the language of the web.

', ) expect(content).toContain('HTML') expect(content).toContain('the language of the web') }) test(' highlight element content is preserved', async ({page}) => { const content = await setAndGet( page, '

This is highlighted text in a paragraph.

', ) expect(content).toContain('highlighted text') }) test(' keyboard shortcut element content survives', async ({page}) => { const content = await setAndGet(page, '

Press Ctrl+S to save.

') expect(content).toContain('Ctrl') expect(content).toContain('to save') }) test(' sample output element content survives', async ({page}) => { const content = await setAndGet(page, '

The output was: Hello, World!

') expect(content).toContain('Hello, World!') }) test('nested blockquote with attribution is preserved', async ({page}) => { const content = await setAndGet( page, '

Not all those who wander are lost.

— J.R.R. Tolkien
', ) expect(content).toContain('wander are lost') expect(content).toContain('Tolkien') }) test(' element content is preserved', async ({page}) => { const content = await setAndGet(page, '

Main content (see footnote 1)

') expect(content).toContain('see footnote 1') }) test('mixed semantic elements in a paragraph survive together', async ({page}) => { const content = await setAndGet( page, '

Students should read Chapter 3 and complete the assigned exercises.

', ) expect(content).toContain('Chapter 3') expect(content).toContain('complete') expect(content).toContain('assigned') expect(content).toContain('exercises') expect(content).toMatch(//) expect(content).toMatch(//) }) })