From a2470fa01bf9d9d60f54ebf4e4055cab9d84dc6a Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 7 Nov 2017 16:43:58 -0300 Subject: [PATCH] More --- .../src/components/BanUserDialog.js | 46 +++++++++---------- client/coral-ui/components/Dialog.js | 4 +- .../client/components/BanUserDialog.js | 26 +++++++++-- test/e2e/page_objects/embedStream.js | 46 +++++++++++++++++-- test/e2e/specs/04_banUser.js | 28 +++++++++-- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/client/coral-admin/src/components/BanUserDialog.js b/client/coral-admin/src/components/BanUserDialog.js index 032330833..61fa3ca9d 100644 --- a/client/coral-admin/src/components/BanUserDialog.js +++ b/client/coral-admin/src/components/BanUserDialog.js @@ -15,30 +15,28 @@ const BanUserDialog = ({open, onCancel, onPerform, username, info}) => ( onCancel={onCancel} title={t('bandialog.ban_user')}> × -
-
-

{t('bandialog.ban_user')}

-
-
-

{t('bandialog.are_you_sure', username)}

- {info} -
-
- - -
+
+

{t('bandialog.ban_user')}

+
+
+

{t('bandialog.are_you_sure', username)}

+ {info} +
+
+ +
); diff --git a/client/coral-ui/components/Dialog.js b/client/coral-ui/components/Dialog.js index 93431db4c..a7d34a512 100644 --- a/client/coral-ui/components/Dialog.js +++ b/client/coral-ui/components/Dialog.js @@ -10,12 +10,12 @@ export default class Dialog extends Component { onCancel: PropTypes.func, onClose: PropTypes.func, open: PropTypes.bool, - style: PropTypes.object + style: PropTypes.object, }; static defaultProps = { onCancel: (e) => e.preventDefault(), - onClose: (e) => e.preventDefault() + onClose: (e) => e.preventDefault(), }; componentDidMount(){ diff --git a/plugins/talk-plugin-moderation-actions/client/components/BanUserDialog.js b/plugins/talk-plugin-moderation-actions/client/components/BanUserDialog.js index 702ee4b10..c98e3e7c2 100644 --- a/plugins/talk-plugin-moderation-actions/client/components/BanUserDialog.js +++ b/plugins/talk-plugin-moderation-actions/client/components/BanUserDialog.js @@ -1,10 +1,12 @@ import React from 'react'; +import PropTypes from 'prop-types'; +import cn from 'classnames'; import styles from './BanUserDialog.css'; import {t} from 'plugin-api/beta/client/services'; import {Dialog, Button} from 'plugin-api/beta/client/components/ui'; -export default ({showBanDialog, closeBanDialog, banUser}) => ( - +const BanUserDialog = ({showBanDialog, closeBanDialog, banUser}) => ( + ×

{t('talk-plugin-moderation-actions.ban_user_dialog_headline')}

{t('talk-plugin-moderation-actions.ban_user_dialog_sub')}

@@ -12,12 +14,28 @@ export default ({showBanDialog, closeBanDialog, banUser}) => ( {t('talk-plugin-moderation-actions.ban_user_dialog_copy')}

- -
); + +BanUserDialog.propTypes = { + showBanDialog: PropTypes.func.isRequired, + closeBanDialog: PropTypes.func.isRequired, + banUser: PropTypes.func.isRequired, +}; + +export default BanUserDialog; \ No newline at end of file diff --git a/test/e2e/page_objects/embedStream.js b/test/e2e/page_objects/embedStream.js index b99faf341..a8648b890 100644 --- a/test/e2e/page_objects/embedStream.js +++ b/test/e2e/page_objects/embedStream.js @@ -2,16 +2,50 @@ const iframeId = 'coralStreamEmbed_iframe'; module.exports = { commands: [{ - navigateToAsset: function(asset) { + navigateToAsset(asset) { this.api.url(`${this.api.launchUrl}/assets/title/${asset}`); return this; }, - getEmbedSection: function() { + getEmbedSection() { this.waitForElementVisible('@iframe'); this.api.frame(iframeId); this.expect.section('@embed').to.be.present; return this.section.embed; }, + login(user = {}) { + const embedStream = this.page.embedStream(); + + const embed = embedStream + .navigate() + .getEmbedSection(); + + embed + .waitForElementVisible('@signInButton') + .click('@signInButton'); + + this.pause(3000); + + // Focusing on the Login PopUp + this.windowHandles((result) => { + const handle = result.value[1]; + this.switchWindow(handle); + }); + + const login = this.page.login(); + + login + .setValue('@emailInput', user.email) + .setValue('@passwordInput', user.password) + .waitForElementVisible('@signIn') + .waitForElementVisible('@loginButton') + .click('@loginButton'); + + // Focusing on the Embed Window + this.windowHandles((result) => { + const handle = result.value[0]; + this.switchWindow(handle); + }); + }, }], url: function() { return this.api.launchUrl; @@ -22,12 +56,12 @@ module.exports = { sections: { embed: { commands: [{ - getProfileSection: function() { + getProfileSection() { this.click('@profileTabButton'); this.expect.section('@profile').to.be.present; return this.section.profile; }, - getCommentsSection: function() { + getCommentsSection() { this.click('@commentsTabButton'); this.expect.section('@comments').to.be.present; return this.section.comments; @@ -64,7 +98,9 @@ module.exports = { elements: { arrow: '.talk-plugin-moderation-actions-arrow', menu: '.talk-plugin-modetarion-actions-menu', - banButton: 'talk-plugin-moderation-actions-ban', + banButton: '.talk-plugin-moderation-actions-ban', + banDialog: '.talk-ban-user-dialog', + banDialogbanButton: '.talk-ban-user-dialog-button-ban', }, }, profile: { diff --git a/test/e2e/specs/04_banUser.js b/test/e2e/specs/04_banUser.js index 598460e30..776093692 100644 --- a/test/e2e/specs/04_banUser.js +++ b/test/e2e/specs/04_banUser.js @@ -1,4 +1,5 @@ module.exports = { + 'admin logs in': (client) => { const adminPage = client.page.admin(); const {testData: {admin}} = client.globals; @@ -24,7 +25,7 @@ module.exports = { .navigate() .getEmbedSection(); }, - 'ban': (client) => { + 'admin bans user': (client) => { const modSection = client.page.embedStream().section.embed.section.mod; modSection @@ -32,6 +33,27 @@ module.exports = { .click('@arrow') .waitForElementVisible('@menu') .waitForElementVisible('@banButton') - .click('@banButton'); - } + .click('@banButton') + .waitForElementVisible('@banDialog') + .waitForElementVisible('@banDialogbanButton') + .click('@banDialogbanButton') + .waitForElementNotVisible('@banDialog'); + }, + 'user logs in': (client) => { + const {testData: {user}} = client.globals; + const embedStream = client.page.embedStream(); + + embedStream + .login(user); + }, + 'user account is banned, should see restricted message box': (client) => { + const embedStream = client.page.embedStream(); + + const embed = embedStream + .navigate() + .getEmbedSection(); + + embed + .waitForElementVisible('@restrictedMessageBox'); + }, };