From d65c2c8a7a8180786d77a67fbff445d5b804ed0a Mon Sep 17 00:00:00 2001 From: Ashish Bhate Date: Wed, 7 Oct 2020 18:03:04 +0530 Subject: [PATCH 1/5] [MM-27231]: cypress test for MM-T1837 --- .../integration/messaging/header_spec.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/e2e/cypress/integration/messaging/header_spec.js b/e2e/cypress/integration/messaging/header_spec.js index 43b9c62d35bd..9c7f76f2b57b 100644 --- a/e2e/cypress/integration/messaging/header_spec.js +++ b/e2e/cypress/integration/messaging/header_spec.js @@ -94,6 +94,33 @@ describe('Header', () => { // # Verify that the Search term input box is still cleared and search term does not reappear when RHS opens cy.get('#searchBox').should('have.attr', 'value', '').and('be.empty'); }); + + it('MM-T1837 - DM channel with bot displays a normal header', () => { + cy.apiAdminLogin(); + + // # Enable Bots + cy.apiUpdateConfig({ + ServiceSettings: { + EnableBotAccountCreation: true, + }, + }); + + // # Create a bot + const botUsername = 'a-bot-to-dm' + Date.now(); + const description = 'A bot to DM'; + cy.apiCreateBot(botUsername, 'Bot To DM', description); + + // # Open a DM with the bot + cy.get('#addDirectChannel').click().wait(TIMEOUTS.HALF_SEC); + cy.focused().type(botUsername, {force: true}).type('{enter}', {force: true}).wait(TIMEOUTS.HALF_SEC); + cy.get('#saveItems').click().wait(TIMEOUTS.HALF_SEC); + + // * Verify Channel Header is visible + cy.get('#channelHeaderInfo').should('be.visible'); + + // # Verify header content + cy.get('#channelHeaderDescription > .header-description__text').find('p').should('have.text', description); + }); }); function updateAndVerifyChannelHeader(prefix, header) { From d099bf6ffc3f672fa6c776484466f87c60a8407f Mon Sep 17 00:00:00 2001 From: Ashish Bhate Date: Wed, 7 Oct 2020 18:06:27 +0530 Subject: [PATCH 2/5] fix comment format --- e2e/cypress/integration/messaging/header_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/cypress/integration/messaging/header_spec.js b/e2e/cypress/integration/messaging/header_spec.js index 9c7f76f2b57b..05b702f47ee0 100644 --- a/e2e/cypress/integration/messaging/header_spec.js +++ b/e2e/cypress/integration/messaging/header_spec.js @@ -118,7 +118,7 @@ describe('Header', () => { // * Verify Channel Header is visible cy.get('#channelHeaderInfo').should('be.visible'); - // # Verify header content + // * Verify header content cy.get('#channelHeaderDescription > .header-description__text').find('p').should('have.text', description); }); }); From d71babf5ebc281a6d52c94312e1b06583ced4842 Mon Sep 17 00:00:00 2001 From: Ashish Bhate Date: Thu, 8 Oct 2020 19:00:21 +0530 Subject: [PATCH 3/5] Add tests for plugin bots --- .../integration/messaging/header_spec.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/e2e/cypress/integration/messaging/header_spec.js b/e2e/cypress/integration/messaging/header_spec.js index 05b702f47ee0..b015f107e10e 100644 --- a/e2e/cypress/integration/messaging/header_spec.js +++ b/e2e/cypress/integration/messaging/header_spec.js @@ -121,6 +121,40 @@ describe('Header', () => { // * Verify header content cy.get('#channelHeaderDescription > .header-description__text').find('p').should('have.text', description); }); + + it('MM-T1837 - DM channel with bot from plugin displays a normal header', () => { + cy.apiAdminLogin(); + + // # Enable Bots and plugins + cy.apiUpdateConfig({ + ServiceSettings: { + EnableBotAccountCreation: true, + }, + PluginSettings: { + Enable: true, + RequirePluginSignature: false, + }, + }); + + // # Try to remove the plugin, just in case + cy.apiRemovePluginById('com.github.matterpoll.matterpoll'); + + // # Upload and enable "matterpoll" plugin + cy.apiUploadPlugin('com.github.matterpoll.matterpoll.tar.gz').then(() => { + cy.apiEnablePluginById('com.github.matterpoll.matterpoll'); + }); + + // # Open a DM with the bot + cy.get('#addDirectChannel').click().wait(TIMEOUTS.HALF_SEC); + cy.focused().type('matterpoll', {force: true}).type('{enter}', {force: true}).wait(TIMEOUTS.HALF_SEC); + cy.get('#saveItems').click().wait(TIMEOUTS.HALF_SEC); + + // * Verify Channel Header is visible + cy.get('#channelHeaderInfo').should('be.visible'); + + // * Verify header content + cy.get('#channelHeaderDescription > .header-description__text').find('p').should('have.text', 'Poll Bot'); + }); }); function updateAndVerifyChannelHeader(prefix, header) { From 92e6f022dbdb96a059eff06897160461c72af3b9 Mon Sep 17 00:00:00 2001 From: Ashish Bhate Date: Thu, 8 Oct 2020 19:18:08 +0530 Subject: [PATCH 4/5] clean up after test --- e2e/cypress/integration/messaging/header_spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e/cypress/integration/messaging/header_spec.js b/e2e/cypress/integration/messaging/header_spec.js index b015f107e10e..79f2e40fbbda 100644 --- a/e2e/cypress/integration/messaging/header_spec.js +++ b/e2e/cypress/integration/messaging/header_spec.js @@ -154,6 +154,9 @@ describe('Header', () => { // * Verify header content cy.get('#channelHeaderDescription > .header-description__text').find('p').should('have.text', 'Poll Bot'); + + // # Clean up, uninstall "matterpoll" plugin + cy.apiRemovePluginById('com.github.matterpoll.matterpoll'); }); }); From bd24e5e5a680726a202c38599da1bc48bb78da3c Mon Sep 17 00:00:00 2001 From: Ashish Bhate Date: Tue, 13 Oct 2020 11:04:10 +0000 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Joseph Baylon --- e2e/cypress/integration/messaging/header_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/cypress/integration/messaging/header_spec.js b/e2e/cypress/integration/messaging/header_spec.js index 79f2e40fbbda..71a1b595290e 100644 --- a/e2e/cypress/integration/messaging/header_spec.js +++ b/e2e/cypress/integration/messaging/header_spec.js @@ -95,7 +95,7 @@ describe('Header', () => { cy.get('#searchBox').should('have.attr', 'value', '').and('be.empty'); }); - it('MM-T1837 - DM channel with bot displays a normal header', () => { + it('MM-T1837_1 - DM channel with bot displays a normal header', () => { cy.apiAdminLogin(); // # Enable Bots @@ -122,7 +122,7 @@ describe('Header', () => { cy.get('#channelHeaderDescription > .header-description__text').find('p').should('have.text', description); }); - it('MM-T1837 - DM channel with bot from plugin displays a normal header', () => { + it('MM-T1837_2 - DM channel with bot from plugin displays a normal header', () => { cy.apiAdminLogin(); // # Enable Bots and plugins