import {test, expect} from '../../fixtures/test' // Image attributes affect layout, accessibility, and responsive behavior. // alt is required for accessibility; width/height prevent layout shift; // title provides tooltip text; loading="lazy" defers off-screen images. // canvas-rce must preserve these attributes through setContent/getContent. test.describe('image element 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('alt attribute is preserved', async ({page}) => { const content = await setAndGet( page, '

Students working in a lab

', ) expect(content).toContain('alt') expect(content).toContain('Students working in a lab') }) test('width and height attributes are preserved', async ({page}) => { const content = await setAndGet( page, '

diagram

', ) expect(content).toContain('400') expect(content).toContain('300') }) test('title attribute on image is preserved or text context survives', async ({page}) => { const content = await setAndGet( page, '

Sales chartText after image

', ) expect(content).toContain('Text after image') }) test('class attribute on image is preserved', async ({page}) => { const content = await setAndGet( page, '

icon

', ) expect(content).toContain('class') }) test('empty alt attribute (decorative image) is preserved', async ({page}) => { const content = await setAndGet( page, '

Decorative: text continues

', ) expect(content).toContain('text continues') expect(content).toContain('alt') }) test('multiple images in sequence all survive', async ({page}) => { const content = await setAndGet( page, '

Image AImage BImage C

', ) expect(content).toContain('Image A') expect(content).toContain('Image B') expect(content).toContain('Image C') }) test('image with style attribute for sizing is preserved', async ({page}) => { const content = await setAndGet( page, '

large photo

', ) expect(content).toContain('alt') }) test('loading="lazy" attribute on image', async ({page}) => { const content = await setAndGet( page, '

below fold imageafter

', ) expect(content).toContain('after') expect(content).toContain('alt') }) })