Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.

Commit

Permalink
Change text of session JOIN buttons
Browse files Browse the repository at this point in the history
Also, fix some tests (#267)
  • Loading branch information
yourcelf committed Apr 15, 2014
1 parent 3bd1e7a commit 979f6d8
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fabfile.py
# for auto-farming
farmingConf.json
# For load simulation
simulatorConf.js
*simulatorConf.js
# ignore ssl, to ensure we never check certs in.
ssl/

Expand Down
2 changes: 1 addition & 1 deletion public/css/screen.styl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ hr.noshade {

width: 130px;

.icon-lock {
.lock {
margin-right: 5px;
}
}
Expand Down
11 changes: 6 additions & 5 deletions public/js/event-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ views.SessionView = Backbone.Marionette.ItemView.extend({
this.ui.attend.removeClass("active");
this.ui.attend.addClass("btn-success");

this.ui.attend.find(".text").text("JOIN");

// don't show the x of 10 when it's live (at least until we have live data for that)
this.$el.find(".start").show();

Expand Down Expand Up @@ -167,17 +165,20 @@ views.SessionView = Backbone.Marionette.ItemView.extend({

this.ui.hangoutOffline.hide();

this.ui.attend.find(".icon-lock").hide();
if (!this.options.event.sessionsOpen() || numAttendees >= this.model.MAX_ATTENDEES) {
this.ui.attend.find(".icon-lock").show();
this.ui.attend.find(".lock").show();

this.ui.attend.attr("disabled", true);
this.ui.attend.addClass("disabled");

if (numAttendees >= this.model.MAX_ATTENDEES) {
this.ui.attend.find(".text").text("JOIN (full)");
this.ui.attend.find(".text").text("FULL");
} else {
this.ui.attend.find(".text").text("LOCKED");
}
} else {
this.ui.attend.find(".lock").hide();
this.ui.attend.find(".text").text("JOIN");
this.ui.attend.removeAttr("disabled");
this.ui.attend.removeClass("disabled");
}
Expand Down
2 changes: 2 additions & 0 deletions test/test.chat.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe("CHAT WINDOW", function() {
browser.get("http://localhost:7777/");
browser.mockAuthenticate("regular1");
browser.get("http://localhost:7777/event/" + evt.id);
browser.waitForScript("$");
browser.waitForSelector("#chat-input");
var msgCount = 50;
for (var i = 0; i < msgCount; i++) {
Expand Down Expand Up @@ -134,6 +135,7 @@ describe("CHAT WINDOW", function() {
var text = "admin check " + (counter++) + "\n";
browser.mockAuthenticate(sockkey);
browser.get("http://localhost:7777/event/" + event.id)
browser.waitForScript("$");
browser.waitForSelector("#chat-input");
browser.byCss("#chat-input").sendKeys(text);
browser.wait(function() {
Expand Down
1 change: 1 addition & 0 deletions test/test.create-event.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ describe("CREATE EVENT", function() {
browser.byCss("#about-nav a").click();
aboutIsVisible(true);
browser.waitForSelector("#about-event .scroll-up");
browser.executeScript("$('#about-event .scroll-up')[0].scrollIntoView();");
browser.byCss("#about-event .scroll-up").click();
aboutIsVisible(false);

Expand Down
3 changes: 3 additions & 0 deletions test/test.create-hoa.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ describe("CREATE HOA", function() {
browser.get("http://localhost:7777/");
browser.mockAuthenticate(user.get("sock-key"));
browser.get("http://localhost:7777/event/" + event.id);
browser.wait(function() {
return event.get("connectedUsers").length === 1;
});
browser.waitForSelector(".create-hoa");
browser.byCss(".create-hoa").click();
// Switch to the hangout creation window.
Expand Down
151 changes: 79 additions & 72 deletions test/test.session-joining.selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,74 @@ describe("SESSION JOINING PARTICIPANT LISTS", function() {
});
});

it("Preserves session list position", function(done) {
this.timeout(80000);
// We'll use 3 sockets --- s1, s2, s3 in the session.
var s1, s2, s3;
var session = event.get("sessions").at(0);
var u1 = common.server.db.users.findWhere({"sock-key": "regular1"});
var u2 = common.server.db.users.findWhere({"sock-key": "regular2"});
var u3 = common.server.db.users.findWhere({"sock-key": "admin1"});
var observer = common.server.db.users.findWhere({"sock-key": "admin2"});
browser.get("http://localhost:7777/");
browser.mockAuthenticate(observer.get("sock-key"));
browser.get("http://localhost:7777" + event.getEventUrl());
browser.waitForScript("$");
browser.then(function() {
return common.authedSock(
u1.getSockKey(), session.getRoomId()
).then(function(sock) { s1 = sock; });
});
browser.then(function() {
return common.authedSock(
u2.getSockKey(), session.getRoomId()
).then(function(sock) { s2 = sock; });
});
browser.then(function() {
return common.authedSock(
u3.getSockKey(), session.getRoomId()
).then(function(sock) { s3 = sock; });
});
function checkSessionUsers(list) {
var selector ="[data-session-id='" + session.id + "'] ul.hangout-users li";
return browser.wait(function() {
return browser.byCsss(selector).then(function(els) {
return Promise.all(_.map(els, function(el, i) {
return new Promise(function(resolve, reject) {
el.getAttribute("class").then(function(cls) {
if (list[i] === null && cls === "empty") {
return resolve();
} else if (cls === "user focus") {
return resolve();
} else {
return reject("Unexpected class " + cls);
}
}).then(null, function(err) {
return reject("Selenium error");
});
});
})).catch(function() {
return false;
});
});
});
};
checkSessionUsers([u1, u2, u3, null, null, null, null, null, null, null]);
browser.then(function() { return s2.promiseClose(); });
checkSessionUsers([u1, null, u3, null, null, null, null, null, null, null]);
browser.then(function() { return s1.promiseClose(); });
checkSessionUsers([null, null, u3, null, null, null, null, null, null, null]);
browser.then(function() {
return common.authedSock(
u2.getSockKey(), session.getRoomId()
).then(function(sock) { s2 = sock });
});
checkSessionUsers([null, u2, u3, null, null, null, null, null, null, null]);
browser.then(function() { return s3.promiseClose(); })
browser.then(function() { return s2.promiseClose(); });
browser.then(function() { done(); });
});

it("Handles stop conditions when session has been deleted", function(done) {
var session = event.get("sessions").at(0);
browser.get("http://localhost:7777/");
Expand Down Expand Up @@ -218,7 +286,10 @@ describe("SESSION JOINING PARTICIPANT LISTS", function() {

// Connect the browser and a socket to the event page.
browser.get("http://localhost:7777/event/" + event.id);
browser.waitForScript("$").then(function() {
browser.wait(function() {
return event.get("connectedUsers").length === 1;
});
browser.then(function() {
common.authedSock("regular2", event.getRoomId(), function(thesock) {
sock = thesock;
});
Expand Down Expand Up @@ -265,6 +336,8 @@ describe("SESSION JOINING PARTICIPANT LISTS", function() {
"); } catch(e) { val = false; } ; return val;"
).then(function(result) {
return result == isShowing;
}).then(null, function(err) {
return false;
});
});
}
Expand All @@ -273,9 +346,11 @@ describe("SESSION JOINING PARTICIPANT LISTS", function() {
browser.mockAuthenticate("regular1");
var sock;
var session = event.get("sessions").at(0);
browser.get(
"http://localhost:7777/test/hangout/" + session.id + "/"
).then(function() {
browser.get("http://localhost:7777/test/hangout/" + session.id + "/")
browser.wait(function() {
return session.getNumConnectedParticipants() === 1;
});
browser.then(function() {
return common.authedSock("regular2", session.getRoomId()).then(function(thesock) {
sock = thesock;
});
Expand Down Expand Up @@ -430,72 +505,4 @@ describe("SESSION JOINING PARTICIPANT LISTS", function() {
done();
});
});

it("Preserves session list position", function(done) {
this.timeout(80000);
// We'll use 3 sockets --- s1, s2, s3 in the session.
var s1, s2, s3;
var session = event.get("sessions").at(0);
var u1 = common.server.db.users.findWhere({"sock-key": "regular1"});
var u2 = common.server.db.users.findWhere({"sock-key": "regular2"});
var u3 = common.server.db.users.findWhere({"sock-key": "admin1"});
var observer = common.server.db.users.findWhere({"sock-key": "admin2"});
browser.get("http://localhost:7777/");
browser.mockAuthenticate(observer.get("sock-key"));
browser.get("http://localhost:7777" + event.getEventUrl());
browser.waitForScript("$");
browser.then(function() {
return common.authedSock(
u1.getSockKey(), session.getRoomId()
).then(function(sock) { s1 = sock; });
});
browser.then(function() {
return common.authedSock(
u2.getSockKey(), session.getRoomId()
).then(function(sock) { s2 = sock; });
});
browser.then(function() {
return common.authedSock(
u3.getSockKey(), session.getRoomId()
).then(function(sock) { s3 = sock; });
});
function checkSessionUsers(list) {
var selector ="[data-session-id='" + session.id + "'] ul.hangout-users li";
return browser.wait(function() {
return browser.byCsss(selector).then(function(els) {
return Promise.all(_.map(els, function(el, i) {
return new Promise(function(resolve, reject) {
el.getAttribute("class").then(function(cls) {
if (list[i] === null && cls === "empty") {
return resolve();
} else if (cls === "user focus") {
return resolve();
} else {
return reject("Unexpected class " + cls);
}
}).then(null, function(err) {
return reject("Selenium error");
});
});
})).catch(function() {
return false;
});
});
});
};
checkSessionUsers([u1, u2, u3, null, null, null, null, null, null, null]);
browser.then(function() { return s2.promiseClose(); });
checkSessionUsers([u1, null, u3, null, null, null, null, null, null, null]);
browser.then(function() { return s1.promiseClose(); });
checkSessionUsers([null, null, u3, null, null, null, null, null, null, null]);
browser.then(function() {
return common.authedSock(
u2.getSockKey(), session.getRoomId()
).then(function(sock) { s2 = sock });
});
checkSessionUsers([null, u2, u3, null, null, null, null, null, null, null]);
browser.then(function() { return s3.promiseClose(); })
browser.then(function() { return s2.promiseClose(); });
browser.then(function() { done(); });
});
});
2 changes: 1 addition & 1 deletion views/event.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<script type="text/template" id="session-template">
<h3>{{- title }}</h3>
<div class="attend btn btn-info" data-toggle="button">
<span class="outer"><i class="icon-lock"></i><span class="text">JOIN</span></span>
<span class="outer"><i class="lock fa fa-lock"></i><span class="text">LOCKED</span></span>
<div class="attendance"></div>
</div>

Expand Down

0 comments on commit 979f6d8

Please sign in to comment.