import {test, expect} from '../../fixtures/test' // and elements define column-level formatting for tables. // Instructors use them to set column widths in grade tables and schedules. // They are structural HTML — canvas-rce should not silently drop them. test.describe('table colgroup and col elements', () => { 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('table cell content is preserved when colgroup is present', async ({page}) => { const content = await setAndGet( page, `
LabelValue
Score95
`, ) expect(content).toContain('Label') expect(content).toContain('Value') expect(content).toContain('Score') expect(content).toContain('95') }) test('colgroup with span attribute content round-trips', async ({page}) => { const content = await setAndGet( page, `
AB
12
`, ) expect(content).toContain('A') expect(content).toContain('B') expect(content).toContain('1') expect(content).toContain('2') }) test('table with col width styles preserves all row data', async ({page}) => { const content = await setAndGet( page, `
AssignmentPointsPossibleGrade
Essay 185100B
Midterm78100C+
`, ) expect(content).toContain('Assignment') expect(content).toContain('Essay 1') expect(content).toContain('Midterm') expect(content).toContain('Grade') }) test('table without colgroup still works correctly', async ({page}) => { const content = await setAndGet( page, '
no colgroupstill works
', ) expect(content).toContain('no colgroup') expect(content).toContain('still works') }) })