import {test, expect} from '../../fixtures/test' // Multilingual Canvas deployments mix RTL (Arabic, Hebrew) and LTR text in // the same page. The BiDi algorithm handles display, but HTML attributes // (dir, lang) and / elements must survive round-trips so that // screen readers and browsers can apply correct directionality. test.describe('RTL and LTR mixed-direction content', () => { 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('RTL paragraph with LTR span — Latin text preserved', async ({page}) => { const content = await setAndGet( page, '

Arabic context with English term embedded.

', ) expect(content).toContain('English term') }) test(' for user-generated mixed direction — text preserved', async ({page}) => { const content = await setAndGet(page, '

Student name: John Smith — grade: A

') expect(content).toContain('John Smith') expect(content).toContain('grade: A') }) test('LTR paragraph containing RTL span — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

English intro text hello in Arabic continues in English.

', ) expect(content).toContain('English intro text') expect(content).toContain('continues in English') }) test('alternating dir paragraphs — all text preserved', async ({page}) => { const content = await setAndGet( page, '

First LTR paragraph.

Second RTL paragraph.

Third LTR paragraph.

', ) expect(content).toContain('First LTR paragraph') expect(content).toContain('Third LTR paragraph') }) test(' forcing direction — text preserved', async ({page}) => { const content = await setAndGet( page, '

Normal text followed by sdrawkcab then normal again.

', ) expect(content).toContain('sdrawkcab') expect(content).toContain('then normal again') }) test('table with RTL and LTR cells — all cell text preserved', async ({page}) => { const content = await setAndGet( page, '
English cellRTL cell content
', ) expect(content).toContain('English cell') expect(content).toContain('RTL cell content') }) })