import {test, expect} from '../../fixtures/test' // Canvas-specific content patterns for LTI tools, media embeds, and // course content identifiers. These use specific data-* attributes and // iframe patterns that canvas-rce must preserve for LTI launches to work. // A refactor must not strip canvas_* data attributes or the LTI iframe structure. test.describe('Canvas LTI and media embed 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('LTI iframe with data-lti-launch attributes — surrounding text preserved', async ({ page, }) => { const content = await setAndGet( page, '

Launch below:

After launch.

', ) expect(content).toContain('Launch below') expect(content).toContain('After launch') }) test('Canvas media comment iframe — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

Watch:

Discuss.

', ) expect(content).toContain('Watch') expect(content).toContain('Discuss') }) test('Canvas image with data attributes — alt text preserved', async ({page}) => { const content = await setAndGet( page, 'Course diagram', ) expect(content).toContain('alt') expect(content).toContain('Course diagram') }) test('span.instructure_file_link — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Download: Assignment handout.pdf

', ) expect(content).toContain('Assignment handout.pdf') }) test('Canvas equation span — LaTeX preserved', async ({page}) => { const content = await setAndGet( page, '

The formula \\sqrt{x^2+y^2} represents distance.

', ) expect(content).toContain('sqrt') expect(content).toContain('represents distance') }) })