Skip to content

Commit

Permalink
test(cypress): add chat reaction tests (#2887)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed Apr 14, 2022
1 parent 2d8f20e commit 2663a62
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 9 deletions.
5 changes: 4 additions & 1 deletion components/views/chat/message/Message.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
:class="textile.messageLoading ? 'loading' : ''"
@contextmenu="contextMenu"
>
<div :class="`message-container ${message.pinned ? 'pinned-message' : ''}`">
<div
:class="`message-container ${message.pinned ? 'pinned-message' : ''}`"
data-cy="message-container"
>
<div v-if="message.pinned" class="pinned-badge">
<archive-icon size="0.85x" />
Archived
Expand Down
2 changes: 1 addition & 1 deletion components/views/chat/message/reactions/Reactions.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@mouseenter="toggleReactors(reaction.emoji)"
@mouseleave="toggleReactors(null)"
>
<span>{{reaction.emoji}}</span>
<span data-cy="emoji-reaction-value">{{reaction.emoji}}</span>
<span>{{reaction.reactors.length}}</span>
<div></div>
</div>
Expand Down
30 changes: 27 additions & 3 deletions cypress/integration/chat-pair-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe.skip('Chat features with two accounts', () => {
})
})

it('Assert timestamp is displayed when user A sends a message', () => {
it.skip('Assert timestamp is displayed when user A sends a message', () => {
cy.get('[data-cy=chat-timestamp]')
.last()
.invoke('text')
Expand All @@ -165,13 +165,37 @@ describe.skip('Chat features with two accounts', () => {
})
})

it('Add reactions to text message in chat', () => {
cy.contains(randomMessage).last().as('messageToReact')
cy.reactToChatElement('@messageToReact', '[title="smile"]')
cy.validateChatReaction('@messageToReact', '😄')
})

it('Add reactions to image in chat', () => {
cy.get('[data-cy=chat-image]').last().as('imageToReact')
cy.reactToChatElement('@imageToReact', '[title="smile"]')
cy.validateChatReaction('@imageToReact', '😄')
})

it('Add reactions to file in chat', () => {
cy.get('[data-cy=chat-file]').last().as('fileToReact')
cy.reactToChatElement('@fileToReact', '[title="smile"]')
cy.validateChatReaction('@fileToReact', '😄')
})

it('Add reactions to glyph in chat', () => {
cy.get('[data-cy=chat-glyph]').last().as('glyphToReact')
cy.reactToChatElement('@glyphToReact', '[title="smile"]')
cy.validateChatReaction('@glyphToReact', '😄')
})

it('User should be able to reply without first clicking into the chat bar - Chat User C', () => {
cy.goToConversation('Chat User C')
cy.get('[data-cy=editable-input]').should('be.visible').type(randomMessage)
cy.get('[data-cy=editable-input]').clear()
})

it('Assert timestamp immediately after sending message', () => {
it.skip('Assert timestamp immediately after sending message', () => {
//Send a random message
cy.chatFeaturesSendMessage(randomMessageTwo)

Expand All @@ -184,7 +208,7 @@ describe.skip('Chat features with two accounts', () => {
})
})

it('Assert timestamp one minute after sending message', () => {
it.skip('Assert timestamp one minute after sending message', () => {
//Wait for 60 seconds
cy.wait(60000)

Expand Down
41 changes: 37 additions & 4 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ Cypress.Commands.add('chatFeaturesSendMessage', (message) => {
cy.get('[data-cy=editable-input]')
.should('be.visible')
.trigger('input')
.type(message)
.paste({
pasteType: 'text',
pastePayload: message,
})
cy.get('[data-cy=send-message]').click() //sending text message
cy.contains(message, { timeout: 15000 })
.last()
Expand Down Expand Up @@ -414,15 +417,26 @@ Cypress.Commands.add('clickOutside', () => {
cy.get('body').click(0, 0) //0,0 here are the x and y coordinates
})

Cypress.Commands.add('validateChatPageIsLoaded', (customTimeout = 180000) => {
Cypress.Commands.add('validateChatPageIsLoaded', (customTimeout = 300000) => {
cy.get('[data-cy=user-name]', { timeout: customTimeout }).should('exist')
})

Cypress.Commands.add('goToConversation', (user, mobile = false) => {
cy.get('[data-cy=sidebar-friends]').click()
//If chat conversation is displayed, click on hamburger button
//Click on sidebar friends button to show friends list
cy.get('[data-cy=sidebar-friends]').then(($button) => {
if (!$button.is(':visible')) {
cy.get('[data-cy=hamburger-button]').click()
}
cy.wrap($button).click()
})

//On mobile viewports, we need to click on hamburger button to see the friends list
if (mobile === true) {
cy.get('[data-cy=hamburger-button]').click()
}

//Find the friend and click on the message button associated
cy.get('[data-cy=friend-name]').contains(user).as('friend')
cy.get('@friend')
.parent()
Expand All @@ -431,10 +445,13 @@ Cypress.Commands.add('goToConversation', (user, mobile = false) => {
.as('friend-message')
cy.get('@friend-message').click()

//On mobile viewports, we need to click on hamburger button to see the chat conversation
if (mobile === true) {
cy.get('[data-cy=hamburger-button]').click()
}
cy.get('[data-cy=user-connected]', { timeout: 60000 })

//Wait until conversation is fully loaded
cy.get('[data-cy=user-connected]', { timeout: 90000 })
.should('be.visible')
.should('have.text', user)
})
Expand Down Expand Up @@ -536,6 +553,22 @@ Cypress.Commands.add('validateCharlimit', (text, assert) => {
})
})

Cypress.Commands.add('reactToChatElement', (elementLocator, emojiLocator) => {
cy.selectContextMenuOption(elementLocator, 'Add Reaction')
cy.get(emojiLocator).click()
})

Cypress.Commands.add(
'validateChatReaction',
(elementLocator, emojiValue, timeout = 30000) => {
cy.get(elementLocator)
.scrollIntoView()
.parents('[data-cy=message-container]')
.find('[data-cy=emoji-reaction-value]', { timeout: timeout })
.should('contain', emojiValue)
},
)

//Version Release Notes Commands

Cypress.Commands.add('releaseNotesScreenValidation', () => {
Expand Down

0 comments on commit 2663a62

Please sign in to comment.