-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdepartment-form.page.ts
More file actions
41 lines (33 loc) · 1.31 KB
/
department-form.page.ts
File metadata and controls
41 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Page, Locator } from '@playwright/test';
import { BaseFormPage } from './base-form.page';
/**
* Department Form Page Object
*
* Covers the create/edit department form.
* Shared behaviour (submit, cancel, validation, success) comes from BaseFormPage.
*/
export class DepartmentFormPage extends BaseFormPage {
readonly nameInput: Locator;
constructor(page: Page) {
super(page, '/departments');
this.nameInput = page.locator('input[formControlName="name"], input[name*="name"]');
}
protected async isFormStillFilled(): Promise<boolean> {
const nameValue = await this.page.getByLabel('Name').inputValue().catch(
() => this.nameInput.inputValue().catch(() => '')
);
return nameValue.length > 0;
}
// ── Field fill methods ──────────────────────────────────────────────────
async fillName(name: string) {
try {
await this.page.getByLabel('Name').fill(name);
} catch {
await this.nameInput.fill(name);
}
}
// ── fillForm convenience method ─────────────────────────────────────────
async fillForm(data: { name: string }) {
await this.fillName(data.name);
}
}