2018-10-04 02:39:39 +02:00
|
|
|
/* global browser document */
|
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');
|
|
|
|
const SharePage = require('./pages/desktop/share_page');
|
|
|
|
|
|
|
|
describe('Firefox Send', function() {
|
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-02 22:15:02 +02:00
|
|
|
browser.url('/');
|
|
|
|
browser.execute(() => {
|
|
|
|
document.getElementById('file-upload').style.display = 'block';
|
|
|
|
});
|
|
|
|
browser.waitForExist('#file-upload');
|
|
|
|
});
|
|
|
|
|
|
|
|
testFiles.forEach(file => {
|
2018-10-04 02:39:39 +02:00
|
|
|
it(`should upload and download files, file: ${file}`, function() {
|
2018-10-02 22:15:02 +02:00
|
|
|
browser.execute(() => {
|
|
|
|
document.getElementById('file-upload').style.display = 'block';
|
|
|
|
});
|
|
|
|
browser.waitForExist('#file-upload');
|
2018-10-04 02:39:39 +02:00
|
|
|
const homePage = new HomePage();
|
2018-10-02 22:15:02 +02:00
|
|
|
browser.chooseFile('#file-upload', `${testFilesPath}/${file}`);
|
|
|
|
browser.click(homePage.readyToSend);
|
2018-10-04 02:39:39 +02:00
|
|
|
const sharePage = new SharePage();
|
2018-10-02 22:15:02 +02:00
|
|
|
browser.waitForExist(sharePage.fileUrl);
|
|
|
|
browser.url(browser.getValue(sharePage.fileUrl));
|
2018-10-04 02:39:39 +02:00
|
|
|
const downloadPage = new DownloadPage();
|
2018-10-02 22:15:02 +02:00
|
|
|
downloadPage.waitForPageToLoad();
|
|
|
|
downloadPage.downloadBtn();
|
|
|
|
// Wait for download to complete
|
|
|
|
browser.waitUntil(() => {
|
|
|
|
browser.waitForExist(downloadPage.downloadComplete);
|
|
|
|
return (
|
|
|
|
browser.getText(downloadPage.downloadComplete) === 'DOWNLOAD COMPLETE'
|
|
|
|
);
|
|
|
|
});
|
2018-10-04 02:39:39 +02:00
|
|
|
assert.ok(fs.existsSync(path.join(downloadDir, file)));
|
2018-10-02 22:15:02 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|