presentation.spec.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { expect, test } from '@playwright/test';
  2. test('Presentation', async ({ page }) => {
  3. await page.goto('/');
  4. // show presentation modal
  5. await page
  6. .getByTestId('grw-contextual-sub-nav')
  7. .getByTestId('open-page-item-control-btn')
  8. .click();
  9. await page.getByTestId('open-presentation-modal-btn').click();
  10. // check the content of the h1
  11. await expect(
  12. page.getByRole('application').getByRole('heading', { level: 1 }),
  13. ).toHaveText(/Welcome to GROWI/);
  14. });
  15. test('Slide page (slide: true frontmatter) renders without crashing', async ({
  16. page,
  17. }) => {
  18. await page.goto('/Sandbox/slide-test');
  19. // open the editor
  20. await page.getByTestId('editor-button').click();
  21. await expect(page.getByTestId('grw-editor-navbar-bottom')).toBeVisible();
  22. // fill the editor with slide content
  23. await page
  24. .locator('.cm-content')
  25. .fill('---\nslide: true\n---\n# Slide 1\n---\n# Slide 2');
  26. // The editor preview must finish rendering both slides through the marpit
  27. // pipeline before saving — this is the slide-mode observable contract and
  28. // also proves the preview did not crash on slide content.
  29. const previewSlides = page
  30. .getByTestId('page-editor-preview-body')
  31. .locator('svg[data-marpit-svg]');
  32. await expect(previewSlides).toHaveCount(2);
  33. // save
  34. await page.keyboard.press('Control+s');
  35. // view mode must render the slide deck after save
  36. await page.getByTestId('view-button').click();
  37. await expect(page.locator('.slides')).toBeVisible();
  38. // reload exercises the SWR loading path where rendererOptions is briefly
  39. // undefined; the slide page must still render without crashing.
  40. await page.reload();
  41. await expect(page.locator('.slides')).toBeVisible();
  42. });