import {test, expect} from '../../fixtures/test' //
 preserves whitespace exactly — tabs, multiple spaces, and newlines
// must not be collapsed. This is essential for code indentation in CS courses.
// A TinyMCE or serializer update that collapses whitespace inside 
 would
// silently corrupt all code examples that rely on indentation.
test.describe('whitespace preservation inside 
 blocks', () => {
  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 spaces inside 
 are preserved', async ({page}) => {
    const content = await setAndGet(page, '
function f() {\n    return 42;\n}
') expect(content).toContain('function f') expect(content).toContain('return 42') }) test('tab-indented code in
 — text preserved', async ({page}) => {
    const content = await setAndGet(
      page,
      '
if (x) {\n\tdo_something();\n\treturn true;\n}
', ) expect(content).toContain('do_something') expect(content).toContain('return true') }) test('leading spaces on each line preserved in
', async ({page}) => {
    const content = await setAndGet(
      page,
      '
line1\n  line2 indented\n    line3 double indent
', ) expect(content).toContain('line1') expect(content).toContain('line2 indented') expect(content).toContain('line3 double indent') }) test('blank lines inside
 preserved', async ({page}) => {
    const content = await setAndGet(page, '
Block A\n\nBlock B after blank line
') expect(content).toContain('Block A') expect(content).toContain('Block B after blank line') }) test('
 with long lines — all text present', async ({page}) => {
    const longLine = 'x'.repeat(200)
    const content = await setAndGet(page, `
${longLine}
`) expect(content).toContain('x'.repeat(50)) }) test('multiple
 blocks each preserve their own whitespace', async ({page}) => {
    const content = await setAndGet(
      page,
      '
first_block()\n  indented
second_block()\n  also_indented
', ) expect(content).toContain('first_block') expect(content).toContain('second_block') expect(content).toContain('indented') expect(content).toContain('also_indented') }) })