From b84daf0422cf967f616265b7db82c8ae70f0a8b4 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 26 Oct 2017 17:30:55 +0200 Subject: [PATCH 01/25] Set resolution to 1600x1200 bs --- nightwatch-browserstack.conf.js | 1 + 1 file changed, 1 insertion(+) diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js index 9e8e334c5..ac8f90d27 100644 --- a/nightwatch-browserstack.conf.js +++ b/nightwatch-browserstack.conf.js @@ -26,6 +26,7 @@ const nightwatch_config = { // Disable this, as it makes bs slow and brittle. 'browserstack.networkLogs': false, + 'browserstack.resolution': '1600x1200', } }, chrome: { From ad4a5595f9e8b184c5f798421c8688c3a0f52c05 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 27 Oct 2017 13:19:00 +0200 Subject: [PATCH 02/25] Enable screenshot on failure for bs --- nightwatch-browserstack.conf.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js index ac8f90d27..bf0ca2284 100644 --- a/nightwatch-browserstack.conf.js +++ b/nightwatch-browserstack.conf.js @@ -27,7 +27,13 @@ const nightwatch_config = { // Disable this, as it makes bs slow and brittle. 'browserstack.networkLogs': false, 'browserstack.resolution': '1600x1200', - } + }, + screenshots : { + enabled: true, + on_failure: true, + on_error: true, + path: process.env.REPORTS_FOLDER || './test/e2e/reports', + }, }, chrome: { desiredCapabilities: { From 5f5c64870ab9ee43dda0dbdaae875caeccae3b58 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 27 Oct 2017 19:00:48 +0200 Subject: [PATCH 03/25] Stabilize e2e --- scripts/e2e-ci.sh | 3 ++ test/e2e/specs/02_admin.js | 6 ++-- test/e2e/specs/03_embedStream.js | 52 +++++++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index e0e94b4bf..f64223f32 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -1,5 +1,8 @@ #!/bin/bash +CIRCLE_TEST_REPORTS=${CIRCLE_TEST_REPORTS:-./test/e2e/reports} +CIRCLE_BRANCH=${CIRCLE_BRANCH:-master} + if [[ "${CIRCLE_BRANCH}" == "master" ]]; then exitCode=0 diff --git a/test/e2e/specs/02_admin.js b/test/e2e/specs/02_admin.js index 4a60780bb..4744d2116 100644 --- a/test/e2e/specs/02_admin.js +++ b/test/e2e/specs/02_admin.js @@ -1,9 +1,9 @@ module.exports = { '@tags': ['admin', 'login'], beforeEach: (client) => { - + client.resizeWindow(1024, 800); - }, + }, 'Admin logs in': (client) => { const adminPage = client.page.admin(); const {testData: {admin}} = client.globals; @@ -17,8 +17,6 @@ module.exports = { .waitForElementVisible('@signInButton') .click('@signInButton'); - client.pause(3000); - adminPage .waitForElementVisible('@moderationContainer'); }, diff --git a/test/e2e/specs/03_embedStream.js b/test/e2e/specs/03_embedStream.js index 57f9a8fd2..5381a5558 100644 --- a/test/e2e/specs/03_embedStream.js +++ b/test/e2e/specs/03_embedStream.js @@ -1,3 +1,31 @@ +class SortedWindowHandler { + + constructor(client) { + this.client = client; + this.client.windowHandles((result) => { + this.handles = result.value; + if (this.handles.length > 2) { + throw new Error('SortedWindowHandler must be created before new windows were created.'); + } + }); + } + + windowHandles(callback) { + this.client.windowHandles((result) => { + console.log(result); + this.handles = this.handles.filter((handle) => result.value.includes(handle)); + const remaining = result.value.filter((handle) => !this.handles.includes(handle)); + if (remaining.length === 1) { + this.handles.push(remaining[0]); + } + if (remaining.length > 1) { + throw new Error('Cannot detect new window handle, because more than one windows was created.'); + } + callback(this.handles); + }); + } +} + module.exports = { '@tags': ['embedStream', 'login'], 'creates a new asset': (client) => { @@ -18,16 +46,15 @@ module.exports = { .navigate() .getEmbedSection(); + const windowHandler = new SortedWindowHandler(client); + embed .waitForElementVisible('@signInButton') .click('@signInButton'); - client.pause(3000); - // Focusing on the Login PopUp - client.windowHandles((result) => { - const handle = result.value[1]; - client.switchWindow(handle); + windowHandler.windowHandles((handles) => { + client.switchWindow(handles[1]); }); const login = client.page.login(); @@ -45,10 +72,19 @@ module.exports = { .waitForElementVisible('@loginButton') .click('@loginButton'); + // Give a tiny bit of time to let popup close. + client.pause(50); + + if (client.capabilities.browserName === 'MicrosoftEdge') { + + // More time for edge. + // https://www.browserstack.com/automate/builds/1ceccf4efb4683b7feb890f45a32b5922b40ed3f/sessions/7393dbfda8387e43b6d5851f359b0c07db414973 + client.pause(1000); + } + // Focusing on the Embed Window - client.windowHandles((result) => { - const handle = result.value[0]; - client.switchWindow(handle); + windowHandler.windowHandles((handles) => { + client.switchWindow(handles[0]); }); }, 'user posts a comment': (client) => { From bfe82218ed44b21ffa041f7480875359c3996e22 Mon Sep 17 00:00:00 2001 From: blackcathacker Date: Sun, 29 Oct 2017 18:09:18 -0700 Subject: [PATCH 04/25] Send user an email when they are banned #1050 --- services/email/banned.html.ejs | 1 + services/email/banned.txt.ejs | 1 + services/users.js | 21 ++++++++++++++++++++- test/server/services/users.js | 21 ++++++++++++++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 services/email/banned.html.ejs create mode 100644 services/email/banned.txt.ejs diff --git a/services/email/banned.html.ejs b/services/email/banned.html.ejs new file mode 100644 index 000000000..4fd8f191c --- /dev/null +++ b/services/email/banned.html.ejs @@ -0,0 +1 @@ +<%= body.replace(/\n/g, '
') %> diff --git a/services/email/banned.txt.ejs b/services/email/banned.txt.ejs new file mode 100644 index 000000000..b36560ec5 --- /dev/null +++ b/services/email/banned.txt.ejs @@ -0,0 +1 @@ +<%= body %> diff --git a/services/users.js b/services/users.js index 9906ef6c0..2e5c66d40 100644 --- a/services/users.js +++ b/services/users.js @@ -398,7 +398,7 @@ module.exports = class UsersService { // TODO: current updating status behavior is weird. // once a user has been `APPROVED` its status cannot be // changed anymore. - return UserModel.findOneAndUpdate({ + const user = await UserModel.findOneAndUpdate({ id, status: { $ne: 'APPROVED' @@ -410,6 +410,25 @@ module.exports = class UsersService { }, { new: true, }); + + if (status === 'BANNED') { + let localProfile = user.profiles.find((profile) => profile.provider === 'local'); + if (localProfile) { + const options = + { + template: 'banned', // needed to know which template to render! + locals: { // specifies the template locals. + body: 'In accordance with The Coral Project’s community guidelines, your account has been banned. You are now longer allowed to comment, flag or engage with our community.' + }, + subject: '[Talk] Your account has been banned', + to: localProfile.id // This only works if the user has registered via e-mail. + // We may want a standard way to access a user's e-mail address in the future + }; + await MailerService.sendSimple(options); + } + + } + return user; } /** diff --git a/test/server/services/users.js b/test/server/services/users.js index dddd5eda8..b4a15e3ba 100644 --- a/test/server/services/users.js +++ b/test/server/services/users.js @@ -1,8 +1,11 @@ const UsersService = require('../../../services/users'); const SettingsService = require('../../../services/settings'); +const MailerService = require('../../../services/mailer'); const chai = require('chai'); chai.use(require('chai-as-promised')); +const sinon = require('sinon'); +chai.use(require('sinon-chai')); const expect = chai.expect; describe('services.UsersService', () => { @@ -15,7 +18,7 @@ describe('services.UsersService', () => { mockUsers = await UsersService.createLocalUsers([{ email: 'stampi@gmail.com', username: 'Stampi', - password: '1Coral!-' + password: '1Coral!-', }, { email: 'sockmonster@gmail.com', username: 'Sockmonster', @@ -25,6 +28,12 @@ describe('services.UsersService', () => { username: 'Marvel', password: '3Coral!3' }]); + + sinon.spy(MailerService, 'sendSimple'); + }); + + afterEach(() => { + MailerService.sendSimple.restore(); }); describe('#findById()', () => { @@ -149,7 +158,11 @@ describe('services.UsersService', () => { .then(() => UsersService.findById(mockUsers[0].id)) .then((user) => { expect(user).to.have.property('status', 'ACTIVE'); + }) + .then(() => { + expect(MailerService.sendSimple).to.not.have.been.called; }); + }); }); @@ -188,6 +201,12 @@ describe('services.UsersService', () => { .then(() => UsersService.findById(mockUsers[0].id)) .then((user) => { expect(user).to.have.property('status', 'BANNED'); + }) + .then(() => { + expect(MailerService.sendSimple).to.have.been.calledWithMatch({ + template: 'banned', + to: mockUsers[0].profiles[0].id + }); }); }); From 12a71fa11718d0a7863456075975a815273ca86a Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 13:11:41 +0100 Subject: [PATCH 05/25] Wait before click --- test/e2e/page_objects/embedStream.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/page_objects/embedStream.js b/test/e2e/page_objects/embedStream.js index 76065ba5e..2ee8b31fd 100644 --- a/test/e2e/page_objects/embedStream.js +++ b/test/e2e/page_objects/embedStream.js @@ -23,11 +23,13 @@ module.exports = { embed: { commands: [{ getProfileSection: function() { + this.waitForElementVisible('@profileTabButton'); this.click('@profileTabButton'); this.expect.section('@profile').to.be.present; return this.section.profile; }, getCommentsSection: function() { + this.waitForElementVisible('@commentsTabButton'); this.click('@commentsTabButton'); this.expect.section('@comments').to.be.present; return this.section.comments; From 511f4f0975f253a05cc04a52d8d197905ab94b19 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 13:26:50 +0100 Subject: [PATCH 06/25] Refactor --- test/e2e/specs/03_embedStream.js | 28 +-------------------------- test/e2e/utils/SortedWindowHandler.js | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 test/e2e/utils/SortedWindowHandler.js diff --git a/test/e2e/specs/03_embedStream.js b/test/e2e/specs/03_embedStream.js index 5381a5558..4c7e620e8 100644 --- a/test/e2e/specs/03_embedStream.js +++ b/test/e2e/specs/03_embedStream.js @@ -1,30 +1,4 @@ -class SortedWindowHandler { - - constructor(client) { - this.client = client; - this.client.windowHandles((result) => { - this.handles = result.value; - if (this.handles.length > 2) { - throw new Error('SortedWindowHandler must be created before new windows were created.'); - } - }); - } - - windowHandles(callback) { - this.client.windowHandles((result) => { - console.log(result); - this.handles = this.handles.filter((handle) => result.value.includes(handle)); - const remaining = result.value.filter((handle) => !this.handles.includes(handle)); - if (remaining.length === 1) { - this.handles.push(remaining[0]); - } - if (remaining.length > 1) { - throw new Error('Cannot detect new window handle, because more than one windows was created.'); - } - callback(this.handles); - }); - } -} +const SortedWindowHandler = require('../utils/SortedWindowHandler'); module.exports = { '@tags': ['embedStream', 'login'], diff --git a/test/e2e/utils/SortedWindowHandler.js b/test/e2e/utils/SortedWindowHandler.js new file mode 100644 index 000000000..c736547ed --- /dev/null +++ b/test/e2e/utils/SortedWindowHandler.js @@ -0,0 +1,28 @@ +class SortedWindowHandler { + + constructor(client) { + this.client = client; + this.client.windowHandles((result) => { + this.handles = result.value; + if (this.handles.length > 2) { + throw new Error('SortedWindowHandler must be created before new windows were created.'); + } + }); + } + + windowHandles(callback) { + this.client.windowHandles((result) => { + this.handles = this.handles.filter((handle) => result.value.includes(handle)); + const remaining = result.value.filter((handle) => !this.handles.includes(handle)); + if (remaining.length === 1) { + this.handles.push(remaining[0]); + } + if (remaining.length > 1) { + throw new Error('Cannot detect new window handle, because more than one windows was created.'); + } + callback(this.handles); + }); + } +} + +module.exports = SortedWindowHandler; From 0c3a9db443d0d799b1b48d67d720733f65ed4045 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 13:52:11 +0100 Subject: [PATCH 07/25] Add more console logs --- scripts/e2e-ci.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index f64223f32..f805c8e20 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -8,13 +8,17 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then exitCode=0 browserstack() { + echo "-- Start e2e for $1 --" REPORTS_FOLDER="$CIRCLE_TEST_REPORTS/$1" yarn e2e-browserstack -- --env "$1" # Determine exit code. result=$? if [ "$result" -gt "0" ] then + echo "-- Success e2e for $1 --" exitCode=$result + else + echo "-- Failed e2e for $1 --" fi # Sleep a bit to let browserstack-local to close properly. From 9af206da1a2450804df0adca7aecd05901df6e5d Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 14:08:13 +0100 Subject: [PATCH 08/25] Correct echo output --- scripts/e2e-ci.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index f805c8e20..a7cbbc23a 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -15,10 +15,10 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then result=$? if [ "$result" -gt "0" ] then - echo "-- Success e2e for $1 --" + echo "-- Failed e2e for $1 --" exitCode=$result else - echo "-- Failed e2e for $1 --" + echo "-- Success e2e for $1 --" fi # Sleep a bit to let browserstack-local to close properly. From 05b326b91c0e50ab682f103324b768c26a095688 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 14:14:49 +0100 Subject: [PATCH 09/25] Add comments --- test/e2e/utils/SortedWindowHandler.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/utils/SortedWindowHandler.js b/test/e2e/utils/SortedWindowHandler.js index c736547ed..f57856814 100644 --- a/test/e2e/utils/SortedWindowHandler.js +++ b/test/e2e/utils/SortedWindowHandler.js @@ -1,5 +1,15 @@ + +/** + * SortedWindowHandler assists in making e2e tests more robust by returning + * deterministic window handles. An instance must be created before new windows + * are created and windowHandles must be called each time a window was created or + * closed. + */ class SortedWindowHandler { + /** + * Constructor, must be called before new windows were created. + */ constructor(client) { this.client = client; this.client.windowHandles((result) => { @@ -10,6 +20,9 @@ class SortedWindowHandler { }); } + /** + * windowHandles will call given `callback` with an array of window handles. + */ windowHandles(callback) { this.client.windowHandles((result) => { this.handles = this.handles.filter((handle) => result.value.includes(handle)); From 97a8f95b93f5fcf60eb70133af04fc345217fe25 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 14:25:18 +0100 Subject: [PATCH 10/25] Use win10 for ie browsers --- nightwatch-browserstack.conf.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js index bf0ca2284..17ce3f3c0 100644 --- a/nightwatch-browserstack.conf.js +++ b/nightwatch-browserstack.conf.js @@ -59,7 +59,7 @@ const nightwatch_config = { desiredCapabilities: { browser: 'internet explorer', os: 'Windows', - os_version: '8.1', + os_version: '10', browser_version: '11', }, }, @@ -67,6 +67,8 @@ const nightwatch_config = { desiredCapabilities: { browser: 'edge', browser_version: '15', + os: 'Windows', + os_version: '10', }, }, } From 8adff1426309a362223510b20c18f22f7d8f2a76 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 15:53:52 +0100 Subject: [PATCH 11/25] Reactivate e2e on ci --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 932643ff6..9f35736c6 100644 --- a/circle.yml +++ b/circle.yml @@ -50,7 +50,7 @@ test: - MOCHA_FILE=$CIRCLE_TEST_REPORTS/junit/test-results.xml MOCHA_REPORTER=mocha-junit-reporter yarn test # Check dependancies using nsp. - nsp check - # - yarn e2e-ci + - yarn e2e-ci deployment: release: From 975fe550e0bb731fc085f746df1b6c37925b67d3 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 16:08:03 +0100 Subject: [PATCH 12/25] Harmonize local chrome headless window-size --- nightwatch.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nightwatch.conf.js b/nightwatch.conf.js index f843b881a..5c3ffcaa5 100644 --- a/nightwatch.conf.js +++ b/nightwatch.conf.js @@ -43,7 +43,7 @@ module.exports = { 'chrome-headless': { desiredCapabilities: { chromeOptions : { - args: ['--headless', '--disable-gpu', 'window-size=1280,800'], + args: ['--headless', '--disable-gpu', 'window-size=1600,1200'], }, }, }, From 53b1104cf88e5263145bb284d308e579b79dc314 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 16:09:16 +0100 Subject: [PATCH 13/25] Add little pause waiting for popup to open --- test/e2e/specs/03_embedStream.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e/specs/03_embedStream.js b/test/e2e/specs/03_embedStream.js index 4c7e620e8..53da1e87d 100644 --- a/test/e2e/specs/03_embedStream.js +++ b/test/e2e/specs/03_embedStream.js @@ -26,6 +26,10 @@ module.exports = { .waitForElementVisible('@signInButton') .click('@signInButton'); + // Wait for window to be created + // https://www.browserstack.com/automate/builds/1ceccf4efb4683b7feb890f45a32b5922b40ed3f/sessions/17b1a79682bef2498cb0be86eac317a08c976b0a#automate_button + client.pause(200); + // Focusing on the Login PopUp windowHandler.windowHandles((handles) => { client.switchWindow(handles[1]); From e091fa552ab7ba0c39c2c57ef2b109ff66bc4604 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 17:02:20 +0100 Subject: [PATCH 14/25] Upgrade selenium standalone --- nightwatch.conf.js | 6 +++--- package.json | 2 +- yarn.lock | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nightwatch.conf.js b/nightwatch.conf.js index 5c3ffcaa5..97eee0e81 100644 --- a/nightwatch.conf.js +++ b/nightwatch.conf.js @@ -9,13 +9,13 @@ module.exports = { globals_path: './test/e2e/globals', selenium: { start_process: true, - server_path: 'node_modules/selenium-standalone/.selenium/selenium-server/3.5.3-server.jar', + server_path: 'node_modules/selenium-standalone/.selenium/selenium-server/3.6.0-server.jar', log_path: './test/e2e/', host: '127.0.0.1', port: 6666, cli_args: { - 'webdriver.chrome.driver': 'node_modules/selenium-standalone/.selenium/chromedriver/2.32-x64-chromedriver', - 'webdriver.gecko.driver': 'node_modules/selenium-standalone/.selenium/geckodriver/0.18.0-x64-geckodriver', + 'webdriver.chrome.driver': 'node_modules/selenium-standalone/.selenium/chromedriver/2.33-x64-chromedriver', + 'webdriver.gecko.driver': 'node_modules/selenium-standalone/.selenium/geckodriver/0.19.0-x64-geckodriver', } }, test_settings: { diff --git a/package.json b/package.json index 3e9d5fb05..897efc819 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "redux": "^3.6.0", "redux-thunk": "^2.1.0", "resolve": "^1.4.0", - "selenium-standalone": "6.9.0", + "selenium-standalone": "^6.11.0", "semver": "^5.4.1", "simplemde": "^1.11.2", "smoothscroll-polyfill": "^0.3.5", diff --git a/yarn.lock b/yarn.lock index 6ea60fc82..7996e549f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7953,9 +7953,9 @@ select@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d" -selenium-standalone@6.9.0: - version "6.9.0" - resolved "https://registry.yarnpkg.com/selenium-standalone/-/selenium-standalone-6.9.0.tgz#5805f403c82b48b4e136d8a97f1832aad7852bd5" +selenium-standalone@^6.11.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/selenium-standalone/-/selenium-standalone-6.11.0.tgz#eb21ff65f3b2ece75061b35d4f9e7572ac0280c2" dependencies: async "^2.1.4" commander "^2.9.0" From e4688f987672112f3f353534b9aca3b2bbb3e3cc Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 19:08:42 +0100 Subject: [PATCH 15/25] Pause to let iframe load --- test/e2e/page_objects/embedStream.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/e2e/page_objects/embedStream.js b/test/e2e/page_objects/embedStream.js index 2ee8b31fd..f148ae7bc 100644 --- a/test/e2e/page_objects/embedStream.js +++ b/test/e2e/page_objects/embedStream.js @@ -8,6 +8,11 @@ module.exports = { }, getEmbedSection: function() { this.waitForElementVisible('@iframe'); + + // Pause a bit to let iframe initialize in the hope that it'll + // fix https://www.browserstack.com/automate/builds/96419cf46e3d6376a36ae6d3f90934112df1ed91/sessions/224f1a1566c1c8c7859e2e76ece51862200f0173#automate_button + this.api.pause(200); + this.api.frame(iframeId); this.expect.section('@embed').to.be.present; return this.section.embed; From 0cdefa0066f96b1f591f0d00ace0c3fbd3c81277 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 21:52:36 +0100 Subject: [PATCH 16/25] Fix wrong typed characters --- nightwatch-browserstack.conf.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js index 17ce3f3c0..65cc6cd9d 100644 --- a/nightwatch-browserstack.conf.js +++ b/nightwatch-browserstack.conf.js @@ -61,6 +61,11 @@ const nightwatch_config = { os: 'Windows', os_version: '10', browser_version: '11', + + // The x64 bit IEDriver that is used by IE 11 has a known issue with sendKeys where + // it may enter incorrect keys (shift + key). + // This adds a delay for each character as temporary fix as advised from the browserstack support. + 'browserstack.customSendKeys': 800, }, }, edge: { From 88d012755cd0d88a1dca3135d44dfd2fd44271c7 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 30 Oct 2017 23:16:23 +0100 Subject: [PATCH 17/25] Always use windows 10 --- nightwatch-browserstack.conf.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js index 65cc6cd9d..d79f6917a 100644 --- a/nightwatch-browserstack.conf.js +++ b/nightwatch-browserstack.conf.js @@ -39,12 +39,16 @@ const nightwatch_config = { desiredCapabilities: { browser: 'chrome', browser_version: '62', + os: 'Windows', + os_version: '10', }, }, firefox: { desiredCapabilities: { browser: 'firefox', browser_version: '56', + os: 'Windows', + os_version: '10', }, }, safari: { From 1578316363b50bab795389f99b8b14da74f5fbc6 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 14:25:58 +0100 Subject: [PATCH 18/25] Retry browsers when failed, print summary --- scripts/e2e-ci.sh | 60 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index a7cbbc23a..cc0146c4f 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -3,22 +3,53 @@ CIRCLE_TEST_REPORTS=${CIRCLE_TEST_REPORTS:-./test/e2e/reports} CIRCLE_BRANCH=${CIRCLE_BRANCH:-master} +MAX_RETRIES=1 + +# Safari >= 8 has issues connecting to browserstack-local. Safari < 8 is too old. +BROWSERS="chrome firefox ie edge" #safari + if [[ "${CIRCLE_BRANCH}" == "master" ]]; then + # List of failed browsers + failedBrowsers= + + # List of succeeded browsers + succeededBrowsers= + exitCode=0 browserstack() { - echo "-- Start e2e for $1 --" - REPORTS_FOLDER="$CIRCLE_TEST_REPORTS/$1" yarn e2e-browserstack -- --env "$1" + + # Current number of tries. + try=${2:-0} + + echo "-- Start e2e for $1 #$try --" + + REPORTS_FOLDER="$CIRCLE_TEST_REPORTS/$1" yarn e2e-browserstack --env "$1" # Determine exit code. result=$? - if [ "$result" -gt "0" ] - then + if [ "$result" -gt "0" ]; then echo "-- Failed e2e for $1 --" + + # Try again of MAX_RETRIES is not reached. + if [ "$try" -lt $MAX_RETRIES ]; then + let try=try+1 + browserstack "$1" "$try" + return + fi + + # Failed, add to list of failed browsers. + failedBrowsers="$failedBrowsers $1" + + # Remember exit code. exitCode=$result else echo "-- Success e2e for $1 --" + + # Succeeded, add to list of succeeded browsers. + succeededBrowsers="$succeededBrowsers $1" + eval "browser_${1}_succeeded_at=$try" fi # Sleep a bit to let browserstack-local to close properly. @@ -26,14 +57,23 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then } # Test using browserstack. - browserstack chrome - browserstack firefox - browserstack ie - browserstack edge + for browser in $BROWSERS + do + browserstack "$browser" + done - # Safari >= 8 has issues connecting to browserstack-local. Safari < 8 is too old. - # browserstack safari + # Print information about succeeded browsers. + for x in $succeededBrowsers + do + echo "Succeeded $x at try #$(eval "echo \$browser_${x}_succeeded_at")" + done + + # Print information about failed browsers. + for x in $failedBrowsers + do + echo "Failed $x" + done exit $exitCode else # When browserstack is not available test locally using chrome headless. From 42f0d76d98513264eff41a33a2fc6cb6563d132c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 14:58:25 +0100 Subject: [PATCH 19/25] Add retry number to console outpu --- scripts/e2e-ci.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index cc0146c4f..7fe912f95 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -30,7 +30,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then # Determine exit code. result=$? if [ "$result" -gt "0" ]; then - echo "-- Failed e2e for $1 --" + echo "-- Failed e2e for $1 #$try --" # Try again of MAX_RETRIES is not reached. if [ "$try" -lt $MAX_RETRIES ]; then @@ -45,7 +45,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then # Remember exit code. exitCode=$result else - echo "-- Success e2e for $1 --" + echo "-- Success e2e for $1 #$try --" # Succeeded, add to list of succeeded browsers. succeededBrowsers="$succeededBrowsers $1" From 7f442ce91e5524b2a2b03aacd145479a4a4f2471 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 14:58:40 +0100 Subject: [PATCH 20/25] Let MAX_RETRIES be customizable --- scripts/e2e-ci.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index 7fe912f95..f0eae055e 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -3,7 +3,8 @@ CIRCLE_TEST_REPORTS=${CIRCLE_TEST_REPORTS:-./test/e2e/reports} CIRCLE_BRANCH=${CIRCLE_BRANCH:-master} -MAX_RETRIES=1 +# Amount of retries before failure. +MAX_RETRIES=${MAX_RETRIES:-1} # Safari >= 8 has issues connecting to browserstack-local. Safari < 8 is too old. BROWSERS="chrome firefox ie edge" #safari @@ -33,7 +34,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then echo "-- Failed e2e for $1 #$try --" # Try again of MAX_RETRIES is not reached. - if [ "$try" -lt $MAX_RETRIES ]; then + if [ "$try" -lt "$MAX_RETRIES" ]; then let try=try+1 browserstack "$1" "$try" return From c31e6347d09ec977b313ddf35483811db4a546c8 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 16:29:32 +0100 Subject: [PATCH 21/25] Sleep between retries --- scripts/e2e-ci.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index f0eae055e..66554cf74 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -6,6 +6,9 @@ CIRCLE_BRANCH=${CIRCLE_BRANCH:-master} # Amount of retries before failure. MAX_RETRIES=${MAX_RETRIES:-1} +# Amount of seconds between tests. +SLEEP_BETWEEN_TESTS=${SLEEP_BETWEEN_TESTS:-1} + # Safari >= 8 has issues connecting to browserstack-local. Safari < 8 is too old. BROWSERS="chrome firefox ie edge" #safari @@ -36,6 +39,10 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then # Try again of MAX_RETRIES is not reached. if [ "$try" -lt "$MAX_RETRIES" ]; then let try=try+1 + + # Sleep a bit to let browserstack-local to close properly. + sleep "$SLEEP_BETWEEN_TESTS" + browserstack "$1" "$try" return fi @@ -54,7 +61,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then fi # Sleep a bit to let browserstack-local to close properly. - sleep 2 + sleep "$SLEEP_BETWEEN_TESTS" } # Test using browserstack. From 96b44b2b99e42ac71d9bea1c38bbd2e0b96da3d3 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 16:39:41 +0100 Subject: [PATCH 22/25] Prefix env variables --- scripts/e2e-ci.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index 66554cf74..6d8514797 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -4,10 +4,10 @@ CIRCLE_TEST_REPORTS=${CIRCLE_TEST_REPORTS:-./test/e2e/reports} CIRCLE_BRANCH=${CIRCLE_BRANCH:-master} # Amount of retries before failure. -MAX_RETRIES=${MAX_RETRIES:-1} +E2E_MAX_RETRIES=${E2E_MAX_RETRIES:-1} # Amount of seconds between tests. -SLEEP_BETWEEN_TESTS=${SLEEP_BETWEEN_TESTS:-1} +E2E_SLEEP_BETWEEN_TESTS=${E2E_SLEEP_BETWEEN_TESTS:-1} # Safari >= 8 has issues connecting to browserstack-local. Safari < 8 is too old. BROWSERS="chrome firefox ie edge" #safari @@ -36,12 +36,12 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then if [ "$result" -gt "0" ]; then echo "-- Failed e2e for $1 #$try --" - # Try again of MAX_RETRIES is not reached. - if [ "$try" -lt "$MAX_RETRIES" ]; then + # Try again of E2E_MAX_RETRIES is not reached. + if [ "$try" -lt "$E2E_MAX_RETRIES" ]; then let try=try+1 # Sleep a bit to let browserstack-local to close properly. - sleep "$SLEEP_BETWEEN_TESTS" + sleep "$E2E_SLEEP_BETWEEN_TESTS" browserstack "$1" "$try" return @@ -61,7 +61,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then fi # Sleep a bit to let browserstack-local to close properly. - sleep "$SLEEP_BETWEEN_TESTS" + sleep "$E2E_SLEEP_BETWEEN_TESTS" } # Test using browserstack. From d20666adb929874c70368dab0bce18d62ed313b3 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 31 Oct 2017 10:00:47 -0600 Subject: [PATCH 23/25] Update users.js Prefix added by mailer service --- services/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/users.js b/services/users.js index 2e5c66d40..e0f7d1599 100644 --- a/services/users.js +++ b/services/users.js @@ -420,7 +420,7 @@ module.exports = class UsersService { locals: { // specifies the template locals. body: 'In accordance with The Coral Project’s community guidelines, your account has been banned. You are now longer allowed to comment, flag or engage with our community.' }, - subject: '[Talk] Your account has been banned', + subject: 'Your account has been banned', to: localProfile.id // This only works if the user has registered via e-mail. // We may want a standard way to access a user's e-mail address in the future }; From 8821c0aa5c64942258c12466608bd7a24f3b49e3 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 17:33:44 +0100 Subject: [PATCH 24/25] Typos --- scripts/e2e-ci.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index 6d8514797..1ae851360 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -14,10 +14,10 @@ BROWSERS="chrome firefox ie edge" #safari if [[ "${CIRCLE_BRANCH}" == "master" ]]; then - # List of failed browsers + # List of failed browsers. failedBrowsers= - # List of succeeded browsers + # List of succeeded browsers. succeededBrowsers= exitCode=0 @@ -36,11 +36,11 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then if [ "$result" -gt "0" ]; then echo "-- Failed e2e for $1 #$try --" - # Try again of E2E_MAX_RETRIES is not reached. + # Try again until E2E_MAX_RETRIES is reached. if [ "$try" -lt "$E2E_MAX_RETRIES" ]; then let try=try+1 - # Sleep a bit to let browserstack-local to close properly. + # Sleep a bit to let browserstack-local close properly. sleep "$E2E_SLEEP_BETWEEN_TESTS" browserstack "$1" "$try" @@ -60,7 +60,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then eval "browser_${1}_succeeded_at=$try" fi - # Sleep a bit to let browserstack-local to close properly. + # Sleep a bit to let browserstack-local close properly. sleep "$E2E_SLEEP_BETWEEN_TESTS" } From bfb2da519fbb01fd20ece50b737b537f02617646 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 31 Oct 2017 17:34:28 +0100 Subject: [PATCH 25/25] Exit code can be negative --- scripts/e2e-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh index 1ae851360..e72d1a6ce 100755 --- a/scripts/e2e-ci.sh +++ b/scripts/e2e-ci.sh @@ -33,7 +33,7 @@ if [[ "${CIRCLE_BRANCH}" == "master" ]]; then # Determine exit code. result=$? - if [ "$result" -gt "0" ]; then + if [ "$result" -ne "0" ]; then echo "-- Failed e2e for $1 #$try --" # Try again until E2E_MAX_RETRIES is reached.