fix: update toast message extraction and test expectations
This commit is contained in:
@@ -35,7 +35,7 @@ test.describe('表单验证测试', () => {
|
|||||||
|
|
||||||
await contactPage.waitForToast();
|
await contactPage.waitForToast();
|
||||||
const toastMessage = await contactPage.getToastMessage();
|
const toastMessage = await contactPage.getToastMessage();
|
||||||
expect(toastMessage.message).toContain('成功');
|
expect(toastMessage.message).toContain('表单提交成功');
|
||||||
expect(toastMessage.type).toBe('success');
|
expect(toastMessage.type).toBe('success');
|
||||||
|
|
||||||
await contactPage.waitForToastHidden();
|
await contactPage.waitForToastHidden();
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ export class ContactPage extends BasePage {
|
|||||||
async getToastMessage(): Promise<{ message: string; type: 'success' | 'error' }> {
|
async getToastMessage(): Promise<{ message: string; type: 'success' | 'error' }> {
|
||||||
const toastElement = await this.page.locator('[data-testid="toast-notification"]');
|
const toastElement = await this.page.locator('[data-testid="toast-notification"]');
|
||||||
if (await toastElement.count() > 0) {
|
if (await toastElement.count() > 0) {
|
||||||
const message = await toastElement.textContent() || '';
|
const messageElement = toastElement.locator('p');
|
||||||
|
const message = await messageElement.textContent() || '';
|
||||||
const type = await toastElement.getAttribute('data-type') as 'success' | 'error';
|
const type = await toastElement.getAttribute('data-type') as 'success' | 'error';
|
||||||
return { message, type };
|
return { message, type };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user