fix: update ContactPage and form tests to match actual form structure

This commit is contained in:
张翔
2026-03-06 13:15:17 +08:00
parent bdd89c0c58
commit 8cfc16e142
5 changed files with 1212 additions and 12 deletions
+13 -8
View File
@@ -8,22 +8,27 @@ export class ContactPage extends BasePage {
super(page, pageConfig.url, config);
}
async fillContactForm(data: { name: string; email: string; phone: string; message: string }): Promise<void> {
await this.fill('#name', data.name);
await this.fill('#email', data.email);
await this.fill('#phone', data.phone);
await this.fill('#message', data.message);
async fillContactForm(data: { name: string; email: string; phone: string; message: string; subject?: string }): Promise<void> {
await this.fill('[data-testid="name-input"]', data.name);
await this.fill('[data-testid="phone-input"]', data.phone);
await this.fill('[data-testid="email-input"]', data.email);
if (data.subject) {
await this.fill('[data-testid="subject-input"]', data.subject);
}
await this.fill('[data-testid="message-input"]', data.message);
}
async submitForm(): Promise<void> {
await this.click('button[type="submit"]');
await this.click('[data-testid="submit-button"]');
}
async getFormErrorMessage(): Promise<string> {
return await this.getText('.error-message');
const errorElement = await this.page.locator('[data-testid="name-input"]').locator('..').locator('p.text-red-500').first();
return await errorElement.textContent() || '';
}
async getFormSuccessMessage(): Promise<string> {
return await this.getText('.success-message');
const successElement = await this.page.locator('text=消息已发送').first();
return await successElement.textContent() || '';
}
}