diff --git a/app/ui/downloadPassword.js b/app/ui/downloadPassword.js index 1b505618..bbecbfa4 100644 --- a/app/ui/downloadPassword.js +++ b/app/ui/downloadPassword.js @@ -72,7 +72,9 @@ module.exports = function(state, emit) { const password = el.value; if (password.length > 0) { document.getElementById('password-btn').disabled = true; - state.fileInfo.url = window.location.href; + // Strip any url parameters between fileId and secretKey + const fileInfoUrl = window.location.href.replace(/\?.+#/, '#'); + state.fileInfo.url = fileInfoUrl; state.fileInfo.password = password; emit('getMetadata'); } diff --git a/test/integration/download-tests.js b/test/integration/download-tests.js index 8781a0f4..21005ece 100644 --- a/test/integration/download-tests.js +++ b/test/integration/download-tests.js @@ -82,4 +82,29 @@ describe('Firefox Send', function() { // check if upload and download file sizes are equal assert.equal(uploadSize, downloadSize); }); + + it(`should upload and download file with added tracking parameter`, function() { + const trackingUrl = + '?fbclid=IaMFak3Tr4ck1ng1d_SDlP0shBk8SM2EN3cCLFKpHVl-k-Pvv0sf9Zy0tnTu9srqVY'; + const password = 'strongpassword'; + + browser.chooseFile( + homePage.uploadInput, + `${testFilesPath}/${testFiles[0]}` + ); + browser.waitForExist(homePage.addPassword); + browser.click(homePage.addPassword); + browser.waitForExist(homePage.passwordInput); + browser.setValue(homePage.passwordInput, password); + browser.click(homePage.uploadButton); + browser.waitForExist(homePage.shareUrl); + const shareUrl = browser.getValue(homePage.shareUrl); + const downloadPage = new DownloadPage( + shareUrl.replace('#', `${trackingUrl}#`) + ); + downloadPage.open(); + downloadPage.downloadUsingPassword(password); + browser.waitForExist(downloadPage.downloadComplete); + assert.ok(fs.existsSync(path.join(downloadDir, testFiles[0]))); + }); }); diff --git a/test/integration/pages/desktop/download_page.js b/test/integration/pages/desktop/download_page.js index 0e9b727c..8bbb8458 100644 --- a/test/integration/pages/desktop/download_page.js +++ b/test/integration/pages/desktop/download_page.js @@ -4,23 +4,22 @@ const Page = require('./page'); class DownloadPage extends Page { constructor(path) { super(path); - this.fileId = /download\/(\w+)\/#/.exec(path)[1]; + this.fileId = /download\/(\w+)\/\??.*#/.exec(path)[1]; this.downloadButton = '#download-btn'; this.downloadComplete = '#download-complete'; + this.passwordInput = '#password-input'; + this.passwordButton = '#password-btn'; } - /** - * @function waitForPageToLoad - * @returns {Object} An object representing the page. - * @throws ElementNotFound - */ - waitForPageToLoad() { - super.waitForPageToLoad(); - browser.waitForExist(this.downloadButton); - return this; + downloadUsingPassword(password) { + browser.waitForExist(this.passwordInput); + browser.setValue(this.passwordInput, password); + browser.click(this.passwordButton); + return browser.click(this.downloadButton); } download() { + browser.waitForExist(this.downloadButton); return browser.click(this.downloadButton); } } diff --git a/test/integration/pages/desktop/home_page.js b/test/integration/pages/desktop/home_page.js index 5679f1b8..ff613a7e 100644 --- a/test/integration/pages/desktop/home_page.js +++ b/test/integration/pages/desktop/home_page.js @@ -10,6 +10,9 @@ class HomePage extends Page { this.progress = 'progress'; this.shareUrl = '#share-url'; this.downloadCountSelect = '#expire-after-dl-count-select'; + this.addPassword = '#add-password'; + this.passwordInput = '#password-input'; + this.passwordButton = '#password-btn'; } waitForPageToLoad() {