saving.spec.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { expect, test } from '@playwright/test';
  2. import path from 'path';
  3. import { appendTextToEditorUntilContains } from '../utils/AppendTextToEditorUntilContains';
  4. test('Successfully create page under specific path', async ({ page }) => {
  5. const newPagePath = '/child';
  6. const openPageCreateModalShortcutKey = 'c';
  7. await page.goto('/Sandbox');
  8. await expect(async () => {
  9. await page.keyboard.press(openPageCreateModalShortcutKey);
  10. await expect(page.getByTestId('page-create-modal')).toBeVisible({
  11. timeout: 1000,
  12. });
  13. }).toPass();
  14. page
  15. .getByTestId('page-create-modal')
  16. .locator('.rbt-input-main')
  17. .fill(newPagePath);
  18. page.getByTestId('btn-create-page-under-below').click();
  19. await page.getByTestId('view-button').click();
  20. const createdPageId = path.basename(page.url());
  21. expect(createdPageId.length).toBe(24);
  22. });
  23. test('Successfully updating a page using a shortcut on a previously created page', async ({
  24. page,
  25. }) => {
  26. const body1 = 'hello';
  27. const body2 = ' world!';
  28. const savePageShortcutKey = 'Control+s';
  29. await page.goto('/Sandbox/child');
  30. // 1st
  31. await page.getByTestId('editor-button').click();
  32. await expect(page.getByTestId('grw-editor-navbar-bottom')).toBeVisible();
  33. await appendTextToEditorUntilContains(page, body1);
  34. await page.keyboard.press(savePageShortcutKey);
  35. await page.getByTestId('view-button').click();
  36. await expect(page.locator('.main')).toContainText(body1);
  37. // 2nd
  38. await page.getByTestId('editor-button').click();
  39. await expect(page.getByTestId('grw-editor-navbar-bottom')).toBeVisible();
  40. await appendTextToEditorUntilContains(page, body1 + body2);
  41. await page.keyboard.press(savePageShortcutKey);
  42. await page.getByTestId('view-button').click();
  43. await expect(page.locator('.main')).toContainText(body1 + body2);
  44. });