import {test, expect} from '../../fixtures/test' // Instructors frequently apply multiple formatting properties to the same text: // bold + italic, underline + color, strikethrough + superscript, etc. // TinyMCE must preserve all applied formats — a refactor must not cause formats // to cancel each other out during serialization. test.describe('combined inline formatting', () => { 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('bold + italic on same text preserves both', async ({page}) => { const content = await setAndGet(page, '

bold italic

') expect(content).toContain('bold italic') expect(content).toMatch(//) expect(content).toMatch(//) }) test('bold + underline on same text preserves both', async ({page}) => { const content = await setAndGet(page, '

bold underlined

') expect(content).toContain('bold underlined') expect(content).toMatch(//) }) test('italic + strikethrough on same text', async ({page}) => { const content = await setAndGet(page, '

struck italic

') expect(content).toContain('struck italic') expect(content).toMatch(//) }) test('bold + italic + underline triple combination', async ({page}) => { const content = await setAndGet(page, '

all three

') expect(content).toContain('all three') expect(content).toMatch(//) expect(content).toMatch(//) }) test('bold + color style combination', async ({page}) => { const content = await setAndGet( page, '

bold red

', ) expect(content).toContain('bold red') expect(content).toMatch(//) }) test('italic + background-color combination', async ({page}) => { const content = await setAndGet( page, '

italic highlight

', ) expect(content).toContain('italic highlight') expect(content).toMatch(//) }) test('superscript + bold combination', async ({page}) => { const content = await setAndGet(page, '

E = mc2

') expect(content).toContain('E = mc') expect(content).toMatch(//) expect(content).toContain('2') }) test('mixed formatted and plain text in same paragraph', async ({page}) => { const content = await setAndGet( page, '

plain bold plain italic plain underline end

', ) expect(content).toContain('plain') expect(content).toContain('bold') expect(content).toContain('italic') expect(content).toContain('underline') expect(content).toContain('end') expect(content).toMatch(/bold<\/strong>/) expect(content).toMatch(/italic<\/em>/) }) test('formatting does not bleed from one element to adjacent plain text', async ({page}) => { await page.evaluate(() => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent('

formatted unformatted

') }) // @ts-expect-error -- TinyMCE global const content = await page.evaluate(() => window.tinymce.activeEditor.getContent()) // "unformatted" must not be inside expect(content).not.toMatch(/[^<]*unformatted/) expect(content).toContain('unformatted') }) test('color + font-size + bold all together', async ({page}) => { const content = await setAndGet( page, '

styled bold

', ) expect(content).toContain('styled bold') expect(content).toMatch(//) }) })