From 75c36ffd6c52318ec6e933486713a86492b4ee21 Mon Sep 17 00:00:00 2001 From: nowgnuesLee Date: Fri, 17 Jan 2025 14:26:48 +0900 Subject: [PATCH 1/3] feature: add e2e test for maintenance page --- e2e/maintenance.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 e2e/maintenance.test.ts diff --git a/e2e/maintenance.test.ts b/e2e/maintenance.test.ts new file mode 100644 index 000000000..b94e48679 --- /dev/null +++ b/e2e/maintenance.test.ts @@ -0,0 +1,7 @@ +import { loginAsAdmin } from './test-util'; +import test from '@playwright/test'; + +test.beforeAll(async ({ page }) => { + await loginAsAdmin(page); + await page.getByRole('menuitem', { name: '' }); +}); From 5c5c23fd90f05c967660f2c04dc1bd68ba13b492 Mon Sep 17 00:00:00 2001 From: nowgnuesLee Date: Thu, 23 Jan 2025 22:55:21 +0900 Subject: [PATCH 2/3] feature: enhance maintenance page tests with notification checks --- e2e/maintenance.test.ts | 43 ++++++++++++++++++++++++++++++++++++++--- e2e/test-util-antd.ts | 16 +++++++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/e2e/maintenance.test.ts b/e2e/maintenance.test.ts index b94e48679..880f7e571 100644 --- a/e2e/maintenance.test.ts +++ b/e2e/maintenance.test.ts @@ -1,7 +1,44 @@ import { loginAsAdmin } from './test-util'; -import test from '@playwright/test'; +import { + getNotificationDescriptionBox, + getNotificationMessageBox, +} from './test-util-antd'; +import { test, expect } from '@playwright/test'; -test.beforeAll(async ({ page }) => { +test.beforeEach(async ({ page }) => { await loginAsAdmin(page); - await page.getByRole('menuitem', { name: '' }); + await page.getByRole('menuitem', { name: 'Maintenance' }).click(); +}); + +test.describe('test maintenance page', () => { + test.describe('Recalculate Usage', () => { + test('click the Recalculate Usage button', async ({ page }) => { + await page.getByRole('button', { name: 'Recalculate Usage' }).click(); + + await expect(getNotificationMessageBox(page)).toContainText( + 'Recalculate Usage', + ); + // skip the Recalculating message because it's too fast + await expect(getNotificationDescriptionBox(page)).toContainText( + 'Recalculation finished', + ); + }); + }); + + test.describe('Rescan Images', () => { + test('click the Rescan Images button', async ({ page }) => { + await page.getByRole('button', { name: 'Rescan Images' }).click(); + + await expect(getNotificationMessageBox(page)).toContainText( + 'Rescan Images', + ); + + await expect(getNotificationDescriptionBox(page)).toContainText( + 'Rescanning...', + ); + await expect(getNotificationDescriptionBox(page)).toContainText( + 'Rescanning image finished.', + ); + }); + }); }); diff --git a/e2e/test-util-antd.ts b/e2e/test-util-antd.ts index c2973480b..b054e1efc 100644 --- a/e2e/test-util-antd.ts +++ b/e2e/test-util-antd.ts @@ -1,4 +1,4 @@ -import { Locator, expect } from '@playwright/test'; +import { Locator, Page, expect } from '@playwright/test'; export async function checkActiveTab( tabsLocator: Locator, @@ -9,7 +9,7 @@ export async function checkActiveTab( } export async function getTableHeaders(locator: Locator) { - return await locator.locator(".ant-table-thead th"); + return await locator.locator('.ant-table-thead th'); } export async function findColumnIndex( @@ -23,3 +23,15 @@ export async function findColumnIndex( return columnIndex; } + +export function getNotificationTextContainer(page: Page) { + return page.locator('.ant-notification-notice-description'); +} + +export function getNotificationMessageBox(page: Page) { + return getNotificationTextContainer(page).locator('li > div > div >> nth=0'); +} + +export function getNotificationDescriptionBox(page: Page) { + return getNotificationTextContainer(page).locator('li > div > div >> nth=1'); +} From dd6ab66dae395512f9a0dff3fc165ff5eee225eb Mon Sep 17 00:00:00 2001 From: nowgnuesLee Date: Wed, 5 Feb 2025 15:45:38 +0900 Subject: [PATCH 3/3] fix: add timeout to rescan image test --- e2e/maintenance.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2e/maintenance.test.ts b/e2e/maintenance.test.ts index 880f7e571..9ac9e499e 100644 --- a/e2e/maintenance.test.ts +++ b/e2e/maintenance.test.ts @@ -26,6 +26,7 @@ test.describe('test maintenance page', () => { }); test.describe('Rescan Images', () => { + test.setTimeout(90 * 1000); test('click the Rescan Images button', async ({ page }) => { await page.getByRole('button', { name: 'Rescan Images' }).click(); @@ -38,6 +39,9 @@ test.describe('test maintenance page', () => { ); await expect(getNotificationDescriptionBox(page)).toContainText( 'Rescanning image finished.', + { + timeout: 60 * 1000, + }, ); }); });