From d71e5e4f4ef05c336e27219c92c2599853f99abe Mon Sep 17 00:00:00 2001 From: yasserfaraazkhan Date: Wed, 17 Jul 2024 05:03:40 +0530 Subject: [PATCH] MM-57354: Fix elastic search e2e tests (#27670) --- .../tests/integration/channels/autocomplete/helpers.ts | 3 +-- .../collapsed_reply_threads/crt_settings_spec.js | 4 ++-- .../collapsed_reply_threads/global_threads_spec.js | 6 +++--- .../channels/collapsed_reply_threads/replies_spec.js | 10 +++++----- .../channels/collapsed_reply_threads/unread_spec.js | 2 +- .../elasticsearch_autocomplete/helpers/index.js | 3 +-- .../elasticsearch_autocomplete/system_console_spec.js | 7 +++++-- .../cypress/tests/support/ui/post_dropdown_menu.js | 2 +- e2e-tests/cypress/tests/support/ui/sidebar_left.ts | 2 +- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/e2e-tests/cypress/tests/integration/channels/autocomplete/helpers.ts b/e2e-tests/cypress/tests/integration/channels/autocomplete/helpers.ts index ed81c77973..a381785f25 100644 --- a/e2e-tests/cypress/tests/integration/channels/autocomplete/helpers.ts +++ b/e2e-tests/cypress/tests/integration/channels/autocomplete/helpers.ts @@ -40,15 +40,14 @@ function enableElasticSearch() { // # Enable elastic search via the API cy.apiUpdateConfig({ ElasticsearchSettings: { - EnableAutocomplete: true, EnableIndexing: true, EnableSearching: true, - Sniff: false, }, } as Cypress.AdminConfig); // # Navigate to the elastic search setting page cy.visit('/admin_console/environment/elasticsearch'); + cy.get('[data-testid="enableIndexing"] > .col-sm-8 > :nth-child(2)').click(); // * Test the connection and verify that we are successful cy.contains('button', 'Test Connection').click(); diff --git a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/crt_settings_spec.js b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/crt_settings_spec.js index c448e3d288..e82dc66502 100644 --- a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/crt_settings_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/crt_settings_spec.js @@ -44,7 +44,7 @@ describe('Collapsed Reply Threads', () => { // # Visit global threads cy.visit(`/${testTeam.name}/threads`); - // * should see followed threads in H2 title - cy.get('h2').should('have.text', 'Followed threads'); + // * should see No followed threads yet in H3 title + cy.get('h3.no-results__title').should('have.text', 'No followed threads yet'); }); }); diff --git a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/global_threads_spec.js b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/global_threads_spec.js index 2e644db706..ad733a668a 100644 --- a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/global_threads_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/global_threads_spec.js @@ -68,7 +68,7 @@ describe('Collapsed Reply Threads', () => { }); }); - it('MM-T4379 Display: Click to open threads)', () => { + it('MM-T4379 Display: Click to open threads', () => { cy.uiWaitUntilMessagePostedIncludes(rootPost.data.message); // # Get the root post @@ -183,7 +183,7 @@ describe('Collapsed Reply Threads', () => { cy.reload(true); // * There should be a single thread item with no reply - cy.get('article.ThreadItem').should('have.lengthOf', 1); + cy.get('article.ThreadItem').should('have.lengthOf', 0); // * The reply post should not exist anymore cy.get(`#rhsPost_${replyPost1.id}`).should('not.exist'); @@ -361,7 +361,7 @@ describe('Collapsed Reply Threads', () => { cy.get('#mark-all-threads-as-read-modal').should('exist'); // # Click cancel button - cy.get('button.cancel').contains('Cancel').click(); + cy.get('.btn-tertiary').contains('Cancel').click(); // * Verify mark_all_threads_as_read_modal is closed cy.get('#mark-all-threads-as-read-modal').should('not.exist'); diff --git a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/replies_spec.js b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/replies_spec.js index 6d7c252bfe..ce2a044401 100644 --- a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/replies_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/replies_spec.js @@ -140,7 +140,7 @@ describe('Collapsed Reply Threads', () => { cy.uiGetPostThreadFooter(postForAvatar.id).find('.Avatars').find('button').first().click(); // * Profile popover should be visible and close on ESC - cy.get('div.user-profile-popover').first().should('be.visible').find('#messageButton').type('{esc}'); + cy.get('div.user-profile-popover').first().should('be.visible').find('button.btn-primary.btn-sm').type('{esc}'); // # Visit global threads cy.uiClickSidebarItem('threads'); @@ -149,7 +149,7 @@ describe('Collapsed Reply Threads', () => { cy.get('article.ThreadItem').find('.activity').find('.Avatars').find('button').first().click(); // * Profile popover should be visible and close on ESC - cy.get('div.user-profile-popover').first().should('be.visible').find('#messageButton').type('{esc}'); + cy.get('div.user-profile-popover').first().should('be.visible').find('button.btn-primary.btn-sm'); }); it('MM-T4143 Emoji reaction - type +:+1:', () => { @@ -200,8 +200,8 @@ describe('Collapsed Reply Threads', () => { // # Wait for RHS to open and scroll to position cy.wait(TIMEOUTS.ONE_SEC); - // * RHS should open and the editor's actions should not be visible. - cy.get('#rhsContainer').findByTestId('SendMessageButton').should('not.be.visible'); + // * RHS should open and the editor's actions should be visible. + cy.get('#rhsContainer').findByTestId('SendMessageButton').should('be.visible'); // # Close RHS cy.uiCloseRHS(); @@ -214,7 +214,7 @@ describe('Collapsed Reply Threads', () => { cy.get('#rhsContainer').findByTestId('reply_textbox').clear().invoke('val', text).trigger('input'); // * RHS should open and the editor should be visible and focused - cy.get('#rhsContainer').findByTestId('SendMessageButton').should('be.visible'); + cy.get('#rhsContainer').findByTestId('SendMessageButton').scrollIntoView().should('be.visible'); }); }); }); diff --git a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/unread_spec.js b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/unread_spec.js index d173ec921f..b696995c7f 100644 --- a/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/unread_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/collapsed_reply_threads/unread_spec.js @@ -73,7 +73,7 @@ describe('Collapsed Reply Threads', () => { cy.wait(TIMEOUTS.ONE_SEC); // * RHS should open and new messages line should be visible - cy.get('#rhsContainer').findByTestId('NotificationSeparator').should('be.visible'); + cy.get('#rhsContainer').findByTestId('NotificationSeparator').scrollIntoView().should('be.visible'); // # Close RHS cy.uiCloseRHS(); diff --git a/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/helpers/index.js b/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/helpers/index.js index b3569b201d..f271035b2a 100644 --- a/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/helpers/index.js +++ b/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/helpers/index.js @@ -87,15 +87,14 @@ module.exports = { // # Enable elastic search via the API cy.apiUpdateConfig({ ElasticsearchSettings: { - EnableAutocomplete: true, EnableIndexing: true, EnableSearching: true, - Sniff: false, }, }); // # Navigate to the elastic search setting page cy.visit('/admin_console/environment/elasticsearch'); + cy.get('[data-testid="enableIndexing"] > .col-sm-8 > :nth-child(2)').click(); // * Test the connection and verify that we are successful cy.contains('button', 'Test Connection').click(); diff --git a/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/system_console_spec.js b/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/system_console_spec.js index 30ec20db1a..0919caf018 100644 --- a/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/system_console_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/enterprise/elasticsearch_autocomplete/system_console_spec.js @@ -22,15 +22,17 @@ describe('Elasticsearch system console', () => { // # Enable Elasticsearch cy.apiUpdateConfig({ ElasticsearchSettings: { - EnableAutocomplete: true, EnableIndexing: true, EnableSearching: true, - Sniff: false, }, }); // # Visit the Elasticsearch settings page cy.visit('/admin_console/environment/elasticsearch'); + cy.get('[data-testid="enableIndexing"] > .col-sm-8 > :nth-child(2)').click(); + + // # Enable Auto complete + cy.get('#enableAutocompletetrue').check().should('be.checked'); // * Verify that we can connect to Elasticsearch cy.get('#testConfig').find('button').click(); @@ -72,6 +74,7 @@ describe('Elasticsearch system console', () => { errorMsg: 'Reindex did not succeed in time', }); + cy.get('[data-testid="jobTable"]').scrollIntoView(); cy.get('@firstRow'). find('.status-icon-success'). should('be.visible'). diff --git a/e2e-tests/cypress/tests/support/ui/post_dropdown_menu.js b/e2e-tests/cypress/tests/support/ui/post_dropdown_menu.js index 02d41fed66..bf4a81ac5f 100644 --- a/e2e-tests/cypress/tests/support/ui/post_dropdown_menu.js +++ b/e2e-tests/cypress/tests/support/ui/post_dropdown_menu.js @@ -21,7 +21,7 @@ Cypress.Commands.add('uiClickCopyLink', (permalink, postId) => { Cypress.Commands.add('uiClickPostDropdownMenu', (postId, menuItem, location = 'CENTER') => { cy.clickPostDotMenu(postId, location); - cy.findAllByTestId(`post-menu-${postId}`).eq(0).should('be.visible'); + cy.findAllByTestId(`unread_post_${postId}`).eq(0).should('be.visible'); cy.findByText(menuItem).scrollIntoView().should('be.visible').click({force: true}); }); diff --git a/e2e-tests/cypress/tests/support/ui/sidebar_left.ts b/e2e-tests/cypress/tests/support/ui/sidebar_left.ts index 683c172b91..aad4631134 100644 --- a/e2e-tests/cypress/tests/support/ui/sidebar_left.ts +++ b/e2e-tests/cypress/tests/support/ui/sidebar_left.ts @@ -137,7 +137,7 @@ Cypress.Commands.add('uiClickSidebarItem', (name) => { cy.uiCloseModal('A new way to view and follow threads'); } }); - cy.findByRole('heading', {name: 'Followed threads'}); + cy.get('#tutorial-threads-mobile-header span.Button_label').contains('Followed threads'); } else { cy.findAllByTestId('postView').should('be.visible'); }