send/test/integration/download-tests.js

61 lines
2.1 KiB
JavaScript
Raw Normal View History

2018-10-31 18:31:17 +00:00
/* global browser */
2018-10-02 20:15:02 +00:00
const assert = require('assert');
const fs = require('fs');
const path = require('path');
2018-10-04 00:39:39 +00:00
const DownloadPage = require('./pages/desktop/download_page');
const HomePage = require('./pages/desktop/home_page');
describe('Firefox Send', function() {
2018-10-31 18:31:17 +00:00
const homePage = new HomePage();
2018-10-02 20:15:02 +00: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 00:39:39 +00:00
beforeEach(function() {
2018-10-31 18:31:17 +00:00
homePage.open();
2018-10-02 20:15:02 +00:00
});
testFiles.forEach(file => {
2018-10-04 00:39:39 +00:00
it(`should upload and download files, file: ${file}`, function() {
2018-10-31 18:31:17 +00: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 00:39:39 +00:00
assert.ok(fs.existsSync(path.join(downloadDir, file)));
2018-10-02 20:15:02 +00:00
});
});
it('should update the download count on home page after 1 download', function() {
const expectedExpiresAfterText = 'Expires after 1 download';
browser.chooseFile(
homePage.uploadInput,
`${testFilesPath}/${testFiles[0]}`
);
browser.waitForExist(homePage.uploadButton);
browser.waitForExist(homePage.downloadCountDropdown);
browser.selectByIndex(homePage.downloadCountDropdown, 1);
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();
browser.waitForExist(homePage.expiresAfterText);
assert.ok(
browser.getText(homePage.expiresAfterText).substring(0, 24) ===
expectedExpiresAfterText
);
});
2018-10-02 20:15:02 +00:00
});