-
Notifications
You must be signed in to change notification settings - Fork 5
/
overview.component.po.ts
107 lines (82 loc) · 3 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { $, $$, browser, by, ElementFinder, promise } from 'protractor';
const CONTAINER_SELECTOR = 'apimock-mocks-overview';
export class MockOverviewActionsPo {
constructor(private container: ElementFinder = null) {
}
async resetToDefaults(): Promise<void> {
await this.container.element(by.buttonText('Reset to defaults')).click();
await browser.sleep(1000); // wait until the command has been finished
}
async setToPassThroughs(): Promise<void> {
await this.container.element(by.buttonText('All to passThrough')).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 MocksOverviewPo {
static get actions(): MockOverviewActionsPo {
return new MockOverviewActionsPo($(CONTAINER_SELECTOR));
}
static isActive(): promise.Promise<any> {
return $(CONTAINER_SELECTOR).isPresent();
}
static row(index: number): MocksOverviewRowPo {
return new MocksOverviewRowPo($(CONTAINER_SELECTOR).$$('.mat-mdc-row').get(index));
}
static async selectScenario(name: string, scenario: string): Promise<void> {
// Open mat-select
await MocksOverviewPo.find(name).selectScenario(scenario);
}
static find(name: string): MocksOverviewRowPo {
return new MocksOverviewRowPo($$('.mat-mdc-row')
.filter(async el => {
const text = await el.$('.mat-column-name').getText();
return text === name;
}).first());
}
static navigateTo(): promise.Promise<any> {
return browser.get('/dev-interface/#/mocks');
}
}
export class MocksOverviewRowPo {
constructor(private container: ElementFinder) {
}
get delay(): any {
return this.container.$('.delay');
}
get echo(): any {
return this.container.$('.echo');
}
get name(): any {
return this.container.$('.mat-column-name').getText();
}
get scenario(): any {
return this.container.$('.mat-mdc-select-value-text').getText();
}
async delayResponse(delay: string): Promise<void> {
await this.delay.sendKeys(delay);
// wait until the command has been finished
await browser.sleep(1000);
}
async toggleEcho(): Promise<void> {
await this.echo.click();
// wait until the command has been finished
await browser.sleep(1000);
}
async selectScenario(scenario: string): Promise<void> {
// Open the mat-select
this.container.$('mat-select')
.click();
// Select the scenario
await $$('mat-option')
.filter(async el => {
const text = await el.getText();
return text === scenario;
}).first()
.click();
// wait until the command has been finished
await browser.sleep(100);
}
}