From e1ead8f500f4b8a226be8838096d0a1c6c03415a Mon Sep 17 00:00:00 2001 From: okbel Date: Wed, 10 Jan 2018 11:43:34 -0300 Subject: [PATCH] Adding e2e for the stream - open and closed asset features --- .../src/components/Embed.js | 4 +-- .../configure/components/AssetStatusInfo.js | 8 +++-- test/e2e/page_objects/embedStream.js | 29 +++++++++++++++++++ test/e2e/specs/03_embedStream.js | 14 +++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/client/coral-embed-stream/src/components/Embed.js b/client/coral-embed-stream/src/components/Embed.js index 4d95c6697..22c6146bd 100644 --- a/client/coral-embed-stream/src/components/Embed.js +++ b/client/coral-embed-stream/src/components/Embed.js @@ -38,7 +38,7 @@ export default class Embed extends React.Component { ]; if (can(user, 'UPDATE_CONFIG')) { tabs.push( - + {t('framework.configure_stream')} ); @@ -90,7 +90,7 @@ export default class Embed extends React.Component { , - + , ]} diff --git a/client/coral-embed-stream/src/tabs/configure/components/AssetStatusInfo.js b/client/coral-embed-stream/src/tabs/configure/components/AssetStatusInfo.js index d3c2f14d7..81221dfe3 100644 --- a/client/coral-embed-stream/src/tabs/configure/components/AssetStatusInfo.js +++ b/client/coral-embed-stream/src/tabs/configure/components/AssetStatusInfo.js @@ -46,14 +46,16 @@ class AssetStatusInfo extends React.Component { render() { const {isClosed, closedAt, onClose, onOpen} = this.props; return ( -
+

{!isClosed ? t('configure.close') : t('configure.open')} {t('configure.comment_stream')}

{(!isClosed && closedAt) ?

{t('configure.comment_stream_will_close')} {timeago(new Date(closedAt))}.

: ''} -
+

{!isClosed ? t('configure.open_stream_configuration') : t('configure.close_stream_configuration')}

-
diff --git a/test/e2e/page_objects/embedStream.js b/test/e2e/page_objects/embedStream.js index 0a31745e4..4b1519740 100644 --- a/test/e2e/page_objects/embedStream.js +++ b/test/e2e/page_objects/embedStream.js @@ -8,6 +8,12 @@ module.exports = { this.expect.section('@comments').to.be.visible; return this.section.comments; }, + goToConfigSection: function() { + this.waitForElementVisible('@configTabButton'); + this.click('@configTabButton'); + this.expect.section('@config').to.be.visible; + return this.section.config; + }, goToProfileSection: function() { this.waitForElementVisible('@profileTabButton'); this.click('@profileTabButton'); @@ -42,6 +48,7 @@ module.exports = { iframe: `#${iframeId}`, commentsTabButton: '.talk-embed-stream-comments-tab > button', profileTabButton: '.talk-embed-stream-profile-tab > button', + configTabButton: '.talk-embed-stream-profile-tab > button', banDialog: '.talk-ban-user-dialog', banDialogConfirmButton: '.talk-ban-user-dialog-button-confirm', }, @@ -95,6 +102,7 @@ module.exports = { firstComment: '.talk-stream-comment.talk-stream-comment-level-0', firstCommentContent: '.talk-stream-comment.talk-stream-comment-level-0 .talk-stream-comment-content', flagButton: '.talk-stream-comment.talk-stream-comment-level-0 .talk-plugin-flags-button', + replyButton: '.talk-stream-comment.talk-stream-comment-level-0 .talk-plugin-replies-reply-button', respectButton: '.talk-stream-comment.talk-stream-comment-level-0 .talk-stream-comment-footer .talk-plugin-respect-button', restrictedMessageBox: '.talk-restricted-message-box', suspendedAccountInput: '.talk-suspended-account-username-input', @@ -132,5 +140,26 @@ module.exports = { myCommentHistoryComment: '.talk-my-profile-comment-history .my-comment-body', }, }, + config: { + selector: '.talk-embed-stream-config-tab-pane', + elements: { + openStream: '.talk-config-close-comments-open-button', + closeStream: '.talk-config-close-comments-close-button', + }, + commands: [{ + openStream: function() { + this.waitForElementVisible('@openStream'); + this.click('@openStream'); + this.waitForElementVisible('@closeStream'); + return this.section.config; + }, + closeStream: function() { + this.waitForElementVisible('@closeStream'); + this.click('@closeStream'); + this.waitForElementVisible('@openStream'); + return this.section.config; + }, + }] + }, }, }; diff --git a/test/e2e/specs/03_embedStream.js b/test/e2e/specs/03_embedStream.js index 56f267375..db3b8bcef 100644 --- a/test/e2e/specs/03_embedStream.js +++ b/test/e2e/specs/03_embedStream.js @@ -96,6 +96,20 @@ module.exports = { profile.assert.equal(result.value, '1'); }); }, + 'stream is closed, user won\'t be able to perform some actions: reply ': (client) => { + + const embedStream = client.page.embedStream(); + + embedStream + .waitForElementVisible('@firstComment') + .waitForElementVisible('@replyButton') + .goToProfileSection() + .closeStream() + .goToCommentsSection() + .waitForElementVisible('@firstComment') + .waitForElementNotVisible('@replyButton') + .openStream(); + }, 'user logs out': (client) => { const embedStream = client.page.embedStream(); const comments = embedStream.goToCommentsSection();