From 7db76bff1a6247fbf84f60083d139b4a4e1bc292 Mon Sep 17 00:00:00 2001 From: Howard Wilson Date: Fri, 3 Jul 2015 12:07:17 +0200 Subject: [PATCH] Fix bug breaking use of app_client_id parameter [#6] --- exportify.js | 2 +- test/integration/exportify_tests.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/exportify.js b/exportify.js index d120ba0..fd54596 100644 --- a/exportify.js +++ b/exportify.js @@ -9,7 +9,7 @@ window.Helpers = { window.location = "https://accounts.spotify.com/authorize" + "?client_id=" + client_id + - "&redirect_uri=" + encodeURIComponent(document.location.href) + + "&redirect_uri=" + encodeURIComponent([location.protocol, '//', location.host, location.pathname].join('')) + "&scope=playlist-read-private%20playlist-read-collaborative" + "&response_type=token"; }, diff --git a/test/integration/exportify_tests.js b/test/integration/exportify_tests.js index fc8ccc2..f49bbc2 100644 --- a/test/integration/exportify_tests.js +++ b/test/integration/exportify_tests.js @@ -55,6 +55,31 @@ casper.test.begin("Testing initial authentication redirect", 2, function(test) { }); }); +casper.test.begin("Testing initial authentication redirect with different client id", 2, function(test) { + casper.start('http://localhost:8080/exportify.html?app_client_id=123456'); + + casper.waitUntilVisible('#loginButton', function() { + test.assertTitle("Exportify", "Exportify main page is loaded"); + this.click('#loginButton'); + }) + + casper.then(function() { + test.assertEquals( + lastRequestedURL, + "https://accounts.spotify.com/authorize?" + + "client_id=123456&" + + "redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fexportify.html&" + + "scope=playlist-read-private playlist-read-collaborative&" + + "response_type=token", + "Redirected to Spotify authentication page" + ); + }); + + casper.run(function() { + test.done(); + }); +}); + casper.test.begin("Testing loading and displaying playlists", 10, function(test) { casper.viewport(1000, 1000);