2018-10-31 19:31:17 +01:00
|
|
|
/* global browser */
|
2018-10-02 22:15:02 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
2018-10-04 02:39:39 +02:00
|
|
|
const DownloadPage = require('./pages/desktop/download_page');
|
|
|
|
const HomePage = require('./pages/desktop/home_page');
|
|
|
|
|
|
|
|
describe('Firefox Send', function() {
|
2018-10-31 19:31:17 +01:00
|
|
|
const homePage = new HomePage();
|
2018-10-02 22:15:02 +02:00
|
|
|
const downloadDir =
|
|
|
|
browser.desiredCapabilities['moz:firefoxOptions']['prefs'][
|
|
|
|
'browser.download.dir'
|
|
|
|
];
|
|
|
|
const testFilesPath = path.join(__dirname, 'fixtures');
|
|
|
|
const testFiles = fs.readdirSync(testFilesPath);
|
|
|
|
|
2018-10-04 02:39:39 +02:00
|
|
|
beforeEach(function() {
|
2018-10-31 19:31:17 +01:00
|
|
|
homePage.open();
|
2018-10-02 22:15:02 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
testFiles.forEach(file => {
|
2018-10-04 02:39:39 +02:00
|
|
|
it(`should upload and download files, file: ${file}`, function() {
|
2018-10-31 19:31:17 +01:00
|
|
|
browser.chooseFile(homePage.uploadInput, `${testFilesPath}/${file}`);
|
|
|
|
browser.waitForExist(homePage.uploadButton);
|
|
|
|
browser.click(homePage.uploadButton);
|
|
|
|
browser.waitForExist(homePage.shareUrl);
|
|
|
|
const downloadPage = new DownloadPage(
|
|
|
|
browser.getValue(homePage.shareUrl)
|
|
|
|
);
|
|
|
|
downloadPage.open();
|
|
|
|
downloadPage.download();
|
|
|
|
browser.waitForExist(downloadPage.downloadComplete);
|
2018-10-04 02:39:39 +02:00
|
|
|
assert.ok(fs.existsSync(path.join(downloadDir, file)));
|
2018-10-02 22:15:02 +02:00
|
|
|
});
|
|
|
|
});
|
2019-01-09 15:02:11 +01:00
|
|
|
|
|
|
|
it('should update the download count on home page after 1 download', function() {
|
|
|
|
browser.chooseFile(
|
|
|
|
homePage.uploadInput,
|
|
|
|
`${testFilesPath}/${testFiles[0]}`
|
|
|
|
);
|
|
|
|
browser.waitForExist(homePage.uploadButton);
|
2019-01-10 02:25:43 +01:00
|
|
|
browser.waitForExist(homePage.downloadCountSelect);
|
|
|
|
browser.selectByIndex(homePage.downloadCountSelect, 1);
|
2019-01-09 15:02:11 +01:00
|
|
|
browser.click(homePage.uploadButton);
|
|
|
|
browser.waitForExist(homePage.shareUrl);
|
|
|
|
const downloadPage = new DownloadPage(browser.getValue(homePage.shareUrl));
|
|
|
|
downloadPage.open();
|
|
|
|
downloadPage.download();
|
|
|
|
browser.waitForExist(downloadPage.downloadComplete);
|
|
|
|
browser.back();
|
2019-01-11 01:22:40 +01:00
|
|
|
browser.waitForExist('send-archive');
|
2019-01-10 02:25:43 +01:00
|
|
|
assert.equal(
|
2019-02-26 19:39:50 +01:00
|
|
|
browser.getText('send-archive > div:first-of-type').substring(0, 24),
|
2019-01-11 01:22:40 +01:00
|
|
|
'Expires after 1 download'
|
2019-01-09 15:02:11 +01:00
|
|
|
);
|
|
|
|
});
|
2018-10-02 22:15:02 +02:00
|
|
|
});
|