import {test, expect} from '../../fixtures/test' // Numeric HTML entities (© — —) appear in content exported // from older CMS platforms, Word documents, and Canvas's own legacy exporter. // TinyMCE may decode them to literal characters or re-encode as named entities. // Tests document actual round-trip behavior for refactor compliance. test.describe('numeric HTML entities', () => { 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('© (copyright) round-trips in some form', async ({page}) => { const content = await setAndGet(page, '

© 2024 Instructure

') expect(content).toContain('2024 Instructure') // May decode to ©, re-encode as © or © expect(content).toMatch(/©|©|©/) }) test('— (em dash) round-trips in some form', async ({page}) => { const content = await setAndGet(page, '

Canvas—the leading LMS

') expect(content).toContain('Canvas') expect(content).toContain('the leading LMS') expect(content).toMatch(/—|—|—/) }) test('— (hex em dash) round-trips', async ({page}) => { const content = await setAndGet(page, '

A—B

') expect(content).toContain('A') expect(content).toContain('B') // Content between A and B must be some form of em dash expect(content).toMatch(/A(—|—|—|—)B/) }) test('  (non-breaking space) round-trips', async ({page}) => { const content = await setAndGet(page, '

first last

') expect(content).toContain('first') expect(content).toContain('last') }) test('“ and ” (curly quotes) round-trip', async ({page}) => { const content = await setAndGet(page, '

“quoted text”

') expect(content).toContain('quoted text') // May be decoded to " " or re-encoded expect(content).toMatch(/"|"|“|”|“|”|"/) }) test(' (tab) in content is handled without crash', async ({page}) => { const content = await setAndGet(page, '

before after

') expect(content).toContain('before') expect(content).toContain('after') }) test('consecutive numeric entities in sequence all produce text', async ({page}) => { // H-e-l-l-o as decimal entities const content = await setAndGet(page, '

Hello

') // TinyMCE may decode these to literal text or leave as entities // Either "Hello" or the entity sequence must survive expect(typeof content).toBe('string') expect(content.length).toBeGreaterThan(0) }) test('mixed named and numeric entities in same text', async ({page}) => { const content = await setAndGet( page, '

© 2024 — All rights © reserved—

', ) expect(content).toContain('2024') expect(content).toContain('All rights') expect(content).toContain('reserved') }) })