test: fix e2e (#4390)

This commit is contained in:
Alex Yang
2023-09-16 20:50:26 -07:00
committed by GitHub
parent bebe69d483
commit 40e094dcdd
5 changed files with 13 additions and 7 deletions
@@ -24,7 +24,7 @@ export const NotFoundPage = ({
const t = useAFFiNEI18N(); const t = useAFFiNEI18N();
return ( return (
<div className={notFoundPageContainer}> <div className={notFoundPageContainer} data-testid="not-found">
<div> <div>
<div className={wrapper}> <div className={wrapper}>
<NotFoundPattern /> <NotFoundPattern />
@@ -3,6 +3,6 @@ import { expect } from '@playwright/test';
test('visit 404 page', async ({ page }) => { test('visit 404 page', async ({ page }) => {
await page.goto('http://localhost:8080/404'); await page.goto('http://localhost:8080/404');
const notFoundTip = page.locator('[data-testid=notFound]'); const notFoundTip = page.getByTestId('not-found');
await expect(notFoundTip).toBeVisible(); await expect(notFoundTip).toBeVisible();
}); });
@@ -21,7 +21,9 @@ test('should create a page with a local first avatar and remove it', async ({
.getByTestId('create-workspace-input') .getByTestId('create-workspace-input')
.type('Test Workspace 1', { delay: 50 }); .type('Test Workspace 1', { delay: 50 });
await page.getByTestId('create-workspace-create-button').click(); await page.getByTestId('create-workspace-create-button').click();
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click({
delay: 50,
});
await page.getByTestId('workspace-card').nth(1).click(); await page.getByTestId('workspace-card').nth(1).click();
await page.getByTestId('settings-modal-trigger').click(); await page.getByTestId('settings-modal-trigger').click();
await page.getByTestId('current-workspace-label').click(); await page.getByTestId('current-workspace-label').click();
@@ -29,10 +31,14 @@ test('should create a page with a local first avatar and remove it', async ({
.getByTestId('upload-avatar') .getByTestId('upload-avatar')
.setInputFiles(resolve(rootDir, 'tests', 'fixtures', 'smile.png')); .setInputFiles(resolve(rootDir, 'tests', 'fixtures', 'smile.png'));
await page.mouse.click(0, 0); await page.mouse.click(0, 0);
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click({
delay: 50,
});
await page.getByTestId('workspace-card').nth(0).click(); await page.getByTestId('workspace-card').nth(0).click();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click({
delay: 50,
});
await page.getByTestId('workspace-card').nth(1).click(); await page.getByTestId('workspace-card').nth(1).click();
const blobUrl = await page const blobUrl = await page
.getByTestId('workspace-avatar') .getByTestId('workspace-avatar')
+1 -1
View File
@@ -137,7 +137,7 @@ test('Navigate to the 404 page and try to open quick search', async ({
page, page,
}) => { }) => {
await page.goto('http://localhost:8080/404'); await page.goto('http://localhost:8080/404');
const notFoundTip = page.locator('[data-testid=notFound]'); const notFoundTip = page.getByTestId('not-found');
await expect(notFoundTip).toBeVisible(); await expect(notFoundTip).toBeVisible();
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const quickSearch = page.locator('[data-testid=quickSearch]'); const quickSearch = page.locator('[data-testid=quickSearch]');
+1 -1
View File
@@ -9,7 +9,7 @@ test('goto not found page', async ({ page }) => {
const currentUrl = page.url(); const currentUrl = page.url();
const invalidUrl = currentUrl.replace('hello-world', 'invalid'); const invalidUrl = currentUrl.replace('hello-world', 'invalid');
await page.goto(invalidUrl); await page.goto(invalidUrl);
await expect(page.getByTestId('notFound')).toBeVisible(); await expect(page.getByTestId('not-found')).toBeVisible();
}); });
test('goto not found workspace', async ({ page }) => { test('goto not found workspace', async ({ page }) => {