feat: e2e test improvement (#642)

* fix: fix new page login in e2e test
* test: add page-logic to simpliy new-page
* test: restore core test
This commit is contained in:
Chi Zhang 2022-12-31 02:03:48 +08:00 committed by GitHub
parent ddf3305bc1
commit 796d078a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 51 additions and 72 deletions

View File

@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { clickPageMoreActions } from './libs/page-logic';
loadPage();
test.describe('Change page mode(Paper or Edgeless)', () => {
@ -35,12 +35,8 @@ test.describe('Change page mode(Paper or Edgeless)', () => {
expect(await edgeless.isVisible()).toBe(true);
});
test.skip('Convert to edgeless by editor header items', async ({ page }) => {
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
test('Convert to edgeless by editor header items', async ({ page }) => {
await clickPageMoreActions(page);
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
await menusEdgelessItem.click();

11
tests/libs/page-logic.ts Normal file
View File

@ -0,0 +1,11 @@
export async function newPage(page) {
return page.getByTestId('sliderBar').getByText('New Page').click();
}
export async function clickPageMoreActions(page) {
return page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(1)
.click();
}

View File

@ -1,16 +1,16 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage } from './libs/page-logic';
loadPage();
test.describe('Local first delete page', () => {
test.skip('New a page , then delete it in all pages, permanently delete it', async ({
test('New a page , then delete it in all pages, permanently delete it', async ({
page,
}) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to restore');
const originPageUrl = page.url();
const newPageId = page.url().split('/').reverse()[0];
await page.getByRole('link', { name: 'All pages' }).click();
const cell = page.getByRole('cell', {

View File

@ -1,9 +1,9 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage, clickPageMoreActions } from './libs/page-logic';
loadPage();
test.describe.skip('Local first export page', () => {
test.describe('Local first export page', () => {
test('New a page ,then open it and export html', async ({ page }) => {
await page.getByText('New Page').click();
await page.getByPlaceholder('Title').click();
@ -18,11 +18,7 @@ test.describe.skip('Local first export page', () => {
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const exportParentBtn = page.getByRole('tooltip', {
name: 'Add to favourites Convert to Edgeless Export Delete',
});
@ -37,7 +33,7 @@ test.describe.skip('Local first export page', () => {
});
test('New a page ,then open it and export markdown', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page
.getByPlaceholder('Title')
@ -49,11 +45,7 @@ test.describe.skip('Local first export page', () => {
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const exportParentBtn = page.getByRole('tooltip', {
name: 'Add to favourites Convert to Edgeless Export Delete',
});

View File

@ -1,11 +1,11 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage, clickPageMoreActions } from './libs/page-logic';
loadPage();
test.describe.skip('Local first favorite and cancel favorite page', () => {
test.describe('Local first favorite and cancel favorite page', () => {
test('New a page and open it ,then favorite it', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
await page.getByRole('link', { name: 'All pages' }).click();
@ -15,16 +15,12 @@ test.describe.skip('Local first favorite and cancel favorite page', () => {
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
await favoriteBtn.click();
});
test('Cancel favorite', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
await page.getByRole('link', { name: 'All pages' }).click();
@ -34,11 +30,7 @@ test.describe.skip('Local first favorite and cancel favorite page', () => {
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
await favoriteBtn.click();

View File

@ -1,11 +1,11 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage, clickPageMoreActions } from './libs/page-logic';
loadPage();
test.describe.skip('Local first favorite items ui', () => {
test.describe('Local first favorite items ui', () => {
test('Show favorite items in sidebar', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
const newPageId = page.url().split('/').reverse()[0];
@ -15,11 +15,7 @@ test.describe.skip('Local first favorite items ui', () => {
});
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
await favoriteBtn.click();
@ -32,7 +28,7 @@ test.describe.skip('Local first favorite items ui', () => {
});
test('Show favorite items in favorite list', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
await page.getByRole('link', { name: 'All pages' }).click();
@ -41,11 +37,7 @@ test.describe.skip('Local first favorite items ui', () => {
});
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
await favoriteBtn.click();

View File

@ -1,18 +1,18 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage } from './libs/page-logic';
loadPage();
test.describe.skip('local first new page', () => {
test.describe('local first new page', () => {
test('click btn new page', async ({ page }) => {
const originPageId = page.url().split('/').reverse()[0];
await page.getByText('New Page').click();
await newPage(page);
const newPageId = page.url().split('/').reverse()[0];
expect(newPageId).not.toBe(originPageId);
});
test('click btn bew page and find it in all pages', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page');
await page.getByRole('link', { name: 'All pages' }).click();

View File

@ -1,11 +1,11 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage } from './libs/page-logic';
loadPage();
test.describe.skip('local first new page', () => {
test.describe('local first new page', () => {
test('click btn bew page and open in tab', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page');
const newPageUrl = page.url();

View File

@ -1,13 +1,13 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage } from './libs/page-logic';
loadPage();
test.describe('Local first delete page', () => {
test('New a page , then delete it in all pages, restore it', async ({
page,
}) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to restore');
const originPageUrl = page.url();

View File

@ -1,11 +1,11 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage, clickPageMoreActions } from './libs/page-logic';
loadPage();
test.describe.skip('Local first delete page', () => {
test.describe('Local first delete page', () => {
test('New a page ,then open it and show delete modal', async ({ page }) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to delete');
await page.getByRole('link', { name: 'All pages' }).click();
@ -15,11 +15,7 @@ test.describe.skip('Local first delete page', () => {
expect(cell).not.toBeUndefined();
await cell.click();
await page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(2)
.click();
await clickPageMoreActions(page);
const deleteBtn = page.getByTestId('editor-option-menu-delete');
await deleteBtn.click();
const confirmTip = page.getByText('Delete page?');
@ -29,7 +25,7 @@ test.describe.skip('Local first delete page', () => {
test('New a page ,then go to all pages and show delete modal', async ({
page,
}) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to delete');
const newPageId = page.url().split('/').reverse()[0];

View File

@ -1,13 +1,13 @@
import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage } from './libs/page-logic';
loadPage();
test.describe.skip('Local first trash page', () => {
test.describe('Local first trash page', () => {
test('New a page , then delete it in all pages, finally find it in trash', async ({
page,
}) => {
await page.getByText('New Page').click();
await newPage(page);
await page.getByPlaceholder('Title').click();
await page.getByPlaceholder('Title').fill('this is a new page to delete');
const newPageId = page.url().split('/').reverse()[0];