This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
spec.jobs.crud.js
399 lines (324 loc) · 15.4 KB
/
spec.jobs.crud.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
/*!
* @author: Divio AG
* @copyright: http://www.divio.ch
*/
'use strict';
/* global describe, it, browser, By, expect */
// #############################################################################
// INTEGRATION TEST
var jobsPage = require('../pages/page.jobs.crud.js');
var cmsProtractorHelper = require('cms-protractor-helper');
describe('Aldryn Jobs tests: ', function () {
// create random job name
var jobName = 'Test job ' + (Math.floor(Math.random() * 10001));
it('logs in to the site with valid username and password', function () {
// go to the main page
browser.get(jobsPage.site);
// check if the page already exists
jobsPage.testLink.isPresent().then(function (present) {
if (present === true) {
// go to the main page
browser.get(jobsPage.site + '?edit');
} else {
// click edit mode link
jobsPage.editModeLink.click();
}
// wait for username input to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.usernameInput);
}, jobsPage.mainElementsWaitTime);
// login to the site
jobsPage.cmsLogin();
});
});
it('creates a new test page', function () {
// click the example.com link in the top menu
jobsPage.userMenus.first().click().then(function () {
// wait for top menu dropdown options to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.userMenuDropdown);
}, jobsPage.mainElementsWaitTime);
return jobsPage.administrationOptions.first().click();
}).then(function () {
// wait for modal iframe to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.sideMenuIframe);
}, jobsPage.iframeWaitTime);
// switch to sidebar menu iframe
browser.switchTo().frame(browser.findElement(
By.css('.cms_sideframe-frame iframe')));
browser.wait(function () {
return browser.isElementPresent(jobsPage.pagesLink);
}, jobsPage.mainElementsWaitTime);
jobsPage.pagesLink.click();
// wait for iframe side menu to reload
browser.wait(function () {
return browser.isElementPresent(jobsPage.addConfigsButton);
}, jobsPage.mainElementsWaitTime);
// check if the page already exists and return the status
return jobsPage.addPageLink.isPresent();
}).then(function (present) {
if (present === true) {
// page is absent - create new page
browser.wait(function () {
return browser.isElementPresent(jobsPage.addPageLink);
}, jobsPage.mainElementsWaitTime);
jobsPage.addPageLink.click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.titleInput);
}, jobsPage.mainElementsWaitTime);
jobsPage.titleInput.sendKeys('Test').then(function () {
jobsPage.saveButton.click();
return jobsPage.slugErrorNotification.isPresent();
}).then(function (present) {
if (present === false) {
browser.wait(function () {
return browser.isElementPresent(jobsPage.editPageLink);
}, jobsPage.mainElementsWaitTime);
// wait till the editPageLink will become clickable
browser.sleep(500);
// validate/click edit page link
jobsPage.editPageLink.click();
// switch to default page content
browser.switchTo().defaultContent();
browser.wait(function () {
return browser.isElementPresent(jobsPage.testLink);
}, jobsPage.mainElementsWaitTime);
// validate test link text
jobsPage.testLink.getText().then(function (title) {
expect(title).toEqual('Test');
});
}
});
}
});
});
it('creates a new apphook config', function () {
// check if the focus is on sidebar ifarme
jobsPage.editPageLink.isPresent().then(function (present) {
if (present === false) {
// wait for modal iframe to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.sideMenuIframe);
}, jobsPage.iframeWaitTime);
// switch to sidebar menu iframe
return browser.switchTo().frame(browser.findElement(By.css(
'.cms_sideframe-frame iframe')));
}
}).then(function () {
browser.wait(function () {
return browser.isElementPresent(jobsPage.breadcrumbsLinks.first());
}, jobsPage.mainElementsWaitTime);
// click the Home link in breadcrumbs
jobsPage.breadcrumbsLinks.first().click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.jobsAddConfigsLink);
}, jobsPage.mainElementsWaitTime);
jobsPage.jobsAddConfigsLink.click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.namespaceInput);
}, jobsPage.mainElementsWaitTime);
jobsPage.namespaceInput.sendKeys('aldryn_jobs').then(function () {
jobsPage.saveButton.click();
// check if Jobs configuration namespace already exists
return jobsPage.namespaceErrorNotification.isPresent();
}).then(function (present) {
if (present === false) {
// wait for success notification
browser.wait(function () {
return browser.isElementPresent(jobsPage.successNotification);
}, jobsPage.mainElementsWaitTime);
// validate success notification
expect(jobsPage.successNotification.isDisplayed())
.toBeTruthy();
}
});
});
});
it('creates a new category', function () {
browser.wait(function () {
return browser.isElementPresent(jobsPage.breadcrumbsLinks.first());
}, jobsPage.mainElementsWaitTime);
// click the Home link in breadcrumbs
jobsPage.breadcrumbsLinks.first().click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.jobsAddCategoriesLink);
}, jobsPage.mainElementsWaitTime);
jobsPage.jobsAddCategoriesLink.click().then(function () {
browser.wait(function () {
return browser.isElementPresent(jobsPage.nameInput);
}, jobsPage.mainElementsWaitTime);
return jobsPage.nameInput.sendKeys('Test category');
}).then(function () {
browser.actions().mouseMove(jobsPage.saveAndContinueButton)
.perform();
jobsPage.saveButton.click();
// check if the category already exists and return the status
return jobsPage.nameErrorNotification.isPresent();
}).then(function (present) {
if (present === false) {
// wait for success notification
browser.wait(function () {
return browser.isElementPresent(jobsPage.successNotification);
}, jobsPage.mainElementsWaitTime);
// validate success notification
expect(jobsPage.successNotification.isDisplayed())
.toBeTruthy();
}
});
});
it('creates a new job opening', function () {
browser.wait(function () {
return browser.isElementPresent(jobsPage.breadcrumbsLinks.first());
}, jobsPage.mainElementsWaitTime);
// click the Home link in breadcrumbs
jobsPage.breadcrumbsLinks.first().click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.addJobOpeningsButton);
}, jobsPage.mainElementsWaitTime);
jobsPage.addJobOpeningsButton.click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.titleInput);
}, jobsPage.mainElementsWaitTime);
jobsPage.titleInput.sendKeys(jobName).then(function () {
// set Category
return cmsProtractorHelper.selectOption(jobsPage.categorySelect,
'Jobs / aldryn_jobs / Test category', jobsPage.categoryOption);
}).then(function () {
// click Today link
jobsPage.startDateLinks.first().click();
// click Now link
jobsPage.startTimeLinks.first().click();
// set End date
jobsPage.endDateInput.sendKeys('2100-07-09');
// set End time
return jobsPage.endTimeInput.sendKeys('12:34:56');
}).then(function () {
browser.wait(function () {
return browser.isElementPresent(jobsPage.saveAndContinueButton);
}, jobsPage.mainElementsWaitTime);
browser.actions().mouseMove(jobsPage.saveAndContinueButton)
.perform();
jobsPage.saveButton.click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.successNotification);
}, jobsPage.mainElementsWaitTime);
// validate success notification
expect(jobsPage.successNotification.isDisplayed()).toBeTruthy();
// validate edit job opening link
expect(jobsPage.editJobOpeningLinks.first().isDisplayed())
.toBeTruthy();
});
});
it('adds a new jobs block on the page', function () {
// switch to default page content
browser.switchTo().defaultContent();
browser.wait(function () {
return browser.isElementPresent(jobsPage.testLink);
}, jobsPage.mainElementsWaitTime);
// add jobs to the page only if it was not added before
return jobsPage.aldrynJobsBlock.isPresent().then(function (present) {
if (present === false) {
// click the Page link in the top menu
return jobsPage.userMenus.get(1).click().then(function () {
// wait for top menu dropdown options to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.userMenuDropdown);
}, jobsPage.mainElementsWaitTime);
jobsPage.advancedSettingsOption.click();
// wait for modal iframe to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.modalIframe);
}, jobsPage.iframeWaitTime);
// switch to modal iframe
browser.switchTo().frame(browser.findElement(By.css(
'.cms_modal-frame iframe')));
// set Jobs Application
cmsProtractorHelper.selectOption(jobsPage.applicationSelect,
'Jobs', jobsPage.jobsOption);
// switch to default page content
browser.switchTo().defaultContent();
browser.wait(function () {
return browser.isElementPresent(jobsPage.saveModalButton);
}, jobsPage.mainElementsWaitTime);
browser.actions().mouseMove(jobsPage.saveModalButton)
.perform();
return jobsPage.saveModalButton.click();
});
}
}).then(function () {
cmsProtractorHelper.waitFor(jobsPage.testLink);
// refresh the page to see changes
browser.refresh();
// wait for link to appear in aldryn jobs block
browser.wait(function () {
return browser.isElementPresent(jobsPage.jobsOpeningLink);
}, jobsPage.mainElementsWaitTime);
jobsPage.jobsOpeningLink.click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.jobTitle);
}, jobsPage.mainElementsWaitTime);
// validate job title
expect(jobsPage.jobTitle.isDisplayed()).toBeTruthy();
});
});
it('deletes job opening', function () {
// wait for modal iframe to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.sideMenuIframe);
}, jobsPage.iframeWaitTime);
// switch to sidebar menu iframe
browser.switchTo()
.frame(browser.findElement(By.css('.cms_sideframe-frame iframe')));
// wait for edit job opening link to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.editJobOpeningLinks.first());
}, jobsPage.mainElementsWaitTime);
// validate edit job opening links texts to delete proper job opening
jobsPage.editJobOpeningLinks.first().getText().then(function (text) {
// wait till horizontal scrollbar will disappear and
// editJobOpeningLinks will become clickable
browser.sleep(1500);
if (text === jobName) {
return jobsPage.editJobOpeningLinks.first().click();
} else {
return jobsPage.editJobOpeningLinks.get(1).getText()
.then(function (text) {
if (text === jobName) {
return jobsPage.editJobOpeningLinks.get(1).click();
} else {
return jobsPage.editJobOpeningLinks.get(2).getText()
.then(function (text) {
if (text === jobName) {
return jobsPage.editJobOpeningLinks.get(2).click();
}
});
}
});
}
}).then(function () {
// wait for delete button to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.deleteButton);
}, jobsPage.mainElementsWaitTime);
browser.actions().mouseMove(jobsPage.saveAndContinueButton)
.perform();
return jobsPage.deleteButton.click();
}).then(function () {
// wait for confirmation button to appear
browser.wait(function () {
return browser.isElementPresent(jobsPage.sidebarConfirmationButton);
}, jobsPage.mainElementsWaitTime);
jobsPage.sidebarConfirmationButton.click();
browser.wait(function () {
return browser.isElementPresent(jobsPage.successNotification);
}, jobsPage.mainElementsWaitTime);
// validate success notification
expect(jobsPage.successNotification.isDisplayed()).toBeTruthy();
// switch to default page content
browser.switchTo().defaultContent();
// refresh the page to see changes
browser.refresh();
});
});
});