diff --git a/e2e/maintenance.test.ts b/e2e/maintenance.test.ts new file mode 100644 index 000000000..9ac9e499e --- /dev/null +++ b/e2e/maintenance.test.ts @@ -0,0 +1,48 @@ +import { loginAsAdmin } from './test-util'; +import { + getNotificationDescriptionBox, + getNotificationMessageBox, +} from './test-util-antd'; +import { test, expect } from '@playwright/test'; + +test.beforeEach(async ({ page }) => { + await loginAsAdmin(page); + 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.setTimeout(90 * 1000); + 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.', + { + timeout: 60 * 1000, + }, + ); + }); + }); +}); 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'); +}