presentation.spec.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // The editor stays mounted but hidden (d-none) after switching to view mode,
  36. // so its preview pane also contains a `.slides` deck. Scope to the visible
  37. // deck to avoid a strict-mode violation against the hidden editor preview.
  38. const viewSlides = page.locator('.slides').filter({ visible: true });
  39. // view mode must render the slide deck after save
  40. await page.getByTestId('view-button').click();
  41. await expect(viewSlides).toBeVisible();
  42. // reload exercises the SWR loading path where rendererOptions is briefly
  43. // undefined; the slide page must still render without crashing.
  44. await page.reload();
  45. await expect(viewSlides).toBeVisible();
  46. });