Strip tracking url parameters

This commit is contained in:
Wiktor Furman 2019-10-15 15:29:48 +02:00
parent 0daa03e04c
commit 114068c531
4 changed files with 40 additions and 11 deletions

View File

@ -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');
}

View File

@ -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])));
});
});

View File

@ -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);
}
}

View File

@ -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() {