From f1f54508f414275226409691aa8a690889a723cb Mon Sep 17 00:00:00 2001 From: Furqan Malik Date: Mon, 3 Apr 2023 18:22:48 -0400 Subject: [PATCH] Fixed Add Channel_test_cases (#22768) * Fixed Add Channel_test_cases * fixed more test cases * fixed lint --- .../accessibility/accessibility_sidebar_spec.ts | 2 +- .../channel_sidebar/category_sorting_1_spec.ts | 2 +- .../channels/channel_sidebar/category_sorting_spec.ts | 2 +- .../channels/channel_sidebar/custom_categories_spec.ts | 2 +- .../channel_sidebar/new_channel_dropdown_spec.ts | 2 +- .../channels/emoji/recently_used_emoji_1_spec.ts | 10 ++++++++-- .../accessibility/accessibility_input_fields_spec.js | 2 +- .../channels/enterprise/ldap/ldap_guest_spec.js | 4 ++-- .../system_scheme_permission_part2_spec.js | 6 +++--- .../integration/channels/mark_as_unread/helpers.js | 1 + e2e-tests/cypress/tests/support/ui/sidebar_left.ts | 4 ++-- 11 files changed, 22 insertions(+), 15 deletions(-) diff --git a/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_sidebar_spec.ts b/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_sidebar_spec.ts index 9c67b1250b..232f62acdf 100644 --- a/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_sidebar_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/accessibility/accessibility_sidebar_spec.ts @@ -69,7 +69,7 @@ describe('Verify Accessibility Support in Channel Sidebar Navigation', () => { cy.uiGetLHSAddChannelButton().focus().tab().tab({shift: true}); // * Verify if the Plus button has focus - cy.findByRole('button', {name: 'Add Channel Dropdown'}).should('be.focused'); + cy.uiGetLHSAddChannelButton().should('be.focused'); cy.focused().tab(); // * Verify if the Plus button has focus diff --git a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_1_spec.ts b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_1_spec.ts index bf2f6e9011..f7b71b4115 100644 --- a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_1_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_1_spec.ts @@ -140,7 +140,7 @@ function createCategoryFromSidebarMenu() { const categoryName = `category-${getRandomId()}`; // # Click on the sidebar menu dropdown - cy.findByLabelText('Add Channel Dropdown').click(); + cy.uiGetLHSAddChannelButton().click(); // # Click on create category link cy.findByText('Create New Category').should('be.visible').click(); diff --git a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_spec.ts b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_spec.ts index 69086ce680..82e3b4a086 100644 --- a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/category_sorting_spec.ts @@ -23,7 +23,7 @@ describe('Category sorting', () => { it('MM-T3916 Create Category character limit', () => { // # Click on the sidebar menu dropdown - cy.findByLabelText('Add Channel Dropdown').click(); + cy.uiGetLHSAddChannelButton().click(); // # Click on create category link cy.findByText('Create New Category').should('be.visible').click(); diff --git a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/custom_categories_spec.ts b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/custom_categories_spec.ts index 30918ebbb3..4822d10432 100644 --- a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/custom_categories_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/custom_categories_spec.ts @@ -90,7 +90,7 @@ function createCategoryFromSidebarMenu() { const categoryName = `category-${getRandomId()}`; // # Click on the sidebar menu dropdown - cy.findByLabelText('Add Channel Dropdown').click(); + cy.uiGetLHSAddChannelButton().click(); // # Click on create category link cy.findByText('Create New Category').should('be.visible').click(); diff --git a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/new_channel_dropdown_spec.ts b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/new_channel_dropdown_spec.ts index 17114e21aa..4aad6c337a 100644 --- a/e2e-tests/cypress/tests/integration/channels/channel_sidebar/new_channel_dropdown_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/channel_sidebar/new_channel_dropdown_spec.ts @@ -62,7 +62,7 @@ describe('Channel sidebar', () => { cy.url().should('include', `/${teamName}/channels/town-square`); // # Click the New Channel Dropdown button - cy.get('.AddChannelDropdown_dropdownButton').should('be.visible').click(); + cy.uiGetLHSAddChannelButton().should('be.visible').click(); // # Click the Browse Channels dropdown item cy.get('.AddChannelDropdown .MenuItem:contains(Browse Channels) button').should('be.visible').click(); diff --git a/e2e-tests/cypress/tests/integration/channels/emoji/recently_used_emoji_1_spec.ts b/e2e-tests/cypress/tests/integration/channels/emoji/recently_used_emoji_1_spec.ts index 0d016ea33d..fcaeb3b38b 100644 --- a/e2e-tests/cypress/tests/integration/channels/emoji/recently_used_emoji_1_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/emoji/recently_used_emoji_1_spec.ts @@ -105,7 +105,10 @@ describe('Recent Emoji', () => { cy.uiGetPostTextBox().type('{enter} {enter}').wait(TIMEOUTS.TWO_SEC); // # Hover over the last post by opening dot menu on it - cy.clickPostDotMenu(); + cy.getLastPostId().then((postId) => { + // # Click on post dot menu so we can check for reaction icon + cy.get(`#post_${postId}`).trigger('mouseover'); + }); cy.get('#recent_reaction_0').should('exist').then((recentReaction) => { // * Assert that custom emoji is present as most recent in quick reaction menu @@ -152,7 +155,10 @@ describe('Recent Emoji', () => { cy.reload(); // # Hover over the last post by opening dot menu on it - cy.clickPostDotMenu(); + cy.getLastPostId().then((postId) => { + // # Click on post dot menu so we can check for reaction icon + cy.get(`#post_${postId}`).trigger('mouseover'); + }); cy.get('#recent_reaction_0').should('exist').then((recentReaction) => { // * Assert that instead of custom emoji the system emoji is present as most recent in quick reaction menu diff --git a/e2e-tests/cypress/tests/integration/channels/enterprise/accessibility/accessibility_input_fields_spec.js b/e2e-tests/cypress/tests/integration/channels/enterprise/accessibility/accessibility_input_fields_spec.js index 8626033949..08f25fc8d4 100644 --- a/e2e-tests/cypress/tests/integration/channels/enterprise/accessibility/accessibility_input_fields_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/enterprise/accessibility/accessibility_input_fields_spec.js @@ -196,7 +196,7 @@ describe('Verify Accessibility Support in different input fields', () => { cy.get('#FormattingControl_ul').should('be.focused').and('have.attr', 'aria-label', 'bulleted list').tab(); // * Verify if the focus is on the numbered list button - cy.get('#FormattingControl_ol').should('be.focused').and('have.attr', 'aria-label', 'numbered list').tab(); + cy.get('#FormattingControl_ol').should('be.focused').and('have.attr', 'aria-label', 'numbered list').tab().tab(); // * Verify if the focus is on the formatting options button cy.get('#toggleFormattingBarButton').should('be.focused').and('have.attr', 'aria-label', 'formatting').tab(); diff --git a/e2e-tests/cypress/tests/integration/channels/enterprise/ldap/ldap_guest_spec.js b/e2e-tests/cypress/tests/integration/channels/enterprise/ldap/ldap_guest_spec.js index fda7dca517..79dbf33ab8 100644 --- a/e2e-tests/cypress/tests/integration/channels/enterprise/ldap/ldap_guest_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/enterprise/ldap/ldap_guest_spec.js @@ -159,7 +159,7 @@ describe('LDAP guest', () => { // # Create team if no membership cy.skipOrCreateTeam(testSettings, getRandomId()).then(() => { // * Verify user is a member - cy.findByRole('button', {name: 'Add Channel Dropdown'}).should('exist'); + cy.uiGetLHSAddChannelButton().should('exist'); // # Demote the user demoteUserToGuest(user2Data); @@ -173,7 +173,7 @@ describe('LDAP guest', () => { cy.uiAddDirectMessage().should('exist'); // * Check the user is a guest - cy.findByRole('button', {name: 'Add Channel Dropdown'}).should('not.exist'); + cy.uiGetLHSAddChannelButton().should('not.exist'); }); }); }); diff --git a/e2e-tests/cypress/tests/integration/channels/enterprise/system_console/system_scheme_permission_part2_spec.js b/e2e-tests/cypress/tests/integration/channels/enterprise/system_console/system_scheme_permission_part2_spec.js index 53e063aef9..33ae5b8c77 100644 --- a/e2e-tests/cypress/tests/integration/channels/enterprise/system_console/system_scheme_permission_part2_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/enterprise/system_console/system_scheme_permission_part2_spec.js @@ -53,7 +53,7 @@ describe('System Scheme', () => { cy.findByTestId('systemScheme-link').should('be.visible').click().wait(TIMEOUTS.HALF_SEC); // # Click on `Reset to defaults` - cy.findByTestId('resetPermissionsToDefault').should('be.visible').click().wait(TIMEOUTS.HALF_SEC); + cy.findByTestId('resetPermissionsToDefault').scrollIntoView().should('be.visible').click().wait(TIMEOUTS.HALF_SEC); // # Confirm the dialog cy.get('#confirmModalButton').click().wait(TIMEOUTS.TWO_SEC); @@ -78,10 +78,10 @@ describe('System Scheme', () => { cy.findByTestId('all_users-private_channel-create_private_channel-checkbox').should('not.have.class', 'checked'); // # Click on `Reset to defaults` - cy.findByTestId('resetPermissionsToDefault').should('be.visible').click().wait(TIMEOUTS.HALF_SEC); + cy.findByTestId('resetPermissionsToDefault').scrollIntoView().should('be.visible').click().wait(TIMEOUTS.HALF_SEC); // # Confirm the dialog - cy.get('#confirmModalButton').click().wait(TIMEOUTS.HALF_SEC); + cy.get('#confirmModalButton').scrollIntoView().click().wait(TIMEOUTS.HALF_SEC); // # Save changes cy.get('#saveSetting').click().wait(TIMEOUTS.TWO_SEC); diff --git a/e2e-tests/cypress/tests/integration/channels/mark_as_unread/helpers.js b/e2e-tests/cypress/tests/integration/channels/mark_as_unread/helpers.js index 4482bcb782..fbcbea8f4b 100644 --- a/e2e-tests/cypress/tests/integration/channels/mark_as_unread/helpers.js +++ b/e2e-tests/cypress/tests/integration/channels/mark_as_unread/helpers.js @@ -21,6 +21,7 @@ export function markAsUnreadShouldBeAbsent(postId, prefix = 'post', location = ' within(() => { cy.findByText('Mark as Unread').should('not.exist'); }); + cy.get('body').type('esc'); } export function switchToChannel(channel) { diff --git a/e2e-tests/cypress/tests/support/ui/sidebar_left.ts b/e2e-tests/cypress/tests/support/ui/sidebar_left.ts index 1168b705dd..58ae372f82 100644 --- a/e2e-tests/cypress/tests/support/ui/sidebar_left.ts +++ b/e2e-tests/cypress/tests/support/ui/sidebar_left.ts @@ -32,7 +32,7 @@ Cypress.Commands.add('uiOpenTeamMenu', (item = '') => { Cypress.Commands.add('uiGetLHSAddChannelButton', () => { return cy.uiGetLHS(). - findByRole('button', {name: 'Add Channel Dropdown'}); + find('.AddChannelDropdown_dropdownButton'); }); Cypress.Commands.add('uiGetLHSTeamMenu', () => { @@ -89,7 +89,7 @@ Cypress.Commands.add('uiGetLhsSection', (section) => { }); Cypress.Commands.add('uiBrowseOrCreateChannel', (item) => { - cy.findByRole('button', {name: 'Add Channel Dropdown'}). + cy.get('.AddChannelDropdown_dropdownButton'). should('be.visible'). click(); cy.get('.dropdown-menu').should('be.visible');