import {test, expect} from '../../fixtures/test' // Canvas course pages use h1-h6 for document outline and screen reader navigation. // TinyMCE typically restricts to h2-h4 via toolbar, but content can include // all heading levels via setContent. All levels must survive serialization. test.describe('heading hierarchy h1 through h6', () => { 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('h1 element is preserved', async ({page}) => { const content = await setAndGet(page, '

Top Level Title

') expect(content).toContain('Top Level Title') expect(content).toMatch(/

{ const content = await setAndGet(page, '

Chapter Title

') expect(content).toContain('Chapter Title') expect(content).toMatch(/

{ const content = await setAndGet(page, '

Section Heading

') expect(content).toContain('Section Heading') expect(content).toMatch(/

{ const content = await setAndGet(page, '

Subsection

') expect(content).toContain('Subsection') expect(content).toMatch(/

{ const content = await setAndGet(page, '

Minor Heading
') expect(content).toContain('Minor Heading') expect(content).toMatch(/
{ const content = await setAndGet(page, '
Fine Print
') expect(content).toContain('Fine Print') expect(content).toMatch(/
{ const content = await setAndGet( page, `

Course Title

Unit 1

Lesson 1.1

Topic A

Detail i
Note
`, ) expect(content).toContain('Course Title') expect(content).toContain('Unit 1') expect(content).toContain('Lesson 1.1') expect(content).toContain('Topic A') expect(content).toContain('Detail i') expect(content).toContain('Note') expect(content).toMatch(/

{ const content = await setAndGet(page, '

Must remain h3

') expect(content).toMatch(/]*>Must remain h3<\/h3>/) expect(content).not.toMatch(/]*>Must remain h3/) expect(content).not.toMatch(/]*>Must remain h3/) }) test('heading with mixed content (text + inline elements)', async ({page}) => { const content = await setAndGet(page, '

Introduction to Machine Learning

') expect(content).toContain('Introduction to') expect(content).toContain('Machine Learning') expect(content).toMatch(/Machine Learning<\/em>/) expect(content).toMatch(/

{ const content = await setAndGet(page, '

After empty heading

') expect(content).toContain('After empty heading') expect(typeof content).toBe('string') }) })