headings.spec.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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()
  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")
  40. await page.keyboard.press('Escape', { delay: 50 })
  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. expect(await page.locator('.ls-block .block-content >> nth=1').innerHTML()).toContain('<h3>bar</h3>')
  44. })
  45. test('view nested block on a dedicated page', async ({ page }) => {
  46. await page.locator('span.bullet-container >> nth=1').click()
  47. await page.waitForTimeout(200)
  48. expect(await page.locator('.ls-block .block-content >> nth=0').innerHTML()).toContain('<h1>bar</h1>')
  49. })