import {test, expect} from '../../fixtures/test'
// Nested tables (a table inside a
) exist in legacy Canvas content
// authored before CSS layout was common. They are also generated by
// copy-paste from Word and email clients. All cell text must survive.
test.describe('nested tables (table inside table cell)', () => {
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('inner table text is preserved inside outer table cell', async ({page}) => {
const content = await setAndGet(
page,
'',
)
expect(content).toContain('Inner cell A')
expect(content).toContain('Inner cell B')
})
test('outer table cells alongside nested table all preserved', async ({page}) => {
const content = await setAndGet(
page,
'',
)
expect(content).toContain('Outer left')
expect(content).toContain('Nested')
expect(content).toContain('Outer right')
})
test('two-level deep nested table text is preserved', async ({page}) => {
const content = await setAndGet(
page,
'',
)
expect(content).toContain('Level 3')
})
test('nested table with headers preserved', async ({page}) => {
const content = await setAndGet(
page,
'',
)
expect(content).toContain('Nested Header')
expect(content).toContain('Nested Data')
})
test('nested table alongside a paragraph — both preserved', async ({page}) => {
const content = await setAndGet(
page,
' Intro text. Outro text. ',
)
expect(content).toContain('Intro text')
expect(content).toContain('Sub-table cell')
expect(content).toContain('Outro text')
})
})
|