import {test, expect} from '../../fixtures/test' // Headings with id attributes enable in-page navigation ("jump to section"). // Canvas generates these automatically from heading text, and instructors // create them manually when building table-of-contents pages. The id must // survive round-trips — losing it breaks all anchor links pointing to that section. test.describe('heading id and anchor navigation patterns', () => { 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('h2 with id — heading text preserved', async ({page}) => { const content = await setAndGet( page, '

Module Overview

Content follows.

', ) expect(content).toContain('Module Overview') }) test('anchor link to heading id — link text and target text preserved', async ({page}) => { const content = await setAndGet( page, '

Jump to requirements

Assignment Requirements

Details here.

', ) expect(content).toContain('Jump to requirements') expect(content).toContain('Assignment Requirements') expect(content).toContain('Details here') }) test('table of contents with multiple anchor links — all text preserved', async ({page}) => { const content = await setAndGet( page, `

Introduction

Welcome.

Week 1: Foundations

Start here.

Week 2: Applications

Apply it.

`, ) expect(content).toContain('Introduction') expect(content).toContain('Week 1: Foundations') expect(content).toContain('Week 2: Applications') }) test('heading ids with special characters slugified — text preserved', async ({page}) => { const content = await setAndGet( page, '

3.1 Getting Started

', ) expect(content).toContain('3.1 Getting Started') }) test('multiple heading levels each with id — all preserved', async ({page}) => { const content = await setAndGet( page, '

Course Title

Unit 1

Lesson 1.1

Content.

', ) expect(content).toContain('Course Title') expect(content).toContain('Unit 1') expect(content).toContain('Lesson 1.1') }) })