import {test, expect} from '../../fixtures/test' // Elements with many data-* attributes appear in Canvas's custom element // patterns for media embeds, LTI content, and interactive widgets. Each // attribute carries metadata the JavaScript layer needs to initialize the // component. Losing any one attribute can break the widget entirely. test.describe('elements with many 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('span with 5 data attributes — text preserved', async ({page}) => { const content = await setAndGet( page, 'Media widget', ) expect(content).toContain('Media widget') }) test('div with Canvas LTI data attributes — text around preserved', async ({page}) => { const content = await setAndGet( page, '

Before

LTI placeholder

After

', ) expect(content).toContain('Before') expect(content).toContain('After') }) test('img with Canvas file data attributes — alt text preserved', async ({page}) => { const content = await setAndGet( page, 'Lecture diagram', ) expect(content).toContain('Lecture diagram') }) test('element with data attributes containing JSON-like values — text preserved', async ({ page, }) => { const content = await setAndGet( page, '
Config element text
', ) expect(content).toContain('Config element text') }) test('10 data attributes on one element — no crash', async ({page}) => { const content = await setAndGet( page, 'Ten data attributes', ) expect(content).toContain('Ten data attributes') }) })