import {test, expect} from '../../fixtures/test' // Canvas file links use specific data attributes to wire up the in-app // preview, download, and permission systems. Instructors paste these from // the file picker and expect all data attributes to survive round-trips. // If data-api-endpoint or data-id are stripped, Canvas's JS won't find the file. test.describe('Canvas file link data attributes', () => { 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('Canvas file link with data-api-endpoint — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Course Syllabus.pdf

', ) expect(content).toContain('Course Syllabus.pdf') }) test('Canvas inline preview link — text preserved', async ({page}) => { const content = await setAndGet( page, '

Lecture Notes.pdf

', ) expect(content).toContain('Lecture Notes.pdf') }) test('Canvas media comment link — text preserved', async ({page}) => { const content = await setAndGet( page, '

Watch: Introduction Video

', ) expect(content).toContain('Watch: Introduction Video') }) test('Canvas image with data-api-returntype — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

Assignment rubric: Rubric diagram (see above)

', ) expect(content).toContain('Assignment rubric') expect(content).toContain('see above') }) test('multiple Canvas file links in a list — all text preserved', async ({page}) => { const content = await setAndGet( page, '', ) expect(content).toContain('Week 1 Reading.pdf') expect(content).toContain('Week 2 Reading.pdf') }) })