import {test, expect} from '../../fixtures/test' // Idempotency: calling setContent(getContent()) must produce stable output. // If each round-trip mutates the HTML (adds extra tags, changes attributes, // double-encodes entities), then saving a page multiple times in Canvas will // corrupt content. A refactor must not break this property. test.describe('setContent idempotency — stable on repeated round-trips', () => { test.beforeEach(async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() }) async function roundTrip(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('plain paragraph is stable after two round-trips', async ({page}) => { const first = await roundTrip(page, '

Hello world

') const second = await roundTrip(page, first) expect(second).toBe(first) }) test('bold text is stable after two round-trips', async ({page}) => { const first = await roundTrip(page, '

Bold text normal

') const second = await roundTrip(page, first) expect(second).toBe(first) }) test('table with headers is stable after two round-trips', async ({page}) => { const first = await roundTrip( page, '
Col ACol B
12
', ) const second = await roundTrip(page, first) expect(second).toBe(first) }) test('ordered list is stable after two round-trips', async ({page}) => { const first = await roundTrip( page, '
  1. First item
  2. Second item
  3. Third item
', ) const second = await roundTrip(page, first) expect(second).toBe(first) }) test('heading with id is stable after two round-trips', async ({page}) => { const first = await roundTrip(page, '

Introduction

Opening.

') const second = await roundTrip(page, first) expect(second).toBe(first) }) test('link with rel attributes is stable after two round-trips', async ({page}) => { const first = await roundTrip( page, '

Link text

', ) const second = await roundTrip(page, first) expect(second).toBe(first) }) test('blockquote with nested paragraph is stable', async ({page}) => { const first = await roundTrip(page, '

Quoted paragraph text.

') const second = await roundTrip(page, first) expect(second).toBe(first) }) })