Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(FR-393): add e2e test for maintenance page #3074

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions e2e/maintenance.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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('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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rescan process can take longer than the default test timeout of 5 seconds, so this test can easily fail.

image.png

'Rescanning image finished.',
);
});
});
});
16 changes: 14 additions & 2 deletions e2e/test-util-antd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Locator, expect } from '@playwright/test';
import { Locator, Page, expect } from '@playwright/test';

export async function checkActiveTab(
tabsLocator: Locator,
Expand All @@ -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(
Expand All @@ -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');
}
Loading