import {test, expect} from '../../fixtures/test' // URLs in href/src attributes may have query strings, fragments, encoded chars, // and port numbers. Instructors paste these from browser address bars or LMS // deep links. The link text must survive; URL manipulation is Canvas's job. test.describe('URL edge cases in href and src 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('href with query string — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Module Assignment

', ) expect(content).toContain('Module Assignment') }) test('href with fragment — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Jump to Section 2

', ) expect(content).toContain('Jump to Section 2') }) test('href with query + fragment — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Search results

', ) expect(content).toContain('Search results') }) test('href with encoded characters — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Course Notes

', ) expect(content).toContain('Course Notes') }) test('link with rel="noopener noreferrer" and target="_blank" — text preserved', async ({ page, }) => { const content = await setAndGet( page, '

External resource (opens in new tab)

', ) expect(content).toContain('External resource') }) test('link with rel="nofollow" — text preserved', async ({page}) => { const content = await setAndGet( page, '

External link

', ) expect(content).toContain('External link') }) test('Canvas deep link with multiple params — text preserved', async ({page}) => { const content = await setAndGet( page, '

Quiz: Midterm Exam

', ) expect(content).toContain('Quiz: Midterm Exam') }) test('data: URI in href — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Data URI link text

', ) expect(content).toContain('Data URI link text') }) })