Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-30376 Cypress/E2E: Automate backlogs - Messaging (8 test cases) (#…
Browse files Browse the repository at this point in the history
…7141)

Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 7, 2020
1 parent d588698 commit e6d400c
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('Profile popover User A & B', () => {
find(`[data-mention=${otherUser.username}]`).
should('be.visible').
click();
cy.get('#user-profile-popover').should('be.visible');
});

// # Add to a Channel should not be shown.
Expand Down
82 changes: 82 additions & 0 deletions e2e/cypress/integration/messaging/group_message_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @messaging

describe('Group Messages', () => {
let testUser;
let otherUser1;
let otherUser2;

before(() => {
cy.apiInitSetup().then(({team, user}) => {
testUser = user;

cy.apiCreateUser({prefix: 'otherA'}).then(({user: newUser}) => {
otherUser1 = newUser;

cy.apiAddUserToTeam(team.id, newUser.id);
});

cy.apiCreateUser({prefix: 'otherB'}).then(({user: newUser}) => {
otherUser2 = newUser;

cy.apiAddUserToTeam(team.id, newUser.id);
});

// # Login as test user and go to town square
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/town-square`);
});
});

it('MM-T3319 Add GM', () => {
// # Click on '+' sign to open DM modal
cy.findByLabelText('write a direct message').should('be.visible').click();

// * Verify that the DM modal is open
cy.get('#moreDmModal').should('be.visible').contains('Direct Messages');

// # Search for the user otherA
cy.get('#selectItems input').should('be.enabled').type(`@${otherUser1.username}`, {force: true});

// * Verify that the user is found and add to GM
cy.get('#moreDmModal .more-modal__row').should('be.visible').and('contain', otherUser1.username).click({force: true});

// # Search for the user otherB
cy.get('#selectItems input').should('be.enabled').type(`@${otherUser2.username}`, {force: true});

// * Verify that the user is found and add to GM
cy.get('#moreDmModal .more-modal__row').should('be.visible').and('contain', otherUser2.username).click({force: true});

// # Search for the current user
cy.get('#selectItems input').should('be.enabled').type(`@${testUser.username}`, {force: true});

// * Assert that it's not found
cy.findByText('No items found').should('be.visible');

// # Start GM
cy.findByText('Go').click();

// # Post something to create a GM
cy.get('#post_textbox').type('Hi!').type('{enter}');

// # Click on '+' sign to open DM modal
cy.findByLabelText('write a direct message').should('be.visible').click();

// * Verify that the DM modal is open
cy.get('#moreDmModal').should('be.visible').contains('Direct Messages');

// # Search for the user otherB
cy.get('#selectItems input').should('be.enabled').type(`@${otherUser2.username}`, {force: true});

// * Verify that the user is found and is part of the GM together with the other user
cy.get('#moreDmModal .more-modal__row').should('be.visible').and('contain', otherUser2.username).and('contain', otherUser1.username);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @messaging

import * as TIMEOUTS from '../../fixtures/timeouts';

describe('Delete the post on text clear', () => {
let townsquareLink;

before(() => {
// # Login as test user and visit town-square
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
townsquareLink = `/${team.name}/channels/town-square`;
cy.visit(townsquareLink);
});
});

it('MM-T2146 Remove all text from a post (no attachment)', () => {
// # Go to a test channel on the side bar
cy.get('#sidebarItem_town-square').click({force: true});

// * Validate if the channel has been opened
cy.url().should('include', townsquareLink);

// # Type 'This is sample text' and submit
cy.postMessage('This is sample text');

// # Get last post ID
cy.getLastPostId().then((postID) => {
// # click dot menu button
cy.clickPostDotMenu();

// # click edit post
cy.get(`#edit_post_${postID}`).click();

// # Edit message to 'This is sample add text'
cy.get('#edit_textbox').should('be.visible').and('be.focused').wait(TIMEOUTS.HALF_SEC).clear();

// # Click button Edit
cy.get('#editButton').click();

// # Press Enter to confirm
cy.focused().click(); // pressing Enter on buttons is not supported in Cypress, so we use click instead

// * Assert post message disappears
cy.get(`#postMessageText_${postID}`).should('not.exist');
});
});
});
49 changes: 49 additions & 0 deletions e2e/cypress/integration/messaging/message_ephemeral_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @messaging

describe('Hide ephemeral message on refresh', () => {
let townsquareLink;

before(() => {
// # Login as test user and visit town-square
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
townsquareLink = `/${team.name}/channels/town-square`;
cy.visit(townsquareLink);
});
});

it('MM-T2197 Ephemeral message disappears in center after refresh', () => {
// # Got to a test channel on the side bar
cy.get('#sidebarItem_town-square').click({force: true});

// * Validate if the channel has been opened
cy.url().should('include', townsquareLink);

// # Set initial status to online
cy.apiUpdateUserStatus('online');

// # Cause an ephemeral message to appear
cy.postMessage('/offline');

// # Get last post ID
cy.getLastPostId().then((postID) => {
// * Assert message presence
cy.get(`#postMessageText_${postID}`).should('have.text', 'You are now offline');

// # Refresh the page
cy.reload();
cy.visit(townsquareLink);

// * Assert message disappearing
cy.get(`#postMessageText_${postID}`).should('not.exist');
});
});
});
53 changes: 53 additions & 0 deletions e2e/cypress/integration/messaging/message_with_gif_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

// Group: @messaging

describe('Show GIF images properly', () => {
let townsquareLink;

before(() => {
// # Set the configuration on Link Previews
cy.apiUpdateConfig({
ServiceSettings: {
EnableLinkPreviews: true,
},
});

// # Login as test user and visit town-square
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
townsquareLink = `/${team.name}/channels/town-square`;
cy.visit(townsquareLink);
});
});

it('MM-T3318 Posting GIFs', () => {
// # Got to a test channel on the side bar
cy.get('#sidebarItem_town-square').click({force: true});

// * Validate if the channel has been opened
cy.url().should('include', townsquareLink);

// # Post tenor GIF
cy.postMessage('https://media1.tenor.com/images/4627c6507cdc899d211319081ba5740b/tenor.gif');

cy.getLastPostId().as('postId').then((postId) => {
// * Validate image size
cy.get(`#post_${postId}`).find('.attachment__image').should('have.css', 'width', '320px');
});

// # Post giphy GIF
cy.postMessage('https://media.giphy.com/media/XIqCQx02E1U9W/giphy.gif');

cy.getLastPostId().as('postId').then((postId) => {
// * Validate image size
cy.get(`#post_${postId}`).find('.attachment__image').invoke('outerWidth').should('be.gte', 480);
});
});
});

0 comments on commit e6d400c

Please sign in to comment.