mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 17:06:16 -04:00
Tests: Add and test padPrefs for helper.newPad (#4042)
Also fix a couple other tests along the way, including accounting for this change:
23307d14d5
This commit is contained in:
parent
b1b181927d
commit
febd48954c
2 changed files with 60 additions and 11 deletions
|
@ -50,15 +50,16 @@ describe("the test helper", function(){
|
|||
// set cookies far into the future to make sure they're not expired yet
|
||||
window.document.cookie = 'token=foo;expires=Thu, 01 Jan 3030 00:00:00 GMT; path=/';
|
||||
window.document.cookie = 'language=bar;expires=Thu, 01 Jan 3030 00:00:00 GMT; path=/';
|
||||
const testCookie = 'token=foo; language=bar'
|
||||
|
||||
expect(window.document.cookie).to.be(testCookie)
|
||||
expect(window.document.cookie).to.contain('token=foo');
|
||||
expect(window.document.cookie).to.contain('language=bar');
|
||||
|
||||
helper.newPad(function(){
|
||||
// helper function seems to have cleared cookies
|
||||
// NOTE: this doesn't yet mean it's proven to have taken effect by this point in execution
|
||||
var firstCookie = window.document.cookie
|
||||
expect(firstCookie).to.not.be(testCookie)
|
||||
expect(firstCookie).to.not.contain('token=foo');
|
||||
expect(firstCookie).to.not.contain('language=bar');
|
||||
|
||||
var chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -73,7 +74,16 @@ describe("the test helper", function(){
|
|||
$usernameInput.blur();
|
||||
|
||||
// Before refreshing, make sure the name is there
|
||||
expect($usernameInput.val()).to.be('John McLear')
|
||||
expect($usernameInput.val()).to.be('John McLear');
|
||||
|
||||
// Now that we have a chrome, we can set a pad cookie, so we can confirm it gets wiped as well
|
||||
chrome$.document.cookie = 'prefsHtml=baz;expires=Thu, 01 Jan 3030 00:00:00 GMT';
|
||||
expect(chrome$.document.cookie).to.contain('prefsHtml=baz');
|
||||
|
||||
// Cookies are weird. Because it's attached to chrome$ (as helper.setPadCookies does), AND we
|
||||
// didn't put path=/, we shouldn't expect it to be visible on window.document.cookie. Let's just
|
||||
// be sure.
|
||||
expect(window.document.cookie).to.not.contain('prefsHtml=baz');
|
||||
|
||||
setTimeout(function(){ //give it a second to save the username on the server side
|
||||
helper.newPad(function(){ // get a new pad, let it clear the cookies
|
||||
|
@ -82,8 +92,12 @@ describe("the test helper", function(){
|
|||
// helper function seems to have cleared cookies
|
||||
// NOTE: this doesn't yet mean cookies were cleared effectively.
|
||||
// We still need to test below that we're in a new session
|
||||
expect(window.document.cookie).to.not.be(testCookie)
|
||||
expect(window.document.cookie).to.not.be(firstCookie)
|
||||
expect(window.document.cookie).to.not.contain('token=foo');
|
||||
expect(window.document.cookie).to.not.contain('language=bar');
|
||||
expect(chrome$.document.cookie).to.contain('prefsHtml=baz');
|
||||
expect(window.document.cookie).to.not.contain('prefsHtml=baz');
|
||||
|
||||
expect(window.document.cookie).to.not.be(firstCookie);
|
||||
|
||||
// click on the settings button to make settings visible
|
||||
var $userButton = chrome$(".buttonicon-showusers");
|
||||
|
@ -91,12 +105,26 @@ describe("the test helper", function(){
|
|||
|
||||
// confirm that the session was actually cleared
|
||||
var $usernameInput = chrome$("#myusernameedit");
|
||||
expect($usernameInput.val()).to.be('')
|
||||
expect($usernameInput.val()).to.be('Enter your name');
|
||||
|
||||
done();
|
||||
});
|
||||
}, 1000);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it("sets pad prefs cookie", function(done) {
|
||||
this.timeout(60000);
|
||||
|
||||
helper.newPad({
|
||||
padPrefs: {foo:"bar"},
|
||||
cb: function(){
|
||||
var chrome$ = helper.padChrome$;
|
||||
expect(chrome$.document.cookie).to.contain('prefsHttp=%7B%22');
|
||||
expect(chrome$.document.cookie).to.contain('foo%22%3A%22bar');
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue