| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- import { expect, test } from '@playwright/test';
- import { appendTextToEditorUntilContains } from '../utils/AppendTextToEditorUntilContains';
- test('has title', async ({ page }) => {
- await page.goto('/Sandbox');
- // Expect a title "to contain" a substring.
- await expect(page).toHaveTitle(/Sandbox/);
- });
- test('get h1', async ({ page }) => {
- await page.goto('/Sandbox');
- // Expects page to have a heading with the name of Installation.
- await expect(
- page.getByRole('heading').filter({ hasText: /\/Sandbox/ }),
- ).toBeVisible();
- });
- test('/Sandbox/Math is successfully loaded', async ({ page }) => {
- await page.goto('/Sandbox/Math');
- // Expect the Math-specific elements to be present
- await expect(page.locator('.katex').first()).toBeVisible();
- });
- test('Sandbox with edit is successfully loaded', async ({ page }) => {
- await page.goto('/Sandbox#edit');
- // Expect the Editor-specific elements to be present
- await expect(page.getByTestId('grw-editor-navbar-bottom')).toBeVisible();
- await expect(page.getByTestId('save-page-btn')).toBeVisible();
- await expect(page.getByTestId('grw-grant-selector')).toBeVisible();
- });
- test.describe
- .serial('PageEditor', () => {
- const body1 = 'hello';
- const body2 = ' world!';
- const targetPath = '/Sandbox/testForUseEditingMarkdown';
- test('Edit and save with save-page-btn', async ({ page }) => {
- await page.goto(targetPath);
- await page.getByTestId('editor-button').click();
- await appendTextToEditorUntilContains(page, body1);
- await page.getByTestId('save-page-btn').click();
- await expect(page.locator('.wiki').first()).toContainText(body1);
- });
- test('Edit and save with shortcut key', async ({ page }) => {
- const savePageShortcutKey = 'Control+s';
- await page.goto(targetPath);
- await page.getByTestId('editor-button').click();
- await expect(page.locator('.cm-content')).toContainText(body1);
- await expect(page.getByTestId('page-editor-preview-body')).toContainText(
- body1,
- );
- await appendTextToEditorUntilContains(page, body1 + body2);
- await page.keyboard.press(savePageShortcutKey);
- await page.getByTestId('view-button').click();
- await expect(page.locator('.wiki').first()).toContainText(body1 + body2);
- });
- });
- test('Access to /me page', async ({ page }) => {
- await page.goto('/me');
- // Expect the UserSettgins-specific elements to be present when accessing /me (UserSettgins)
- await expect(page.getByTestId('grw-user-settings')).toBeVisible();
- });
- test('All In-App Notification list is successfully loaded', async ({
- page,
- }) => {
- await page.goto('/me/all-in-app-notifications');
- // Expect the In-App Notification-specific elements to be present when accessing /me/all-in-app-notifications
- await expect(page.getByTestId('grw-in-app-notification-page')).toBeVisible();
- });
- test('/trash is successfully loaded', async ({ page }) => {
- await page.goto('/trash');
- await expect(page.getByTestId('trash-page-list')).toContainText(
- 'There are no pages under this page.',
- );
- });
- test('/tags is successfully loaded', async ({ page }) => {
- await page.goto('/tags');
- await expect(page.getByTestId('grw-tags-list')).toContainText(
- 'You have no tag, You can set tags on pages',
- );
- });
- test.describe
- .serial('Access to Template Editing Mode', () => {
- const templateBody1 = 'Template for children';
- const templateBody2 = 'Template for descendants';
- test('Successfully created template for children', async ({ page }) => {
- await page.goto('/Sandbox');
- await expect(page.getByTestId('grw-contextual-sub-nav')).toBeVisible();
- await page
- .getByTestId('grw-contextual-sub-nav')
- .getByTestId('open-page-item-control-btn')
- .click();
- await page.getByTestId('open-page-template-modal-btn').click();
- expect(page.getByTestId('page-template-modal')).toBeVisible();
- await page.getByTestId('template-button-children').click();
- await appendTextToEditorUntilContains(page, templateBody1);
- await page.getByTestId('save-page-btn').click();
- await expect(page.locator('.wiki').first()).toContainText(templateBody1);
- });
- test('Template is applied to pages created (template for children)', async ({
- page,
- }) => {
- await page.goto('/Sandbox');
- await page.getByTestId('grw-page-create-button').click();
- await expect(page.locator('.cm-content')).toContainText(templateBody1);
- await expect(page.getByTestId('page-editor-preview-body')).toContainText(
- templateBody1,
- );
- });
- test('Successfully created template for descendants', async ({ page }) => {
- await page.goto('/Sandbox');
- await expect(page.getByTestId('grw-contextual-sub-nav')).toBeVisible();
- await page
- .getByTestId('grw-contextual-sub-nav')
- .getByTestId('open-page-item-control-btn')
- .click();
- await page.getByTestId('open-page-template-modal-btn').click();
- expect(page.getByTestId('page-template-modal')).toBeVisible();
- await page.getByTestId('template-button-descendants').click();
- await appendTextToEditorUntilContains(page, templateBody2);
- await page.getByTestId('save-page-btn').click();
- await expect(page.locator('.wiki').first()).toContainText(templateBody2);
- });
- test('Template is applied to pages created (template for descendants)', async ({
- page,
- }) => {
- await page.goto('/Sandbox/Bootstrap5');
- await page.getByTestId('grw-page-create-button').click();
- await expect(page.locator('.cm-content')).toContainText(templateBody2);
- await expect(page.getByTestId('page-editor-preview-body')).toContainText(
- templateBody2,
- );
- });
- });
|