Repository: payloadcms/payload
File: test/lexical/collections/_LexicalFullyFeatured/e2e.spec.ts (TypeScript)

Code before:
    await expect(
      codeBlock.locator('.payload-richtext-code-block__language-selector-button'),
    ).toHaveAttribute('data-selected-language', 'ts')

    // Ensure it does not contain payload types
    await codeBlock.locator('.monaco-editor .view-line').first().click()
    await page.keyboard.type("import { APIError } from 'payload'")
    await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(0)
  })

  test('ensure payload code block can be created using slash commands and it contains payload types', async ({
    page,
  }) => {
    await lexical.slashCommand('payloadcode')
    const codeBlock = lexical.editor.locator('.LexicalEditorTheme__block-PayloadCode')
    await expect(codeBlock).toHaveCount(1)
    await expect(codeBlock).toBeVisible()

    await expect(codeBlock.locator('.monaco-editor')).toBeVisible()
    await expect(
      codeBlock.locator('.payload-richtext-code-block__language-selector-button'),
    ).toHaveAttribute('data-selected-language', 'ts')

    // Ensure it contains payload types
    await codeBlock.locator('.monaco-editor .view-line').first().click()
    await page.keyboard.type("import { APIError } from 'payload'")
    await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(1)
  })

  test('copy pasting a inline block within range selection should not duplicate the inline block id', async ({
    page,
  }) => {
    await page.keyboard.type('Hello ')
    await lexical.slashCommand('inline')
    await lexical.drawer.locator('input').first().fill('World')
    await lexical.drawer.getByText('Save changes').click()
    await expect(lexical.drawer).toBeHidden()
    const inlineBlock = lexical.editor.locator('.LexicalEditorTheme__inlineBlock')
    await expect(inlineBlock).toHaveCount(1)

    await page.keyboard.press('ControlOrMeta+A')
    await page.keyboard.press('ControlOrMeta+C')
    // needed for some reason
    // eslint-disable-next-line playwright/no-wait-for-timeout
    await page.waitForTimeout(1000)
    await page.keyboard.press('ArrowRight')
    await page.keyboard.press('ControlOrMeta+V')
    await expect(inlineBlock).toHaveCount(2)
    await inlineBlock.nth(1).locator('button').first().click()
    await expect(lexical.drawer).toBeVisible()
    await expect(lexical.drawer.locator('input').first()).toHaveValue('World')

Review comment (suggestion):
Actually, I think you need to change this to actually be erroring code. Like try to import something that does not exist

Code after:
    await expect(
      codeBlock.locator('.payload-richtext-code-block__language-selector-button'),
    ).toHaveAttribute('data-selected-language', 'typescript')

    // Ensure it does not contain payload types
    await codeBlock.locator('.monaco-editor .view-line').first().click()
    await page.keyboard.type("import { APIError } from 'payload'")
    await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(0)
  })

  test('ensure payload code block can be created using slash commands and it contains payload types', async ({
    page,
  }) => {
    await lexical.slashCommand('payloadcode')
    const codeBlock = lexical.editor.locator('.LexicalEditorTheme__block-PayloadCode')
    await expect(codeBlock).toHaveCount(1)
    await expect(codeBlock).toBeVisible()

    await expect(codeBlock.locator('.monaco-editor')).toBeVisible()
    await expect(
      codeBlock.locator('.payload-richtext-code-block__language-selector-button'),
    ).toHaveAttribute('data-selected-language', 'ts')

    // Ensure it contains payload types
    await codeBlock.locator('.monaco-editor .view-line').first().click()
    await page.keyboard.type("import { APIError } from 'payload'")
    await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(0)

    await page.keyboard.press('Enter')
    await page.keyboard.type("import { DoesNotExist } from 'payload'")
    await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(1)
  })

  test('copy pasting a inline block within range selection should not duplicate the inline block id', async ({
    page,
  }) => {
    await page.keyboard.type('Hello ')
    await lexical.slashCommand('inline')
    await lexical.drawer.locator('input').first().fill('World')
    await lexical.drawer.getByText('Save changes').click()
    await expect(lexical.drawer).toBeHidden()
    const inlineBlock = lexical.editor.locator('.LexicalEditorTheme__inlineBlock')
    await expect(inlineBlock).toHaveCount(1)

    await page.keyboard.press('ControlOrMeta+A')
    await page.keyboard.press('ControlOrMeta+C')
    // needed for some reason
    // eslint-disable-next-line playwright/no-wait-for-timeout
    await page.waitForTimeout(1000)
    await page.keyboard.press('ArrowRight')
    await page.keyboard.press('ControlOrMeta+V')