import {test, expect} from '../../fixtures/test' // Canvas content uses both absolute URLs (https://...) and relative URLs // (/courses/123/files/456). Relative URLs in href, src, and action must be // preserved exactly — rewriting them would break navigation and asset loading // in Canvas course pages. test.describe('relative URLs in href, src, and other 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('relative href link text is preserved', async ({page}) => { const content = await setAndGet( page, '

View Syllabus

', ) expect(content).toContain('View Syllabus') expect(content).toContain('/courses/123') }) test('relative img src — alt text preserved', async ({page}) => { const content = await setAndGet( page, '

Course diagram

', ) expect(content).toContain('alt') expect(content).toContain('Course diagram') }) test('root-relative URL in link — text preserved', async ({page}) => { const content = await setAndGet(page, '

Go to login page first.

') expect(content).toContain('login page') expect(content).toContain('first') }) test('../ relative URL in link — text preserved', async ({page}) => { const content = await setAndGet(page, '

Week 1 Module

') expect(content).toContain('Week 1 Module') }) test('Canvas LTI iframe relative src — text around it preserved', async ({page}) => { const content = await setAndGet( page, '

Tool below:

After tool.

', ) expect(content).toContain('Tool below') expect(content).toContain('After tool') }) test('multiple relative links — all text preserved', async ({page}) => { const content = await setAndGet( page, '', ) expect(content).toContain('Assignments') expect(content).toContain('Quizzes') expect(content).toContain('Grades') }) })