-
Notifications
You must be signed in to change notification settings - Fork 5
/
overview.component.po.ts
74 lines (57 loc) · 2.2 KB
/
overview.component.po.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { $, $$, browser, by, ElementFinder, promise } from 'protractor';
const CONTAINER_SELECTOR = 'apimock-variables-overview';
export class VariablesOverviewActionsPo {
constructor(private container: ElementFinder = null) {
}
async add(key: string, value: string): Promise<void> {
await this.container.$$('.key').last().sendKeys(key);
await this.container.$$('.value').last().sendKeys(value);
await this.container.element(by.buttonText('Add variable')).click();
await browser.sleep(1000); // wait until the command has been finished
}
async search(query: string): Promise<void> {
await this.container.$('apimock-mat-table-filter').$('input').sendKeys(query);
}
}
export class VariablesOverviewPo {
static get actions(): VariablesOverviewActionsPo {
return new VariablesOverviewActionsPo($(CONTAINER_SELECTOR));
}
static row(index: number): VariablesOverviewRowPo {
return new VariablesOverviewRowPo($(CONTAINER_SELECTOR).$$('.mat-mdc-row').get(index));
}
static find(name: string): VariablesOverviewRowPo {
return new VariablesOverviewRowPo($$('.mat-mdc-row')
.filter(async el => {
const text = await el.$('.mat-column-key').getText();
return text === name;
}).first());
}
static navigateTo(): promise.Promise<any> {
return browser.get('/dev-interface/#/variables');
}
static isActive(): promise.Promise<any> {
return $(CONTAINER_SELECTOR).isPresent();
}
}
export class VariablesOverviewRowPo {
constructor(private container: ElementFinder) {
}
get key(): any {
return this.container.$('.mat-column-key');
}
get value(): any {
return this.container.$('.mat-column-value').$('input');
}
async updateValue(value: string): Promise<void> {
await this.value.clear();
await this.value.sendKeys(value);
// wait until the command has been finished
await browser.sleep(1000);
}
async delete(): Promise<void> {
await this.container.$('.delete').click();
// wait until the command has been finished
await browser.sleep(1000);
}
}