fix: use waitForSelector for toast elements instead of timeouts
This commit is contained in:
@@ -37,12 +37,10 @@ test.describe('表单验证测试', () => {
|
||||
});
|
||||
await contactPage.submitForm();
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitForSelector('[data-testid="toast-notification"]', { timeout: 5000 });
|
||||
const toastMessage = await contactPage.getToastMessage();
|
||||
expect(toastMessage.message).toContain('表单提交成功');
|
||||
expect(toastMessage.type).toBe('success');
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
});
|
||||
|
||||
test('联系表单 - 必填字段验证', async ({ page }) => {
|
||||
@@ -114,11 +112,9 @@ test.describe('表单验证测试', () => {
|
||||
});
|
||||
await contactPage.submitForm();
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitForSelector('[data-testid="toast-notification"]', { timeout: 5000 });
|
||||
const toastMessage = await contactPage.getToastMessage();
|
||||
expect(toastMessage.message).toContain('服务器错误');
|
||||
expect(toastMessage.type).toBe('error');
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user