fix: check specific field error messages and toast for API errors
This commit is contained in:
@@ -60,8 +60,8 @@ test.describe('表单验证测试', () => {
|
|||||||
await contactPage.submitForm();
|
await contactPage.submitForm();
|
||||||
|
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
const errorMessage = await contactPage.getFormErrorMessage();
|
const nameError = await page.locator('[data-testid="name-input"] ~ [data-testid="error-message"]').textContent();
|
||||||
expect(errorMessage).toBeTruthy();
|
expect(nameError).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('联系表单 - 邮箱格式验证', async ({ page }) => {
|
test('联系表单 - 邮箱格式验证', async ({ page }) => {
|
||||||
@@ -82,8 +82,8 @@ test.describe('表单验证测试', () => {
|
|||||||
await contactPage.submitForm();
|
await contactPage.submitForm();
|
||||||
|
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
const errorMessage = await contactPage.getFormErrorMessage();
|
const emailError = await page.locator('[data-testid="email-input"] ~ [data-testid="error-message"]').textContent();
|
||||||
expect(errorMessage).toBeTruthy();
|
expect(emailError).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('联系表单 - API错误处理', async ({ page }) => {
|
test('联系表单 - API错误处理', async ({ page }) => {
|
||||||
@@ -112,7 +112,7 @@ test.describe('表单验证测试', () => {
|
|||||||
await contactPage.submitForm();
|
await contactPage.submitForm();
|
||||||
|
|
||||||
await page.waitForTimeout(3000);
|
await page.waitForTimeout(3000);
|
||||||
const errorMessage = await contactPage.getFormErrorMessage();
|
const toastMessage = await contactPage.getToastMessage();
|
||||||
expect(errorMessage).toBeTruthy();
|
expect(toastMessage.message).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user