-
Notifications
You must be signed in to change notification settings - Fork 1
/
spec.js
113 lines (100 loc) · 3.08 KB
/
spec.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
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
108
109
110
111
112
113
// protractor (angular + selenium) docs: http://www.protractortest.org/#/api
// // protractor defines methods like browser.get, element.getText
// jasmine docs https://jasmine.github.io/api/3.0/matchers.html
// // jasmine defines methods like toEqual, expect, toContain
describe("Cryptography Demo", () => {
beforeEach(() => {
browser.get("/");
});
it("should have a title", () => {
expect(browser.getTitle()).toEqual("Cryptography Demo | Callisto: Tech to combat sexual assault & harassment");
});
it("displays article 1", () => {
expect(article(1).isPresent()).toBeTruthy();
});
it("advances to article 2", () => {
// there's only 1 article visible on page start
expect(article(2).isPresent()).toBeFalsy();
// we click the "next" button in the 1st article
article(1).next();
// and now a second article is visible
expect(article(2).isPresent()).toBeTruthy();
});
it("advances to article 3", () => {
expect(article(3).isPresent()).toBeFalsy();
article(1).next();
article(2).next();
expect(article(3).isPresent()).toBeTruthy();
});
it("advances to article 4", () => {
expect(article(4).isPresent()).toBeFalsy();
article(1).next();
article(2).next();
article(3).next();
expect(article(4).isPresent()).toBeTruthy();
});
it("advances to article 5", () => {
expect(article(5).isPresent()).toBeFalsy();
article(1).next();
article(2).next();
article(3).next();
article(4).next();
expect(article(5).isPresent()).toBeTruthy();
});
it("advances to article 6", () => {
expect(article(6).isPresent()).toBeFalsy();
article(1).next();
article(2).next();
article(3).next();
article(4).next();
article(5).next();
expect(article(6).isPresent()).toBeTruthy();
});
it("advances to article 7", () => {
expect(article(7).isPresent()).toBeFalsy();
article(1).next();
article(2).next();
article(3).next();
article(4).next();
article(5).next();
article(6).next();
expect(article(7).isPresent()).toBeTruthy();
});
it("advances to article 8", () => {
expect(article(8).isPresent()).toBeFalsy();
article(1).next();
article(2).next();
article(3).next();
article(4).next();
article(5).next();
article(6).next();
article(7).next();
expect(article(8).isPresent()).toBeTruthy();
});
it("advances to last article", () => {
expect($('#last-step').isPresent()).toBeFalsy();
article(1).next();
article(2).next();
article(3).next();
article(4).next();
article(5).next();
article(6).next();
article(7).next();
expect($('#last-step').isPresent()).toBeTruthy();
});
function article(index) {
const element = $(`step-root *:nth-child(${index}) article`);
if (index === 2) {
element.next = () => {
element.$("#userInput").sendKeys('user name');
element.$("#perpInput").sendKeys('perp id');
element.$(".advance-button").click();
}
} else {
element.next = () => {
element.$(".advance-button").click();
}
}
return element;
}
});