import {test, expect} from '../../fixtures/test' // Canvas renders math equations using MathJax with specific span patterns. // The `data-equation-content` attribute carries the LaTeX source. The // `class="equation_image"` img element displays the rendered equation. // Instructors copy these from Canvas's equation editor and expect them preserved. test.describe('Canvas math equation patterns', () => { 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('data-equation-content attribute — attribute present in output', async ({page}) => { const content = await setAndGet( page, '

Area formula: A = πr²

', ) expect(content).toContain('Area formula') }) test('Canvas equation image with class — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

The quadratic formula: x = frac{-b pm sqrt{b^2-4ac}}{2a} solves ax²+bx+c=0.

', ) expect(content).toContain('quadratic formula') expect(content).toContain('solves') }) test('LaTeX in data attribute with special chars — text preserved', async ({page}) => { const content = await setAndGet( page, '

Summation: ∑

', ) expect(content).toContain('Summation') }) test('multiple equations in a paragraph — all text preserved', async ({page}) => { const content = await setAndGet( page, '

Given f(x) and g(x), find the intersection.

', ) expect(content).toContain('find the intersection') }) test('equation inside a table cell — text preserved', async ({page}) => { const content = await setAndGet( page, '
FormulaE = mc²
', ) expect(content).toContain('Formula') }) })