fix: update ContactPage and form tests to match actual form structure
This commit is contained in:
@@ -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() || '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user