From ebda51dc0f8a1aca7101edbc7553f40903d442d0 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 10 Nov 2017 10:26:54 -0300 Subject: [PATCH] Adding suspension test --- test/e2e/page_objects/admin.js | 16 ++++ test/e2e/page_objects/embedStream.js | 2 + test/e2e/specs/06_suspendUser.js | 120 +++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 test/e2e/specs/06_suspendUser.js diff --git a/test/e2e/page_objects/admin.js b/test/e2e/page_objects/admin.js index b73c1f0e1..f0ccd9f29 100644 --- a/test/e2e/page_objects/admin.js +++ b/test/e2e/page_objects/admin.js @@ -14,6 +14,12 @@ module.exports = { this.expect.section('@drawer').to.be.visible; return this.section.drawer; }, + goToModerate() { + this + .click('@moderateNav') + .expect.section('@moderate').to.be.visible; + return this.section.stories; + }, goToStories() { this .click('@storiesNav') @@ -45,12 +51,22 @@ module.exports = { 'drawerOverlay': 'div.mdl-layout__obfuscator.is-visible', 'storiesNav': '.talk-admin-nav-stories', 'communityNav': '.talk-admin-nav-community', + 'moderateNav': '.talk-admin-nav-moderate', 'settingsButton': '.talk-admin-header-settings-button', 'signOutButton': '.talk-admin-header-sign-out', }, sections: { moderate: { selector: '.talk-admin-moderation-container', + elements: { + suspendUserDialog: '.talk-admin-suspend-user-dialog', + suspendUserConfirmButton: 'talk-admin-suspend-user-dialog-confirm', + supendUserSendButton: 'talk-admin-suspend-user-dialog-send', + comment: '.talk-admin-moderate-comment', + commentActionMenu: '.talk-admin-moderate-comment-actions-menu', + actionItemSuspendUser: '.talk-admin-moderate-comment-actions-menu .action-menu-item#supendUser', + actionMenuButton: '.talk-admin-moderate-comment-actions-menu #actions-dropdown-0' + } }, stories: { selector: '.talk-admin-stories', diff --git a/test/e2e/page_objects/embedStream.js b/test/e2e/page_objects/embedStream.js index ccf7a8522..1cecad2a3 100644 --- a/test/e2e/page_objects/embedStream.js +++ b/test/e2e/page_objects/embedStream.js @@ -117,8 +117,10 @@ module.exports = { elements: { offensiveUsernameRadio: '.talk-plugin-flags-popup-radio#USERNAME_OFFENSIVE', flagUsernameRadio: '.talk-plugin-flags-popup-radio#USERS', + flagCommentRadio: '.talk-plugin-flags-popup-radio#COMMENTS', continueButton: '.talk-plugin-flags-popup-button', popUpText: '.talk-plugin-flags-popup-text', + spamCommentRadio: '.talk-plugin-flags-popup-radio#COMMENT_SPAM', } }, mod: { diff --git a/test/e2e/specs/06_suspendUser.js b/test/e2e/specs/06_suspendUser.js new file mode 100644 index 000000000..8aeaf1574 --- /dev/null +++ b/test/e2e/specs/06_suspendUser.js @@ -0,0 +1,120 @@ +module.exports = { + + before: (client) => { + client.resizeWindow(1600, 1200); + }, + + afterEach: (client, done) => { + if (client.currentTest.results.failed) { + throw new Error('Test Case failed, skipping all the rest'); + } + done(); + }, + + after: (client) => { + client.end(); + }, + 'user logs in': (client) => { + const {testData: {user}} = client.globals; + const comments = client.page.embedStream().section.comments; + + comments + .openLoginPopup((popup) => popup.login(user)); + }, + 'user posts comment': (client) => { + const comments = client.page.embedStream().section.comments; + const {testData: {comment}} = client.globals; + + comments + .waitForElementVisible('@commentBoxTextarea') + .setValue('@commentBoxTextarea', comment.body) + .waitForElementVisible('@commentBoxPostButton') + .click('@commentBoxPostButton') + .waitForElementVisible('@firstCommentContent') + .getText('@firstCommentContent', (result) => { + comments.assert.equal(result.value, comment.body); + }); + }, + 'user logs out': (client) => { + const embedStream = client.page.embedStream(); + const comments = embedStream.section.comments; + + comments + .logout(); + }, + 'admin logs in': (client) => { + const adminPage = client.page.admin(); + const {testData: {admin}} = client.globals; + + adminPage.navigateAndLogin(admin); + }, + 'navigate to the embed stream': (client) => { + const embedStream = client.page.embedStream(); + + embedStream + .navigate() + .ready(); + }, + 'admin reports comment': (client) => { + const embedStream = client.page.embedStream(); + const comments = embedStream.section.comments; + + comments + .waitForElementVisible('@firstComment') + .waitForElementVisible('@flagButton') + .click('@flagButton'); + + comments.section.flag + .waitForElementVisible('@flagCommentRadio') + .click('@flagCommentRadio') + .waitForElementVisible('@continueButton') + .click('@continueButton') + .waitForElementVisible('@spamCommentRadio') + .click('@spamCommentRadio') + .click('@continueButton') + .waitForElementVisible('@popUpText') + .click('@continueButton'); + }, + 'admin suspends user': (client) => { + const adminPage = client.page.admin(); + const moderate = adminPage.section.moderate; + + adminPage + .navigate() + .ready() + .goToModerate(); + + moderate + .waitForElementVisible('@comment') + .waitForElementVisible('@commentActionMenu') + .waitForElementVisible('@actionMenuButton') + .click('@actionMenuButton') + .waitForElementVisible('@actionItemSuspendUser') + .click('@actionItemSuspendUser') + .waitForElementVisible('@suspendUserDialog') + .waitForElementVisible('@suspendUserConfirmButton') + .click('@suspendUserConfirmButton') + .waitForElementVisible('@supendUserSendButton') + .click('@supendUserSendButton'); + }, + 'admin logs out': (client) => { + const comments = client.page.embedStream().section.comments; + + comments + .logout(); + }, + 'user logs in (2)': (client) => { + const {testData: {user}} = client.globals; + const comments = client.page.embedStream().section.comments; + + comments + .openLoginPopup((popup) => popup.login(user)); + }, + 'user account is suspended, should see restricted message box': (client) => { + const embedStream = client.page.embedStream(); + const comments = embedStream.section.comments; + + comments + .waitForElementVisible('@restrictedMessageBox'); + }, +};