import {test, expect} from '../../fixtures/test' // The scope and headers attributes on and establish relationships // between header and data cells for screen readers (WCAG 1.3.1). // scope="col" / scope="row" are the most common; headers="id1 id2" is used // for complex tables. canvas-rce must preserve them through round-trips. test.describe('table scope and headers accessibility 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('scope="col" on th — header text preserved', async ({page}) => { const content = await setAndGet( page, '
NameScore
Alice95
', ) expect(content).toContain('Name') expect(content).toContain('Score') expect(content).toContain('Alice') }) test('scope="row" on th in tbody — all text preserved', async ({page}) => { const content = await setAndGet( page, '
MondayLectureLab
TuesdaySeminarOffice Hours
', ) expect(content).toContain('Monday') expect(content).toContain('Lecture') expect(content).toContain('Tuesday') expect(content).toContain('Office Hours') }) test('scope="colgroup" on th spanning multiple columns', async ({page}) => { const content = await setAndGet( page, '
Semester 1Semester 2
MathScienceMathScience
', ) expect(content).toContain('Semester 1') expect(content).toContain('Semester 2') expect(content).toContain('Math') expect(content).toContain('Science') }) test('headers attribute linking td to th ids — text preserved', async ({page}) => { const content = await setAndGet( page, '
NameGrade
BobA
', ) expect(content).toContain('Name') expect(content).toContain('Grade') expect(content).toContain('Bob') }) test('summary attribute on table — table text preserved', async ({page}) => { // summary is deprecated in HTML5 but appears in legacy content const content = await setAndGet( page, '
StudentFinal Grade
CarolB+
', ) expect(content).toContain('Student') expect(content).toContain('Final Grade') expect(content).toContain('Carol') }) })