From a118d263ea54a369cf3b4140609d4ac5083e876b Mon Sep 17 00:00:00 2001 From: David Jay Date: Thu, 1 Dec 2016 16:23:33 -0500 Subject: [PATCH] Cleaning url regex in commentstream. --- bin/cli-serve | 3 ++- .../coral-embed-stream/src/CommentStream.js | 2 +- client/coral-plugin-commentbox/CommentBox.js | 1 + package.json | 4 ++-- pree2e.sh | 1 - tests/e2e/globals.js | 2 +- tests/e2e/tests/EmbedStreamTests.js | 20 +++++++++---------- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/bin/cli-serve b/bin/cli-serve index 14c1261d7..a6790c6a0 100755 --- a/bin/cli-serve +++ b/bin/cli-serve @@ -17,7 +17,8 @@ const util = require('../util'); /** * Get port from environment and store in Express. */ -const port = normalizePort(process.env.TALK_PORT || '3000'); + +const port = normalizePort(process.env.TALK_PORT || (process.env.NODE_ENV === 'test' ? '3011' : '3000')); app.set('port', port); diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 2413a73a2..a5047c959 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -61,7 +61,7 @@ class CommentStream extends Component { const path = /https?\:\/\/([^?#]+)/.exec(this.pym.parentUrl); - this.props.getStream(path || window.location); + this.props.getStream(path[1] || window.location); this.path = path; this.pym.sendMessage('childReady'); diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index 9ae524652..5f9592cd5 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -78,6 +78,7 @@ class CommentBox extends Component { { author && ( diff --git a/package.json b/package.json index 1d5448070..be6c2b153 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "lint-fix": "eslint . --fix", "test": "NODE_ENV=test mocha --compilers js:babel-core/register --recursive tests", "test-watch": "NODE_ENV=test mocha --compilers js:babel-core/register --recursive -w tests", - "pree2e": "./pree2e.sh", - "e2e": "source .env-test && node_modules/.bin/nightwatch", + "pree2e": "NODE_ENV=test ./pree2e.sh", + "e2e": "NODE_ENV=test node_modules/.bin/nightwatch", "embed-start": "NODE_ENV=development npm run build && ./bin/cli serve --jobs" }, "config": { diff --git a/pree2e.sh b/pree2e.sh index 269e7cdb5..8857e5745 100755 --- a/pree2e.sh +++ b/pree2e.sh @@ -1,3 +1,2 @@ node_modules/selenium-standalone/bin/selenium-standalone install -source .env-test npm start & diff --git a/tests/e2e/globals.js b/tests/e2e/globals.js index d90f024a4..147af2663 100644 --- a/tests/e2e/globals.js +++ b/tests/e2e/globals.js @@ -1,4 +1,4 @@ module.exports = { waitForConditionTimeout: 20000, - baseUrl: 'http://localhost:3011' + baseUrl: 'localhost:3011/' }; diff --git a/tests/e2e/tests/EmbedStreamTests.js b/tests/e2e/tests/EmbedStreamTests.js index 001264f9f..65ea9fa76 100644 --- a/tests/e2e/tests/EmbedStreamTests.js +++ b/tests/e2e/tests/EmbedStreamTests.js @@ -37,11 +37,11 @@ module.exports = { .click('#coralSignUpButton') .waitForElementVisible('#coralLogInButton', 10000) .click('#coralLogInButton') - .waitForElementVisible('#commentBox .coral-plugin-commentbox-button', 3000) + .waitForElementVisible('.coral-plugin-commentbox-button', 4000) // Post a comment - .setValue('#commentBox .coral-plugin-commentbox-textarea', mockComment) - .click('#commentBox .coral-plugin-commentbox-button') + .setValue('.coral-plugin-commentbox-textarea', mockComment) + .click('.coral-plugin-commentbox-button') .waitForElementVisible('.comment', 1000) //Verify that it appears @@ -63,9 +63,9 @@ module.exports = { .frame('coralStreamIframe'); // Post a comment - client.waitForElementVisible('#commentBox .coral-plugin-commentbox-button', 2000) - .setValue('#commentBox .coral-plugin-commentbox-textarea', mockComment) - .click('#commentBox .coral-plugin-commentbox-button') + client.waitForElementVisible('.coral-plugin-commentbox-button', 2000) + .setValue('.coral-plugin-commentbox-textarea', mockComment) + .click('.coral-plugin-commentbox-button') .waitForElementVisible('#coral-notif', 1000) //Verify that it appears @@ -88,9 +88,9 @@ module.exports = { .frame('coralStreamIframe'); // Post a comment - client.waitForElementVisible('#commentBox .coral-plugin-commentbox-button', 2000) - .setValue('#commentBox .coral-plugin-commentbox-textarea', mockComment) - .click('#commentBox .coral-plugin-commentbox-button') + client.waitForElementVisible('.coral-plugin-commentbox-button', 2000) + .setValue('.coral-plugin-commentbox-textarea', mockComment) + .click('.coral-plugin-commentbox-button') // Post a reply .waitForElementVisible('.coral-plugin-replies-reply-button', 5000) @@ -162,7 +162,7 @@ module.exports = { // Verify that comment count is correct client.waitForElementVisible('.coral-plugin-comment-count-text', 2000) - .assert.containsText('.coral-plugin-comment-count-text', '5 Comments'); + .assert.containsText('.coral-plugin-comment-count-text', '1 Comment'); done(); }); },