import {test, expect} from '../../fixtures/test' // id attributes on headings and sections enable in-page anchor navigation. // Canvas course pages often have a table of contents that links to #section-id // anchors deeper in the page. If canvas-rce strips id attributes, TOC links // break silently — a refactor must not introduce this regression. test.describe('id attributes for in-page jump links', () => { 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('id on a heading is preserved', async ({page}) => { const content = await setAndGet( page, '

Introduction

Opening paragraph.

', ) expect(content).toContain('Introduction') expect(content).toContain('id') }) test('anchor link to an id in the same page text is preserved', async ({page}) => { const content = await setAndGet( page, '

Jump to Section 2

Section 2

', ) expect(content).toContain('Jump to Section 2') expect(content).toContain('Section 2') }) test('id on a paragraph is preserved', async ({page}) => { const content = await setAndGet(page, '

The key concept explained here.

') expect(content).toContain('The key concept explained here') expect(content).toContain('id') }) test('multiple sections with ids all preserved', async ({page}) => { const content = await setAndGet( page, '

Chapter 1

Content one.

Chapter 2

Content two.

', ) expect(content).toContain('Chapter 1') expect(content).toContain('Content one') expect(content).toContain('Chapter 2') expect(content).toContain('Content two') }) test('id with hyphen and numbers is preserved', async ({page}) => { const content = await setAndGet(page, '

Advanced Topics

') expect(content).toContain('Advanced Topics') expect(content).toContain('section-3-2-advanced') }) test('id on a list element — text preserved', async ({page}) => { const content = await setAndGet( page, '
  1. First step
  2. Second step
', ) expect(content).toContain('First step') expect(content).toContain('Second step') }) })