From 979f6d8045314804815747d5e3c4b4c20e2dd578 Mon Sep 17 00:00:00 2001 From: Charlie DeTar Date: Mon, 14 Apr 2014 20:38:15 -0600 Subject: [PATCH] Change text of session JOIN buttons Also, fix some tests (#267) --- .gitignore | 2 +- public/css/screen.styl | 2 +- public/js/event-views.js | 11 +- test/test.chat.selenium.js | 2 + test/test.create-event.selenium.js | 1 + test/test.create-hoa.selenium.js | 3 + test/test.session-joining.selenium.js | 151 ++++++++++++++------------ views/event.ejs | 2 +- 8 files changed, 94 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index 40366c0e..17a5cc9a 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/public/css/screen.styl b/public/css/screen.styl index 4bc93874..ad092104 100644 --- a/public/css/screen.styl +++ b/public/css/screen.styl @@ -572,7 +572,7 @@ hr.noshade { width: 130px; - .icon-lock { + .lock { margin-right: 5px; } } diff --git a/public/js/event-views.js b/public/js/event-views.js index 42ed508e..aacd75ec 100644 --- a/public/js/event-views.js +++ b/public/js/event-views.js @@ -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(); @@ -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"); } diff --git a/test/test.chat.selenium.js b/test/test.chat.selenium.js index 9a607d21..66d02694 100644 --- a/test/test.chat.selenium.js +++ b/test/test.chat.selenium.js @@ -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++) { @@ -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() { diff --git a/test/test.create-event.selenium.js b/test/test.create-event.selenium.js index e0799660..a65e8266 100644 --- a/test/test.create-event.selenium.js +++ b/test/test.create-event.selenium.js @@ -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); diff --git a/test/test.create-hoa.selenium.js b/test/test.create-hoa.selenium.js index 9505051c..bae02f12 100644 --- a/test/test.create-hoa.selenium.js +++ b/test/test.create-hoa.selenium.js @@ -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. diff --git a/test/test.session-joining.selenium.js b/test/test.session-joining.selenium.js index 2850359c..fc01a563 100644 --- a/test/test.session-joining.selenium.js +++ b/test/test.session-joining.selenium.js @@ -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/"); @@ -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; }); @@ -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; }); }); } @@ -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; }); @@ -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(); }); - }); }); diff --git a/views/event.ejs b/views/event.ejs index 1ee140f1..1d85b800 100644 --- a/views/event.ejs +++ b/views/event.ejs @@ -66,7 +66,7 @@