From df28ab6dfb9f636206558266fa9a30fa74271742 Mon Sep 17 00:00:00 2001 From: tzhangchi Date: Tue, 27 Dec 2022 15:59:13 +0800 Subject: [PATCH] test: speed up favorites test --- tests/local-first-favorite-page.spec.ts | 57 +--------------------- tests/local-first-favorites-items.spec.ts | 58 +++++++++++++++++++++++ 2 files changed, 60 insertions(+), 55 deletions(-) create mode 100644 tests/local-first-favorites-items.spec.ts diff --git a/tests/local-first-favorite-page.spec.ts b/tests/local-first-favorite-page.spec.ts index e8a27cd752..aa95da1b89 100644 --- a/tests/local-first-favorite-page.spec.ts +++ b/tests/local-first-favorite-page.spec.ts @@ -3,8 +3,8 @@ import { loadPage } from './libs/load-page'; loadPage(); -test.describe('Local first favorite page', () => { - test('New a page and open it ,then favorite ot', async ({ 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 page.getByPlaceholder('Title').click(); await page.getByPlaceholder('Title').fill('this is a new page to favorite'); @@ -23,59 +23,6 @@ test.describe('Local first favorite page', () => { const favoriteBtn = page.getByTestId('editor-option-menu-favorite'); await favoriteBtn.click(); }); - - test('Show favorite items in sidebar', async ({ page }) => { - await page.getByText('New Page').click(); - await page.getByPlaceholder('Title').click(); - await page.getByPlaceholder('Title').fill('this is a new page to favorite'); - const newPageId = page.url().split('/').reverse()[0]; - await page.getByRole('link', { name: 'All pages' }).click(); - const cell = page.getByRole('cell', { - name: 'this is a new page to favorite', - }); - expect(cell).not.toBeUndefined(); - await cell.click(); - await page - .getByTestId('editor-header-items') - .getByRole('button') - .nth(2) - .click(); - - const favoriteBtn = page.getByTestId('editor-option-menu-favorite'); - await favoriteBtn.click(); - const favoriteListItemInSidebar = page.getByTestId( - 'favorite-list-item-' + newPageId - ); - expect(await favoriteListItemInSidebar.textContent()).toBe( - 'this is a new page to favorite' - ); - }); - - test('Show favorite items in favorite list', async ({ page }) => { - await page.getByText('New Page').click(); - 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(); - const cell = page.getByRole('cell', { - name: 'this is a new page to favorite', - }); - expect(cell).not.toBeUndefined(); - await cell.click(); - await page - .getByTestId('editor-header-items') - .getByRole('button') - .nth(2) - .click(); - - const favoriteBtn = page.getByTestId('editor-option-menu-favorite'); - await favoriteBtn.click(); - - await page.getByRole('link', { name: 'Favourites' }).click(); - expect( - page.getByRole('cell', { name: 'this is a new page to favorite' }) - ).not.toBeUndefined(); - }); - test('Cancel favorite', async ({ page }) => { await page.getByText('New Page').click(); await page.getByPlaceholder('Title').click(); diff --git a/tests/local-first-favorites-items.spec.ts b/tests/local-first-favorites-items.spec.ts new file mode 100644 index 0000000000..68e6fbb5ad --- /dev/null +++ b/tests/local-first-favorites-items.spec.ts @@ -0,0 +1,58 @@ +import { test, expect } from '@playwright/test'; +import { loadPage } from './libs/load-page'; + +loadPage(); + +test.describe('Local first favorite items ui', () => { + test('Show favorite items in sidebar', async ({ page }) => { + await page.getByText('New Page').click(); + await page.getByPlaceholder('Title').click(); + await page.getByPlaceholder('Title').fill('this is a new page to favorite'); + const newPageId = page.url().split('/').reverse()[0]; + await page.getByRole('link', { name: 'All pages' }).click(); + const cell = page.getByRole('cell', { + name: 'this is a new page to favorite', + }); + expect(cell).not.toBeUndefined(); + await cell.click(); + await page + .getByTestId('editor-header-items') + .getByRole('button') + .nth(2) + .click(); + + const favoriteBtn = page.getByTestId('editor-option-menu-favorite'); + await favoriteBtn.click(); + const favoriteListItemInSidebar = page.getByTestId( + 'favorite-list-item-' + newPageId + ); + expect(await favoriteListItemInSidebar.textContent()).toBe( + 'this is a new page to favorite' + ); + }); + + test('Show favorite items in favorite list', async ({ page }) => { + await page.getByText('New Page').click(); + 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(); + const cell = page.getByRole('cell', { + name: 'this is a new page to favorite', + }); + expect(cell).not.toBeUndefined(); + await cell.click(); + await page + .getByTestId('editor-header-items') + .getByRole('button') + .nth(2) + .click(); + + const favoriteBtn = page.getByTestId('editor-option-menu-favorite'); + await favoriteBtn.click(); + + await page.getByRole('link', { name: 'Favourites' }).click(); + expect( + page.getByRole('cell', { name: 'this is a new page to favorite' }) + ).not.toBeUndefined(); + }); +});