headings.spec.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { expect } from '@playwright/test'
  2. import { test } from './fixtures'
  3. import { createRandomPage, editFirstBlock, newInnerBlock } from './utils'
  4. test('set heading to 1', async ({ page }) => {
  5. await createRandomPage(page)
  6. await page.type('textarea >> nth=0', 'foo')
  7. await page.keyboard.press('Escape', { delay: 50 })
  8. await page.locator('span.bullet-container >> nth=0').click({button: "right"})
  9. await page.locator('#custom-context-menu .to-heading-button[title="Heading 1"]').click()
  10. await editFirstBlock(page)
  11. await page.waitForTimeout(500)
  12. expect(await page.inputValue('textarea >> nth=0')).toBe('# foo')
  13. await page.keyboard.press('Escape', { delay: 50 })
  14. expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('<h1>foo</h1>')
  15. })
  16. test('remove heading', async ({ page }) => {
  17. await page.locator('span.bullet-container >> nth=0').click({button: "right"})
  18. await page.locator('#custom-context-menu .to-heading-button[title="Remove heading"]').click()
  19. expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('foo')
  20. })
  21. test('set heading to 2', async ({ page }) => {
  22. await page.locator('span.bullet-container >> nth=0').click({button: "right"})
  23. await page.locator('#custom-context-menu .to-heading-button[title="Heading 2"]').click({ delay: 400})
  24. expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('<h2>foo</h2>')
  25. })
  26. test('switch to auto heading', async ({ page }) => {
  27. await page.locator('span.bullet-container >> nth=0').click({button: "right"})
  28. await page.locator('#custom-context-menu .to-heading-button[title="Auto heading"]').click()
  29. await editFirstBlock(page)
  30. await page.waitForTimeout(500)
  31. expect(await page.inputValue('textarea >> nth=0')).toBe('foo')
  32. await page.keyboard.press('Escape', { delay: 50 })
  33. expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('<h1>foo</h1>')
  34. })
  35. test('set heading of nested block to auto', async ({ page }) => {
  36. await newInnerBlock(page)
  37. await page.waitForTimeout(500)
  38. await page.type('textarea >> nth=0', 'bar')
  39. await page.keyboard.press("Tab", { delay: 100 })
  40. await page.keyboard.press('Escape', { delay: 100 })
  41. await page.locator('span.bullet-container >> nth=1').click({button: "right"})
  42. await page.locator('#custom-context-menu .to-heading-button[title="Auto heading"]').click()
  43. await page.waitForTimeout(100)
  44. expect(await page.locator('.ls-block .block-content >> nth=1').innerHTML()).toContain('<h2>bar</h2>')
  45. })
  46. test('view nested block on a dedicated page', async ({ page }) => {
  47. await page.locator('span.bullet-container >> nth=1').click()
  48. await page.waitForTimeout(200)
  49. expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('<h1>bar</h1>')
  50. })