import {test, expect} from '../../fixtures/test' // Course content frequently uses complex tables with merged cells for schedules, // rubrics, and grade tables. colspan and rowspan are standard HTML attributes // that TinyMCE must preserve — stripping them collapses the table layout. test.describe('table merged cells (colspan/rowspan)', () => { 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('colspan attribute is preserved on td', async ({page}) => { const content = await setAndGet( page, '
Merged header
AB
', ) expect(content).toContain('Merged header') expect(content).toContain('colspan="2"') }) test('rowspan attribute is preserved on td', async ({page}) => { const content = await setAndGet( page, '
Side labelRow 1
Row 2
', ) expect(content).toContain('Side label') expect(content).toContain('rowspan="2"') }) test('colspan on th is preserved', async ({page}) => { const content = await setAndGet( page, '
Quarter Results
Q1Q2Q3
', ) expect(content).toContain('Quarter Results') expect(content).toMatch(/colspan="3"/) }) test('table with both colspan and rowspan in same table', async ({page}) => { const content = await setAndGet( page, `
Header
Tall cellTop right
Bottom right
`, ) expect(content).toContain('Header') expect(content).toContain('Tall cell') expect(content).toContain('Top right') expect(content).toContain('Bottom right') expect(content).toMatch(/colspan="2"/) expect(content).toMatch(/rowspan="2"/) }) test('colspan="1" (default, no-op) is handled gracefully', async ({page}) => { const content = await setAndGet(page, '
Normal
') expect(content).toContain('Normal') // colspan="1" may be preserved or stripped (both are valid) expect(typeof content).toBe('string') }) test('rubric-style table with complex spans preserves all content', async ({page}) => { const content = await setAndGet( page, `
Criterion Rating Scale
4 - Excellent 3 - Good 2 - Fair 1 - Poor
Writing quality Clear and concise Mostly clear Some clarity issues Hard to follow
No errors Few errors Some errors Many errors
`, ) expect(content).toContain('Criterion') expect(content).toContain('Rating Scale') expect(content).toContain('Writing quality') expect(content).toContain('Excellent') expect(content).toContain('No errors') const colspanMatch = content.match(/colspan="4"/) expect(colspanMatch).not.toBeNull() }) test('cell content within merged cells is preserved', async ({page}) => { const content = await setAndGet( page, '
Bold merged content
', ) expect(content).toMatch(/Bold merged content<\/strong>/) }) })