Skip to content

Commit

Permalink
MM-61306: Cypress/E2E, fixed failed tests (mattermost#28959)
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserfaraazkhan authored Nov 1, 2024
1 parent 857fd87 commit 77862dd
Show file tree
Hide file tree
Showing 36 changed files with 107 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ describe('Verify Accessibility Support in different Buttons', () => {

// # Post a message
cy.postMessage('hello');
cy.getLastPostId().then((postId) => {
// # On a message in center channel, click then pin the post to the channel
cy.uiClickPostDropdownMenu(postId, 'Pin to Channel');

// # Click pin icon next to search box
cy.uiGetChannelPinButton().click();
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Verify Accessibility keyboard usability across different regions in th

// # Search for a term
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').typeWithForce('hello').typeWithForce('{enter}');
cy.uiGetSearchBox().typeWithForce('hello').typeWithForce('{enter}');

// # Change the focus to search results
cy.get('#searchContainer').within(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('Verify Quick Navigation support across different regions in the app',
it('MM-T1460_8 Verify Navigation Support in Search Results', () => {
// # Search for some text
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').should('be.visible').type('hello {enter}');
cy.uiGetSearchBox().should('be.visible').first().type('hello {enter}');

// # Change the focus to search results
cy.get('#searchContainer').within(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Archived channels', () => {
// # Search for "Test archive reaction"
cy.get('body').type('{esc}');
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').should('be.visible').type(messageText).type('{enter}');
cy.uiGetSearchBox().should('be.visible').first().type(messageText).type('{enter}');

// # Click on post dot menu so we can check for reaction icon
cy.clickPostDotMenu(postId, 'SEARCH');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('archive tests while preventing viewing archived channels', () => {

// # Search for the post from step 1')
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${messageText}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${messageText}{enter}`);

// * Post is returned by search, since it's not archived anymore
cy.get('#searchContainer').should('be.visible');
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('archive tests while preventing viewing archived channels', () => {

// # Archive dialogue message reads "This will archive the channel from the team and make its contents inaccessible for all users" (Mobile dialogue makes no mention of the data will be accessible)
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${testArchivedMessage}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${testArchivedMessage}{enter}`);

// * Post is not returned by search
cy.get('#searchContainer').should('be.visible');
Expand All @@ -112,7 +112,7 @@ describe('archive tests while preventing viewing archived channels', () => {

// # Search for the string of text from step 1
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${messageText}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${messageText}{enter}`);

// * Post is returned by search, since it's not archived anymore
cy.get('#searchContainer').should('be.visible');
Expand All @@ -131,7 +131,7 @@ describe('archive tests while preventing viewing archived channels', () => {
// # Archive a channel and make a mental note of the channel name
// # Type "in:" and note the list of channels that appear
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`in:${testChannel.name}`);
cy.uiGetSearchBox().first().clear().type(`in:${testChannel.name}`);
cy.findByTestId(testChannel.name).should('not.exist');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Leave an archived channel', () => {

// # Search for a post in an archived channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${testArchivedMessage}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${testArchivedMessage}{enter}`);

// # Open the archived channel by selecting Jump from search results and then selecting the link to move to the most recent posts in the channel
cy.uiGetSearchContainer().should('be.visible');
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Leave an archived channel', () => {
createArchivedChannel({prefix: 'archived-search-for'}, messageList).then(({name}) => {
// # Locate the post in a search
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${messageList[1]}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${messageList[1]}{enter}`);

// # Click jump to open an archive post in permalink view
cy.uiGetSearchContainer().should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('Leave an archived channel', () => {

// # Search for content from an archived channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${messageD}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${messageD}{enter}`);

// # Open the channel from search results
cy.get('#searchContainer').should('be.visible');
Expand All @@ -109,7 +109,7 @@ describe('Leave an archived channel', () => {

// # Search for content from a different archived channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(`${messageC}{enter}`);
cy.uiGetSearchBox().first().clear().type(`${messageC}{enter}`);

// # Open the channel from search result by clicking Jump
cy.get('#searchContainer').should('be.visible').findByText('Jump').click().wait(TIMEOUTS.ONE_SEC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('Channel RHS', () => {

// # Enter the search terms and hit enter to start the search
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type(MESSAGES.TINY).type('{enter}');
cy.uiGetSearchBox().first().clear().type(MESSAGES.TINY).type('{enter}');

// * Verify that the search results is opened in RHS
verifyRHSisOpenAndHasTitle('Search Results');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('MM-T4066 Setting manual status clear time more than 7 days away', () =

// # Click on the date which is dateToBeSelected
for (let i = 0; i < months; i++) {
cy.get('.fa-angle-right').click();
cy.get('i.icon.icon-chevron-right').click();
}
cy.get('.date-picker__popper').find(`.rdp-month button[aria-label="${dateToBeSelected.format('Do MMMM (dddd)')}"]`).click();

Expand Down Expand Up @@ -161,7 +161,7 @@ describe('MM-T4066 Setting manual status clear time more than 7 days away', () =

// # Click on the date which is dateToBeSelected
for (let i = 0; i < months; i++) {
cy.get('.fa-angle-right').click();
cy.get('i.icon.icon-chevron-right').click();
}
cy.get('.date-picker__popper').find(`.rdp-month button[aria-label="${dateToBeSelected.format('Do MMMM (dddd)')}"]`).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ describe('Verify Accessibility Support in different input fields', () => {
cy.uiGetSearchContainer().click();

// * Verify Accessibility support in search input
cy.uiGetSearchBox().should('have.attr', 'aria-describedby', 'searchHints').and('have.attr', 'aria-label', 'Search');
cy.uiGetSearchBox().find('input').focus();
cy.uiGetSearchBox().should('have.attr', 'aria-describedby', 'searchbar-help-popup').and('have.attr', 'aria-label', 'Search messages');
cy.uiGetSearchBox().focus();
cy.get('#searchHints').should('be.visible');

// # Ensure User list is cached once in UI
cy.uiGetSearchBox().find('input').type('from:').wait(TIMEOUTS.FIVE_SEC);
cy.uiGetSearchBox().type('from:').wait(TIMEOUTS.FIVE_SEC);

// # Trigger the user autocomplete again
cy.uiGetSearchBox().find('input').clear().type('from:').wait(TIMEOUTS.FIVE_SEC).type('{downarrow}{downarrow}');
cy.uiGetSearchBox().first().clear().type('from:').wait(TIMEOUTS.FIVE_SEC).type('{downarrow}{downarrow}');

// * Verify Accessibility Support in search autocomplete
verifySearchAutocomplete(2);
Expand All @@ -103,10 +103,10 @@ describe('Verify Accessibility Support in different input fields', () => {
verifySearchAutocomplete(3);

// # Type the in: filter and ensure channel list is cached once
cy.uiGetSearchBox().find('input').clear().type('in:').wait(TIMEOUTS.FIVE_SEC);
cy.uiGetSearchBox().first().clear().type('in:').wait(TIMEOUTS.FIVE_SEC);

// # Trigger the channel autocomplete again
cy.uiGetSearchBox().find('input').clear().type('in:').wait(TIMEOUTS.FIVE_SEC).type('{downarrow}{downarrow}');
cy.uiGetSearchBox().first().clear().type('in:').wait(TIMEOUTS.FIVE_SEC).type('{downarrow}{downarrow}');

// * Verify Accessibility Support in search autocomplete
verifySearchAutocomplete(2, 'channel');
Expand Down Expand Up @@ -290,7 +290,7 @@ function getUserMentionAriaLabel(displayName) {
}

function verifySearchAutocomplete(index, type = 'user') {
cy.uiGetSearchBox().find('.suggestion-list__item').eq(index).should('be.visible').and('have.class', 'suggestion--selected').within((el) => {
cy.get('#searchBox').find('.suggestion-list__item').eq(index).should('be.visible').and('have.class', 'suggestion--selected').within((el) => {
if (type === 'user') {
cy.get('.suggestion-list__ellipsis').invoke('text').then((text) => {
const usernameLength = 12;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Guest Account - Guest User Experience', () => {

// # Search for the Guest User
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').wait(TIMEOUTS.FIVE_SEC).type(`in:${guestUser.username}`);
cy.uiGetSearchBox().wait(TIMEOUTS.FIVE_SEC).type(`in:${guestUser.username}`);

// * Verify Guest Badge is not displayed at Search auto-complete
cy.contains('.suggestion-list__item', guestUser.username).should('be.visible').within(($el) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('Verify Guest User Identification in different screens', () => {
it('Verify Guest Badge not displayed in Search Autocomplete', () => {
// # Search for the Guest User
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').type('from:');
cy.uiGetSearchBox().type('from:');

// * Verify Guest Badge is not displayed at Search auto-complete
cy.contains('.suggestion-list__item', guestUser.username).scrollIntoView().should('be.visible').within(($el) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Incoming webhook', () => {
cy.postIncomingWebhook({url: incomingWebhook.url, data: payload});

cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').
cy.uiGetSearchBox().
wait(TIMEOUTS.HALF_SEC).
typeWithForce('findme').
typeWithForce('{enter}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Upload Files - Settings', () => {
cy.get('#searchHints').find('.search-hint__search-type-selector button > .icon-file-text-outline').should('not.exist');

// # Search for posts
cy.uiGetSearchBox().find('input').type('sample').type('{enter}');
cy.uiGetSearchBox().first().type('sample').type('{enter}');

// * Verify search results do not have File button
cy.get('.files-tab').should('not.exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Incoming webhook', () => {
cy.wrap(el).should('contain', 'The following should be markdown formatted');
cy.wrap(el).should('contain', '(mouse emoji, strawberry emoji, then formatting as indicated):');
cy.get('.emoticon').eq(0).parent().
should('have.html', `<span alt=":hamster:" class="emoticon" title=":hamster:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f439.png&quot;);">:hamster:</span>`);
should('have.html', `<span alt=":hamster:" class="emoticon" data-testid="postEmoji.:hamster:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f439.png&quot;);">🐹</span>`);
cy.get('.emoticon').eq(1).parent().
should('have.html', `<span alt=":strawberry:" class="emoticon" title=":strawberry:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f353.png&quot;);">:strawberry:</span>`);
cy.wrap(el).find('strong').should('have.text', 'bold');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Keyboard Shortcuts', () => {
it('MM-T1250 CTRL/CMD+SHIFT+L - Set focus to center channel message box (with SEARCH RHS open)', () => {
// # Search
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').type('test{enter}');
cy.uiGetSearchBox().first().type('test{enter}');

// * Wait for the RHS to open and the search results to appear
cy.contains('.sidebar--right__header', 'Search Results').should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ describe('Keyboard Shortcuts', () => {
it('MM-T1248 - CTRL/CMD+SHIFT+L - Set focus to center channel message box', () => {
// # Open search box to change focus
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').should('be.focused');
cy.uiGetSearchBox().should('be.focused');

// # Type CTRL/CMD+SHIFT+L
cy.get('body').cmdOrCtrlShortcut('{shift}L');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ describe('Messaging', () => {
cy.getLastPostId().then((postId) => {
// # Search for the posted message
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').should('be.visible').type(messageX).type('{enter}').wait(TIMEOUTS.HALF_SEC);
cy.uiGetSearchBox().should('be.visible').first().type(messageX).type('{enter}').wait(TIMEOUTS.HALF_SEC);

// # Click on post dot menu so we can edit
cy.clickPostDotMenu(postId, 'SEARCH');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Message permalink', () => {

// # Search for a message in the current channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');
cy.uiGetSearchBox().first().clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');

// # Jump to first permalink view (most recent message)
cy.get('.search-item__jump').first().click();
Expand All @@ -73,7 +73,7 @@ describe('Message permalink', () => {

// # Search for a message in the current channel
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');
cy.uiGetSearchBox().first().clear().type('in:town-square').wait(TIMEOUTS.HALF_SEC).type('{enter}{enter}');

// # Jump to first permalink view (most recent message)
cy.get('.search-item__jump').first().click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Permalink message edit', () => {

// # Search for searchWord
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').type(searchWord).type('{enter}');
cy.uiGetSearchBox().type(searchWord).type('{enter}');

// # Jump to permalink view
cy.get('.search-item__jump').first().click();
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Permalink message edit', () => {

// # Find searchWord and verify edited post
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').should('be.visible').type(searchWord).type('{enter}');
cy.uiGetSearchBox().should('be.visible').first().type(searchWord).type('{enter}');
cy.get('.search-item__jump').first().click();

// # Check if url include the permalink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('Post PreHeader', () => {

// # Search for the channel.
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').type('test both pinned and saved {enter}');
cy.uiGetSearchBox().first().type('test both pinned and saved {enter}');

// * Check that the post pre-header has both pinned and saved links in RHS search results
cy.get('#searchContainer').should('be.visible').within(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Notifications', () => {

// # Enter "in:town-square" in the search bar and hit ENTER
cy.uiGetSearchContainer().click();
cy.uiGetSearchBox().find('input').
cy.uiGetSearchBox().
typeWithForce('in:town-square').
wait(TIMEOUTS.HALF_SEC).
typeWithForce('{enter}').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ describe('Onboarding', () => {

// * Check that the 'Team Settings' modal was opened
cy.get('#teamSettingsModal').should('exist').within(() => {
cy.get('#open_inviteEdit').should('be.visible').click();
cy.get('#accessButton').should('be.visible').click();

// # Enable any user with an account on the server to join the team
cy.get('#teamOpenInvite').should('be.visible').click();
cy.findByText('Save').should('be.visible').click();
cy.get('input.mm-modal-generic-section-item__input-checkbox').last().should('be.visible').click();

cy.findAllByTestId('mm-save-changes-panel__save-btn').should('be.visible').click();

// # Close the modal
cy.get('#teamSettingsModalLabel').find('button').should('be.visible').click();
cy.findByLabelText('Close').should('be.visible').click();
});

// # Logout from sysadmin account
Expand All @@ -77,9 +78,6 @@ describe('Onboarding', () => {
// # Get invitation email and go to the provided link
getEmail(username, email);

// * Ensure that the email was correctly verified
cy.findByText('Email Verified').should('be.visible');

// * Ensure that the email was pre-filled and the password input box is focused
cy.get('#input_loginId').should('be.visible').and('have.value', email);
cy.get('#input_password-input').should('be.visible').and('be.focused').type(password);
Expand All @@ -98,8 +96,8 @@ describe('Onboarding', () => {
cy.get('#sidebarItem_town-square').should('exist');
});

// * Check that the 'Beginning of Town Square' message is visible
cy.findByText('Beginning of Town Square').should('be.visible');
// * Check that the 'Town Square' message is visible
cy.url().should('include', `/${testTeam.name}/channels/town-square`);
});

// eslint-disable-next-line no-shadow
Expand Down
Loading

0 comments on commit 77862dd

Please sign in to comment.