From 6ba3be8a0f91ea5e5d05dcf36e324ae7bd8ba2ad Mon Sep 17 00:00:00 2001
From: Danny Coates
Date: Wed, 31 Oct 2018 11:31:17 -0700
Subject: [PATCH] updated integration tests for new ui
---
app/ui/archiveTile.js | 2 +
app/ui/copyDialog.js | 2 +-
app/ui/download.js | 2 +-
test/integration/download-tests.js | 40 ++++++-------------
test/integration/homepage-tests.js | 33 +++++----------
.../pages/desktop/download_page.js | 23 ++++-------
test/integration/pages/desktop/home_page.js | 27 +++++++------
test/integration/pages/desktop/page.js | 12 ++++--
.../pages/desktop/progress_page.js | 31 --------------
test/integration/pages/desktop/share_page.js | 24 -----------
test/integration/progress-tests.js | 22 +++++-----
11 files changed, 65 insertions(+), 153 deletions(-)
delete mode 100644 test/integration/pages/desktop/progress_page.js
delete mode 100644 test/integration/pages/desktop/share_page.js
diff --git a/app/ui/archiveTile.js b/app/ui/archiveTile.js
index 394cacaa..24cacac6 100644
--- a/app/ui/archiveTile.js
+++ b/app/ui/archiveTile.js
@@ -196,6 +196,7 @@ module.exports.wip = function(state, emit) {
${expiryOptions(state, emit)}
${password(state, emit)}
-
+
${state.translate('copyUrlFormButton')}
diff --git a/app/ui/download.js b/app/ui/download.js
index 6a149b7a..497f28fa 100644
--- a/app/ui/download.js
+++ b/app/ui/download.js
@@ -87,7 +87,7 @@ module.exports = function(state, emit) {
break;
case 'complete':
content = html`
-
+
${state.translate('downloadFinish')}
${state.translate(
diff --git a/test/integration/download-tests.js b/test/integration/download-tests.js
index 0f909d27..aa23d994 100644
--- a/test/integration/download-tests.js
+++ b/test/integration/download-tests.js
@@ -1,13 +1,13 @@
-/* global browser document */
+/* global browser */
const assert = require('assert');
const fs = require('fs');
const path = require('path');
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() {
+ const homePage = new HomePage();
const downloadDir =
browser.desiredCapabilities['moz:firefoxOptions']['prefs'][
'browser.download.dir'
@@ -16,35 +16,21 @@ describe('Firefox Send', function() {
const testFiles = fs.readdirSync(testFilesPath);
beforeEach(function() {
- browser.url('/');
- browser.execute(() => {
- document.getElementById('file-upload').style.display = 'block';
- });
- browser.waitForExist('#file-upload');
+ homePage.open();
});
testFiles.forEach(file => {
it(`should upload and download files, file: ${file}`, function() {
- browser.execute(() => {
- document.getElementById('file-upload').style.display = 'block';
- });
- browser.waitForExist('#file-upload');
- const homePage = new HomePage();
- browser.chooseFile('#file-upload', `${testFilesPath}/${file}`);
- browser.click(homePage.readyToSend);
- const sharePage = new SharePage();
- browser.waitForExist(sharePage.fileUrl);
- browser.url(browser.getValue(sharePage.fileUrl));
- const downloadPage = new DownloadPage();
- downloadPage.waitForPageToLoad();
- downloadPage.downloadBtn();
- // Wait for download to complete
- browser.waitUntil(() => {
- browser.waitForExist(downloadPage.downloadComplete);
- return (
- browser.getText(downloadPage.downloadComplete) === 'DOWNLOAD COMPLETE'
- );
- });
+ 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);
assert.ok(fs.existsSync(path.join(downloadDir, file)));
});
});
diff --git a/test/integration/homepage-tests.js b/test/integration/homepage-tests.js
index d572dadd..8eec6c70 100644
--- a/test/integration/homepage-tests.js
+++ b/test/integration/homepage-tests.js
@@ -3,45 +3,30 @@ const assert = require('assert');
const HomePage = require('./pages/desktop/home_page');
describe('Firefox Send homepage', function() {
+ const homePage = new HomePage();
const baseUrl = browser.options['baseUrl'];
- const legalLinks = [
+ const footerLinks = [
'legal',
'about',
'legal',
'cookies',
- 'report-infringement'
+ 'report-infringement',
+ 'github',
+ 'twitter'
];
- const socialLinks = ['github', 'twitter', 'mozilla'];
beforeEach(function() {
- browser.url('/');
- browser.pause(500);
+ homePage.open();
});
it('should have the right title', function() {
assert.equal(browser.getTitle(), 'Firefox Send');
});
- legalLinks.forEach((link, i) => {
- it(`should navigate to the correct legal pages, page: ${link}`, function() {
- const homePage = new HomePage();
+ footerLinks.forEach((link, i) => {
+ it(`should navigate to the correct page: ${link}`, function() {
// Click links on bottom of page
- const els = browser.elements(homePage.legalLinks);
- browser.elementIdClick(els.value[i].ELEMENT);
- // Wait for page to load
- browser.waitUntil(() => {
- const url = browser.getUrl();
- return url !== baseUrl;
- });
- assert.ok(browser.getUrl().includes(link));
- });
- });
-
- socialLinks.forEach((link, i) => {
- it(`should navigate to the correct social pages, page: ${link}`, function() {
- const homePage = new HomePage();
- // Click links on bottom of page
- const els = browser.elements(homePage.socialLinks);
+ const els = browser.elements(homePage.footerLinks);
browser.elementIdClick(els.value[i].ELEMENT);
// Wait for page to load
browser.waitUntil(() => {
diff --git a/test/integration/pages/desktop/download_page.js b/test/integration/pages/desktop/download_page.js
index 6f23593e..e76e75a4 100644
--- a/test/integration/pages/desktop/download_page.js
+++ b/test/integration/pages/desktop/download_page.js
@@ -2,10 +2,10 @@
const Page = require('./page');
class DownloadPage extends Page {
- constructor() {
- super();
- this.downloadBtnLocator = '.btn--download';
- this.downloadCompletedLocator = '.btn--complete';
+ constructor(path) {
+ super(path);
+ this.downloadButton = '#download-btn';
+ this.downloadComplete = '#download-complete';
}
/**
@@ -14,21 +14,12 @@ class DownloadPage extends Page {
* @throws ElementNotFound
*/
waitForPageToLoad() {
- browser.waitUntil(() => {
- browser.waitForExist(this.downloadBtnLocator);
- const el = browser.element(this.downloadBtnLocator);
- return browser.elementIdDisplayed(el.value.ELEMENT);
- });
+ browser.waitForExist(this.downloadButton);
return this;
}
- downloadBtn() {
- this.waitForPageToLoad();
- return browser.click(this.downloadBtnLocator);
- }
-
- get downloadComplete() {
- return this.downloadCompletedLocator;
+ download() {
+ return browser.click(this.downloadButton);
}
}
module.exports = DownloadPage;
diff --git a/test/integration/pages/desktop/home_page.js b/test/integration/pages/desktop/home_page.js
index 0c408e83..aaf118b7 100644
--- a/test/integration/pages/desktop/home_page.js
+++ b/test/integration/pages/desktop/home_page.js
@@ -1,23 +1,26 @@
+/* global browser document */
const Page = require('./page');
class HomePage extends Page {
constructor() {
- super();
- this.legalSectionLinks = '.legalSection .legalSection__link';
- this.readyToSendLocator = 'div#page-one button.btn';
- this.socialLinksLocator = '.socialSection__link';
+ super('/');
+ this.footerLinks = 'footer a';
+ this.uploadInput = '#file-upload';
+ this.uploadButton = '#upload-btn';
+ this.progress = 'progress';
+ this.shareUrl = '#share-url';
}
- get legalLinks() {
- return this.legalSectionLinks;
+ waitForPageToLoad() {
+ browser.waitForExist(this.uploadInput);
+ this.showUploadInput();
+ return this;
}
- get readyToSend() {
- return this.readyToSendLocator;
- }
-
- get socialLinks() {
- return this.socialLinksLocator;
+ showUploadInput() {
+ browser.execute(() => {
+ document.getElementById('file-upload').style.display = 'block';
+ });
}
}
module.exports = HomePage;
diff --git a/test/integration/pages/desktop/page.js b/test/integration/pages/desktop/page.js
index b65a7519..9ec1d375 100644
--- a/test/integration/pages/desktop/page.js
+++ b/test/integration/pages/desktop/page.js
@@ -1,9 +1,11 @@
/* global browser */
class Page {
- constructor() {}
+ constructor(path) {
+ this.path = path;
+ }
- open(path) {
- browser.url(path);
+ open() {
+ browser.url(this.path);
this.waitForPageToLoad();
}
@@ -12,6 +14,8 @@ class Page {
* @returns {Object} An object representing the page.
* @throws ElementNotFound
*/
- waitForPageToLoad() {}
+ waitForPageToLoad() {
+ return this;
+ }
}
module.exports = Page;
diff --git a/test/integration/pages/desktop/progress_page.js b/test/integration/pages/desktop/progress_page.js
deleted file mode 100644
index be74ab00..00000000
--- a/test/integration/pages/desktop/progress_page.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/* global browser */
-const Page = require('./page');
-const SharePage = require('./share_page');
-
-class ProgressPage extends Page {
- constructor() {
- super();
- this.cancelBtnLocator = '.uploadCancel';
- this.progressIconLocator = '.btn--stripes';
- }
-
- /**
- * @function waitForPageToLoad
- * @returns {Object} An object representing the Share page.
- * @throws ElementNotFound
- */
- waitForPageToLoad() {
- browser.waitUntil(() => {
- browser.waitForExist(this.progressIconLocator);
- const el = browser.element(this.progressIconLocator);
- return browser.elementIdDisplayed(el.value.ELEMENT);
- });
- const sharePage = new SharePage();
- return sharePage.waitForPageToLoad();
- }
-
- get cancelBtn() {
- return this.cancelBtnLocator;
- }
-}
-module.exports = ProgressPage;
diff --git a/test/integration/pages/desktop/share_page.js b/test/integration/pages/desktop/share_page.js
deleted file mode 100644
index 296c9dd1..00000000
--- a/test/integration/pages/desktop/share_page.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/* global browser */
-const Page = require('./page');
-
-class SharePage extends Page {
- constructor() {
- super();
- this.sharePageLocator = '#shareWrapper';
- this.shareUrlLocator = '#fileUrl';
- }
-
- waitForPageToLoad() {
- browser.waitUntil(() => {
- browser.waitForExist(this.sharePageLocator);
- const el = browser.element(this.sharePageLocator);
- return browser.elementIdDisplayed(el.value.ELEMENT);
- });
- return this;
- }
-
- get fileUrl() {
- return this.shareUrlLocator;
- }
-}
-module.exports = SharePage;
diff --git a/test/integration/progress-tests.js b/test/integration/progress-tests.js
index 12b51b65..593cce8b 100644
--- a/test/integration/progress-tests.js
+++ b/test/integration/progress-tests.js
@@ -1,22 +1,18 @@
-/* global browser document */
+/* global browser */
const assert = require('assert');
-const ProgressPage = require('./pages/desktop/progress_page');
const HomePage = require('./pages/desktop/home_page');
describe('Firefox Send progress page', function() {
+ const homePage = new HomePage();
beforeEach(function() {
- browser.url('/');
+ homePage.open();
});
- it('should show an icon while an upload is in progress', function() {
- browser.execute(() => {
- document.getElementById('file-upload').style.display = 'block';
- });
- browser.waitForExist('#file-upload');
- const homePage = new HomePage();
- browser.chooseFile('#file-upload', __filename);
- browser.click(homePage.readyToSend);
- const progressPage = new ProgressPage();
- assert.ok(progressPage.waitForPageToLoad());
+ it('should show progress when a file is uploading', function() {
+ browser.chooseFile(homePage.uploadInput, __filename);
+ browser.waitForExist(homePage.uploadButton);
+ browser.click(homePage.uploadButton);
+
+ assert.ok(browser.waitForExist(homePage.progress));
});
});