/
index.js
61 lines (49 loc) · 1.66 KB
/
index.js
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
import { Selector, t } from 'testcafe';
import { attributeSelector, dataComp } from '../../utils/selector-utils';
import Identity from './Identity';
import PoliciesSection from './Policies';
import { editorUrl } from '../../utils/constants';
import { getLocation } from '../../utils/location-utils';
export default class SettingsPage {
sideMenu = Selector('.side-menu');
newIdentity = this.sideMenu.find(dataComp('add-new-identity'));
newIdentityInput = this.newIdentity.find('input');
newIdentityButton = this.newIdentity.find('button');
find(identityType) {
return this.sideMenu.find(attributeSelector('data-identity-type', identityType));
}
async add(identityType) {
await t
.expect(this.newIdentity.visible)
.ok()
.click(this.newIdentityButton)
.typeText(this.newIdentityInput, identityType)
.pressKey('enter');
const currentIdentity = new Identity(identityType);
await t.expect(currentIdentity.container.visible).ok();
return currentIdentity;
}
async open(identityType) {
const button = this.find(identityType);
const currentIdentity = new Identity(identityType);
await t
.expect(button.visible)
.ok()
.click(button)
.expect(currentIdentity.container.visible)
.ok();
return currentIdentity;
}
async openPoliciesPage(){
const button = this.sideMenu.find("a").withExactText("Policies");
const policies = new PoliciesSection();
await t
.expect(button.visible)
.ok()
.click(button)
.expect(policies.container.visible)
.ok()
.expect(getLocation()).eql(`${editorUrl}/settings/policies`)
return policies;
}
}