import {test, expect} from '../../fixtures/test' // Canvas quiz questions are stored as HTML in the RCE. Multiple choice // questions use
    with
  1. for each answer choice. The question stem // may include images, code blocks, math, and formatted text. // All content must survive the round-trip to be gradeable. test.describe('quiz question content 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('multiple choice question — stem and all choices preserved', async ({page}) => { const content = await setAndGet( page, `

    What is the time complexity of binary search?

    1. O(n)
    2. O(log n)
    3. O(n²)
    4. O(1)
    `, ) expect(content).toContain('time complexity of binary search') expect(content).toContain('O(n)') expect(content).toContain('O(log n)') expect(content).toContain('O(n') // ² encoded as ² by TinyMCE }) test('true/false question — both options preserved', async ({page}) => { const content = await setAndGet( page, `

    True or False: A linked list has O(1) random access.

    • True
    • False
    `, ) expect(content).toContain('linked list has O(1) random access') expect(content).toContain('True') expect(content).toContain('False') }) test('code question with pre block — code preserved', async ({page}) => { const content = await setAndGet( page, `

    What does this function return when called with f(5)?

    def f(n):
        if n <= 1:
            return 1
        return n * f(n - 1)

    Enter the numeric answer:

    `, ) expect(content).toContain('What does this function return') expect(content).toContain('def f(n)') expect(content).toContain('return 1') expect(content).toContain('Enter the numeric answer') }) test('matching question with two columns', async ({page}) => { const content = await setAndGet( page, `

    Match each data structure to its average search time:

    StructureTime
    ArrayO(n)
    Hash tableO(1)
    BSTO(log n)
    `, ) expect(content).toContain('Match each data structure') expect(content).toContain('Hash table') expect(content).toContain('O(1)') expect(content).toContain('BST') }) })