Skip to content

Commit

Permalink
[MM-28262] e2e/messaging: add T2168, T2169, T2170, T2171 and T2172 (m…
Browse files Browse the repository at this point in the history
…attermost#6507)

* e2e/messaging: add T2168-69-70-71-72

* reflect review comments

* s/flag/save
  • Loading branch information
isacikgoz authored Sep 22, 2020
1 parent 798fe73 commit 2f96c3d
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 6 deletions.
155 changes: 149 additions & 6 deletions e2e/cypress/integration/messaging/pinned_posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ describe('Messaging', () => {
testUser = user;
testTeam = team;
testChannel = channel;
cy.apiLogin(testUser);
});
});

it('MM-T2167 Pin a post, view pinned posts', () => {
// # Login as the other user
cy.apiLogin(testUser);

// # Visit a test channel and post a message
beforeEach(() => {
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
});

it('MM-T2167 Pin a post, view pinned posts', () => {
// # Post a message
cy.postMessage('This is a post that is going to be pinned.');

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

// # Click pin icon next to search box
cy.get('#channelHeaderPinButton').should('exist').click();
Expand All @@ -48,4 +49,146 @@ describe('Messaging', () => {
cy.get(`#rhsPostMessageText_${postId}`).findByText('Pinned').should('not.exist');
});
});

it('MM-T2168 Un-pin a post, disappears from pinned posts RHS', () => {
// # Post a message
cy.postMessage('This is a post that is going to be pinned then removed.');

cy.getLastPostId().then((postId) => {
// # On a message in center channel, click then pin the post to the channel
cy.clickPostPinIcon(postId);

// # Find the 'Pinned' span in the post pre-header to verify that the post was actually pinned
cy.get(`#post_${postId}`).findByText('Pinned').should('exist');

// # Click pin icon next to search box
cy.get('#channelHeaderPinButton').should('exist').click();

// # View pinned posts RHS
cy.get(`#rhsPostMessageText_${postId}`).should('exist');

// # On a message in center channel, Click [...] > Un-pin from channel
cy.getPostMenu(postId, 'Unpin from Channel').click();

// * Post disappears from RHS
cy.get(`#rhsPostMessageText_${postId}`).should('not.exist');

// * Pinned badge is removed from post in center
cy.get(`#post_${postId}`).findByText('Pinned').should('not.exist');
});
});

it('MM-T2169 Un-pinning a post in center also removes badge from *search results* RHS', () => {
// # 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.clickPostPinIcon(postId);

// # Search for "Hello"
cy.get('#searchBox').should('be.visible').type('Hello').type('{enter}');

// * Post appears in RHS search results, displays Pinned badge
cy.get(`#searchResult_${postId}`).findByText('Pinned').should('exist');

// # On a message in center channel, Click [...] > Un-pin from channel
cy.getPostMenu(postId, 'Unpin from Channel').click();

// * Post still appears in RHS search results, but Pinned badge is removed
cy.get(`#searchResult_${postId}`).findByText('Pinned').should('not.exist');
});
});

it('MM-T2170 Un-pinning a post in *permalink* view also removes badge from saved posts RHS', () => {
// # Post a message
cy.postMessage('Permalink post.');

cy.getLastPostId().then((postId) => {
// # On a message in center channel, click then pin the post to the channel
cy.clickPostPinIcon(postId);

// # Click save icon
cy.clickPostSaveIcon(postId);

// # In RHS, click Jump to view permalink view
cy.get('#channelHeaderFlagButton').should('exist').click();
cy.get(`#searchResult_${postId}`).should('exist');
cy.get('a.search-item__jump').first().click();

// * Message is displayed in center channel and highlighted (permalink view)
cy.get(`#post_${postId}`).
should('have.css', 'animation-duration', '1s').
and('have.css', 'animation-delay', '5s').
and('have.class', 'post--highlight');

// # In permalink view, click [...] > Un-pin from channel
cy.getPostMenu(postId, 'Unpin from Channel').click();

// * Pinned badge is removed in both center and RHS
cy.get(`#post_${postId}`).findByText('Pinned').should('not.exist');
cy.get(`#searchResult_${postId}`).findByText('Pinned').should('not.exist');
});
});

it('MM-T2171 Un-pinning and pinning a post in center also removes and adds badge in *saved posts* RHS (Se portion)', () => {
// # Post a message
cy.postMessage('This is a post that is going to be pinned then removed, then pinned again.');

cy.getLastPostId().then((postId) => {
// # On a message in center channel, click then pin the post to the channel
cy.clickPostPinIcon(postId);

// # And also save the message
cy.clickPostSaveIcon(postId);

// # Open Saved posts
cy.get('#channelHeaderFlagButton').should('exist').click();

// * Post appears in saved posts list, and displays Pinned badge
cy.get(`#searchResult_${postId}`).findByText('Pinned').should('exist');

// # In center channel, click [...] > Un-pin from channel
cy.getPostMenu(postId, 'Unpin from Channel').click();

// * Post still appears in saved posts list, and Pinned badge is removed in both center and RHS
cy.get(`#post_${postId}`).findByText('Pinned').should('not.exist');
cy.get(`#searchResult_${postId}`).findByText('Pinned').should('not.exist');

// # In center channel, click [...] > Pin to channel
cy.getPostMenu(postId, 'Pin to Channel').click();

// * Pinned badge returns on message in both center and RHS
cy.get(`#post_${postId}`).findByText('Pinned').should('exist');
cy.get(`#searchResult_${postId}`).findByText('Pinned').should('exist');
});
});

it('MM-T2172 Non-pinned replies do not appear with parent post in pinned posts RHS', () => {
// # Post a message
cy.postMessage('This is a post that is going to be pinned and replied.');

cy.getLastPostId().then((postId) => {
// # On a message in center channel, click then pin the post to the channel
cy.clickPostPinIcon(postId);

// # Open RHS comment menu
cy.clickPostCommentIcon(postId);

// # Enter comment in RHS
cy.postMessageReplyInRHS('This is a reply');

// # Click to reply to message
cy.getLastPostId().then((replyPostId) => {
// # Click pin icon next to search box
cy.get('#channelHeaderPinButton').should('exist').click();

// * Pinned post appear in RHS
cy.get(`#rhsPostMessageText_${postId}`).should('exist');

// * Reply does no appear in RHS
cy.get(`#rhsPostMessageText_${replyPostId}`).should('not.exist');
});
});
});
});
8 changes: 8 additions & 0 deletions e2e/cypress/support/ui_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ Cypress.Commands.add('getPostMenu', (postId, menuItem, location = 'CENTER') => {
});
});

/**
* Click Pin to Channel icon by post ID or to most recent post (if post ID is not provided)
* @param {String} postId - Post ID
*/
Cypress.Commands.add('clickPostPinIcon', (postId) => {
cy.getPostMenu(postId, 'Pin to Channel').click();
});

// Close RHS by clicking close button
Cypress.Commands.add('closeRHS', () => {
cy.get('#rhsCloseButton').should('be.visible').click();
Expand Down

0 comments on commit 2f96c3d

Please sign in to comment.