This repository was archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathtest.facilitator-embeds.selenium.js
124 lines (112 loc) · 5.18 KB
/
test.facilitator-embeds.selenium.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
var expect = require('expect.js'),
_ = require("underscore"),
common = require('./common');
describe("FACILITATOR EMBEDS", function() {
var browser = null,
event = null;
if (process.env.SKIP_SELENIUM_TESTS) {
return;
}
this.timeout(60000); // Extra long timeout for selenium :(
before(function(done) {
this.timeout(240000);
common.getSeleniumBrowser(function (theBrowser) {
browser = theBrowser;
common.standardSetup(function() {
event = common.server.db.events.findWhere({shortName: "writers-at-work"});
event.set("open", true);
done();
});
});
});
after(function(done) {
browser.quit().then(function() {
common.standardShutdown(done);
});
});
it("Gets an about page with auto-hide for new sessions", function(done) {
var session = event.get("sessions").at(0);
browser.mockAuthenticate("regular1");
browser.get(common.URL + "/facilitator/" + session.id + "/");
browser.waitForSelector(".cancel-autohide");
browser.waitForScript("$");
browser.executeScript(
"return $('.main-window').hasClass('sidebar');"
).then(function(val) {
expect(val).to.be(true);
done();
});
});
it("Displays, removes, and changes embedded webpages", function(done) {
var session = event.get("sessions").at(0);
browser.mockAuthenticate("regular1");
// Load a session page with a webpage activity.
session.set("activities", [{type: "webpage", url: common.URL + "/public/html/test.html"}]);
browser.get(common.URL + "/facilitator/" + session.id + "/");
// Ensure the webpage is displayed.
browser.waitForScript("$");
browser.executeScript("return $('iframe').attr('src');").then(function(src) {
expect(src).to.eql(common.URL + "/public/html/test.html");
});
// Remove the embed.
browser.awaitModalDismissal();
browser.byCss(".activity-settings").click();
browser.waitForSelector(".remove-embed");
browser.byCss(".remove-embed").click();
// Ensure 'about' is displayed.
browser.awaitModalDismissal();
browser.waitForSelector(".about-activity");
browser.waitForScript("$");
browser.executeScript("return $('.about-activity').text();").then(function(text) {
expect(text.indexOf("helps the Unhangout Permalink service")).to.not.eql(-1);
expect(session.get("activities")).to.eql([{'type': 'about'}]);
});
// Ensure modals have been removed and not just hidden.
browser.wait(function() {
return browser.byCsss(".add-activity-dialog").then(function(els) {
return els.length === 0;
});
});
// Add a new activity.
browser.awaitModalDismissal();
browser.byCss(".add-activity").click();
browser.waitForSelector(".add-activity-dialog input[type='text']");
// Doesn't allow blank URL's.
browser.byCss(".add-activity-dialog input[type='text']").sendKeys(" ");
browser.byCss(".add-activity-dialog [type='submit']").click();
// Nothing should happen... the next call should fail if the modal is closed.
// Allows non-blank URLs.
browser.byCss(".add-activity-dialog input[type='text']").sendKeys(common.URL + "/public/html/test.html");
browser.byCss(".add-activity-dialog [type='submit']").click();
browser.waitForSelector("iframe");
browser.byCss(".webpage-activity"); // throws error if it's not there
browser.waitForScript("$");
browser.executeScript("return $('iframe').attr('src');").then(function(src) {
expect(src).to.eql(common.URL + "/public/html/test.html");
expect(session.get("activities")).to.eql([{
'type': 'webpage', 'url': common.URL + "/public/html/test.html"
}]);
});
// Embeds youtube videos.
browser.awaitModalDismissal(".add-activity-dialog");
browser.waitTime(1000);
browser.byCss(".activity-settings").click();
// Can't seem to get around this hard-coded delay; get occasional
// "Element is no longer attached to the DOM" errors without it.
browser.waitTime(1000);
browser.waitForSelector(".add-activity-dialog input[type='text']");
browser.byCss(".add-activity-dialog input[type='text']").sendKeys(
"https://youtu.be/NIylUcGDi-Y")
browser.byCss(".add-activity-dialog [type='submit']").click();
browser.waitForSelector("iframe");
browser.waitForScript("$");
browser.executeScript("return $('iframe').attr('src');").then(function(src) {
expect(src).to.eql("https://www.youtube.com/embed/NIylUcGDi-Y?wmode=transparent&enablejsapi=1&origin=" + encodeURIComponent(common.URL))
expect(session.get("activities")).to.eql([{
'type': 'video', 'video': {'provider': "youtube", 'id': 'NIylUcGDi-Y'}
}]);
done();
});
// Punting on testing youtube transport stuff for now..
});
});