import {test, expect} from '../../fixtures/test' // TinyMCE's getContent() accepts a format option: 'html' (default) or 'raw'. // Raw format returns the editor's internal representation without serialization // filtering. Understanding both formats is critical for refactoring because // the Canvas save flow uses a specific format — changing it can corrupt content. test.describe('getContent format options', () => { test.beforeEach(async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() }) test('default html format contains text', async ({page}) => { const content = await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('

HTML format text

') // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent({format: 'html'}) }) expect(content).toContain('HTML format text') }) test('raw format returns non-empty string with text', async ({page}) => { const content = await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('

Raw format text

') // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent({format: 'raw'}) }) expect(typeof content).toBe('string') expect(content).toContain('Raw format text') }) test('text format strips all tags', async ({page}) => { const content = await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('

Bold and italic

') // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent({format: 'text'}) }) expect(content).toContain('Bold') expect(content).toContain('italic') expect(content).not.toContain('') expect(content).not.toContain('') }) test('html format applies serialization (b→strong)', async ({page}) => { const content = await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('

Bold text

') // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent({format: 'html'}) }) expect(content).toContain('Bold text') }) test('getContent without options defaults to html format', async ({page}) => { const [withOption, withoutOption] = await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('

Same content

') return [ // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.getContent({format: 'html'}), // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.getContent(), ] }) expect(withoutOption).toBe(withOption) }) test('text format of a table returns cell text without tags', async ({page}) => { const content = await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('
AlphaBeta
') // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent({format: 'text'}) }) expect(content).toContain('Alpha') expect(content).toContain('Beta') expect(content).not.toContain('') }) })