forked from hiqdev/hipanel-module-stock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartForm.ts
43 lines (33 loc) · 1.69 KB
/
PartForm.ts
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
42
43
import {Page} from "@playwright/test";
import Select2 from "@hipanel-core/input/Select2";
import PriceWithCurrency from "@hipanel-module-stock/input/PriceWithCurrency";
export default class PartForm {
private page: Page;
public constructor(page: Page) {
this.page = page;
}
public async fillPartFields(partData: any, index: number = 0) {
await Select2.field(this.page, this.selector('select', 'partno', index)).setValue(partData.partno);
await Select2.field(this.page, this.selector('select', 'src_id', index)).setValue(partData.src_id);
await Select2.field(this.page, this.selector('select', 'dst_ids', index)).setValue(partData.dst_id);
await this.fillSerials(partData.serials, index);
await this.page.fill(this.selector('input', 'move_descr', index), partData.move_descr);
await PriceWithCurrency.field(this.page, 'part', index).setSumAndCurrency(partData.price, partData.currency);
await this.page.selectOption(this.selector('select', 'company_id', index), partData.company_id);
}
private selector(type: string, name: string, index: number = 0): string {
return `${type}[id=part-${index}-${name}]`;
}
public async fillSerials(serial: string, index: number = 0) {
await this.page.fill(this.selector('input', 'serials', index), serial);
}
/**
* It is strange, but in the same form on the /stock/part/replace page "serials" input has "serial" name
*/
public async fillSerial(serial: string, index: number = 0) {
await this.page.fill(this.selector('input', 'serial', index), serial);
}
public async save() {
await this.page.click('button:has-text("Save")');
}
}