chore(e2e): make e2e more stable

This commit is contained in:
Zeke Zhang 2024-10-27 10:20:47 +08:00
parent a03f459177
commit 0dc49d32e4
3 changed files with 19 additions and 13 deletions

View File

@ -19,10 +19,13 @@ test.describe('auth', () => {
});
test('register', async ({ page }) => {
// Generate a random username
const username = `zidonghuaceshi${Math.random().toString(36).substring(2, 15)}`;
await page.goto('/');
await page.getByRole('link', { name: 'Create an account' }).click();
await page.getByPlaceholder('Username').click();
await page.getByPlaceholder('Username').fill('zidonghuaceshi');
await page.getByPlaceholder('Username').fill(username);
await page.getByPlaceholder('Password', { exact: true }).click();
await page.getByPlaceholder('Password', { exact: true }).fill('zidonghuaceshi123');
await page.getByPlaceholder('Confirm password').click();
@ -31,14 +34,14 @@ test.describe('auth', () => {
await expect(page.getByText('Sign up successfully, and automatically jump to the sign in page')).toBeVisible();
// 用新账户登录
// Sign in with the new account
await page.getByPlaceholder('Username/Email').click();
await page.getByPlaceholder('Username/Email').fill('zidonghuaceshi');
await page.getByPlaceholder('Username/Email').fill(username);
await page.getByPlaceholder('Password').click();
await page.getByPlaceholder('Password').fill('zidonghuaceshi123');
await page.getByRole('button', { name: 'Sign in' }).click();
await page.getByTestId('user-center-button').hover();
await expect(page.getByText('zidonghuaceshi')).toBeVisible();
await expect(page.getByText(username)).toBeVisible();
});
});

View File

@ -192,14 +192,18 @@ test.describe('form item & edit form', () => {
).toBeDisabled();
},
expectEasyReading: async () => {
await expect(
page.getByLabel('block-item-CollectionField-general-form-general.checkbox-checkbox').getByRole('checkbox'),
).toBeVisible();
await expect(
page
.getByLabel('block-item-CollectionField-general-form-general.checkbox-checkbox')
.getByRole('img', { name: 'check' }),
).toBeVisible({ visible: record.checkbox });
if (record.checkbox) {
await expect(
page
.getByLabel('block-item-CollectionField-general-form-general.checkbox-checkbox')
.getByRole('img', { name: 'check' }),
).toBeVisible({ visible: record.checkbox });
} else {
// 未选中状态会显示一个禁用的 checkbox
await expect(
page.getByLabel('block-item-CollectionField-general-form-general.checkbox-checkbox').getByRole('checkbox'),
).toBeDisabled();
}
},
});
});

View File

@ -22,7 +22,6 @@ test.describe('file manager', () => {
// 2、测试步骤进入“文件管理器”-“新建”按钮,填写表单,点击“确定”按钮
await page.goto('/admin/settings/file-manager');
await page.waitForLoadState('networkidle');
await page.getByRole('button', { name: 'plus Add new' }).hover();
await page.getByRole('menuitem', { name: 'Local storage' }).click();
const createLocalStorage = new CreateLocalStorage(page);