Skip to content

Commit

Permalink
test(cypress): add reaction tests and skip tests failing (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed Apr 19, 2022
1 parent 05660d7 commit 6a3e1c1
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 40 deletions.
3 changes: 2 additions & 1 deletion components/views/chat/message/reactions/Reactions.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
<div
:class="didIReact(reaction) ? 'emoji-reaction emoji-reacted' : 'emoji-reaction'"
@click="quickReaction(reaction.emoji)"
data-cy="reaction-to-message"
@mouseenter="toggleReactors(reaction.emoji)"
@mouseleave="toggleReactors(null)"
>
<span data-cy="emoji-reaction-value">{{reaction.emoji}}</span>
<span>{{reaction.reactors.length}}</span>
<span data-cy="emoji-reaction-count">{{reaction.reactors.length}}</span>
<div></div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions cypress/integration/chat-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe.skip('Chat Features Tests', () => {

it('Chat - Message edited shows edited status', () => {
cy.contains(randomMessage + randomNumber)
.siblings('[data-cy=message-edited]')
.parents('[data-cy=message-container]')
.find('[data-cy=message-edited]')
.should('contain', '(edited)')
})

Expand Down Expand Up @@ -61,8 +62,7 @@ describe.skip('Chat Features Tests', () => {
})

it('Chat - Copy paste text', () => {
// Sending another random message to validate the scenario
cy.chatFeaturesSendMessage(randomTextToCopy)
let randomTextToCopy = randomMessage + randomNumber

// Allowing Chrome Browser to have read and write access to clipboard
cy.wrap(
Expand All @@ -84,7 +84,7 @@ describe.skip('Chat Features Tests', () => {
.should('equal', 'granted')

//Copying the latest text message sent
cy.get('[data-cy=chat-message]').last().rightclick()
cy.contains(randomTextToCopy).last().scrollIntoView().rightclick()
cy.contains('Copy Message').realClick()

//Validating that text messsage copied matches with actual clipboard value
Expand Down
84 changes: 65 additions & 19 deletions cypress/integration/chat-pair-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ describe.skip('Chat features with two accounts', () => {
cy.validateChatPageIsLoaded()
})

it('Send message to user B', () => {
cy.goToConversation('Chat User B')
cy.chatFeaturesSendMessage(randomMessage)
cy.contains(randomMessage).last().scrollIntoView().should('exist')
})

it('Send emoji to user B', () => {
cy.goToConversation('Chat User B')
cy.chatFeaturesSendEmoji('[title="smile"]', '😄')
cy.get('[data-cy=chat-message] > span')
.last()
.scrollIntoView()
.should('have.text', '😄')
})

it('Send message to user B', () => {
cy.chatFeaturesSendMessage(randomMessage)
cy.get('[data-cy=chat-message]')
.contains(randomMessage)
.last()
.scrollIntoView()
.should('exist')
})

it('Send glyph to user B', () => {
cy.chatFeaturesSendGlyph()
cy.goToLastGlyphOnChat()
Expand All @@ -45,10 +49,11 @@ describe.skip('Chat features with two accounts', () => {
})

it('Glyphs messages cannot be edited', () => {
cy.get('[data-cy=chat-glyph]').last().scrollIntoView()
cy.validateOptionNotInContextMenu('[data-cy=chat-glyph]', 'Edit')
})

it('Send image to user B', () => {
it.skip('Send image to user B', () => {
cy.chatFeaturesSendImage(imageLocalPath, 'logo.png')
cy.goToLastImageOnChat()
.invoke('attr', 'src')
Expand All @@ -57,7 +62,7 @@ describe.skip('Chat features with two accounts', () => {
})
})

it('Image messages cannot be edited', () => {
it.skip('Image messages cannot be edited', () => {
cy.validateOptionNotInContextMenu('[data-cy=chat-image]', 'Edit')
})

Expand Down Expand Up @@ -85,16 +90,16 @@ describe.skip('Chat features with two accounts', () => {
it('Assert message received from user A', () => {
//Adding assertion to validate that messages are displayed
cy.goToConversation('Chat User A')
cy.contains(randomMessage).last().scrollIntoView().should('exist')
cy.get('[data-cy=chat-message]').last().scrollIntoView().should('exist')
})

it('Message not sent by same user cannot be edited', () => {
cy.contains(randomMessage).last().as('lastmessage')
cy.get('[data-cy=chat-message]').last().as('lastmessage')
cy.validateOptionNotInContextMenu('@lastmessage', 'Edit')
})

it('User should be able to reply a message', () => {
cy.contains(randomMessage).last().as('lastmessage')
cy.get('[data-cy=chat-message]').last().as('lastmessage')
cy.chatFeaturesReplyMessage('Chat User A', '@lastmessage', textReply)
})

Expand Down Expand Up @@ -137,7 +142,7 @@ describe.skip('Chat features with two accounts', () => {
})
})

it('Assert image received from user A', () => {
it.skip('Assert image received from user A', () => {
cy.goToLastImageOnChat()
.invoke('attr', 'src')
.then((imageSecondAccountSrc) => {
Expand All @@ -161,17 +166,17 @@ describe.skip('Chat features with two accounts', () => {
.last()
.invoke('text')
.then(($text) => {
expect($text).to.match(/d+|[hour[s]? |minute[s]? |second[s]?]\s/)
expect($text).to.contain('now')
})
})

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

it('Add reactions to image in chat', () => {
it.skip('Add reactions to image in chat', () => {
cy.get('[data-cy=chat-image]').last().as('imageToReact')
cy.reactToChatElement('@imageToReact', '[title="smile"]')
cy.validateChatReaction('@imageToReact', '😄')
Expand All @@ -191,11 +196,14 @@ describe.skip('Chat features with two accounts', () => {

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]').should('be.visible').paste({
pasteType: 'text',
pastePayload: randomMessage,
})
cy.get('[data-cy=editable-input]').clear()
})

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

Expand All @@ -204,7 +212,7 @@ describe.skip('Chat features with two accounts', () => {
.last()
.invoke('text')
.then(($text) => {
expect($text).to.contain('a few seconds ago')
expect($text).to.contain('now')
})
})

Expand All @@ -217,7 +225,8 @@ describe.skip('Chat features with two accounts', () => {
.last()
.invoke('text')
.then(($text) => {
expect($text).to.contain('a minute ago')
let regexTimestamp = '((1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm]))'
expect($text).to.match(regexTimestamp)
})
})

Expand All @@ -229,4 +238,41 @@ describe.skip('Chat features with two accounts', () => {
cy.goToConversation('Chat User B')
cy.chatFeaturesSendMessage(randomMessage)
})

it('React to other users reaction', () => {
//import Chat User A account the one that receive reactions previously
cy.importAccount(randomPIN, recoverySeedAccountOne)
cy.validateChatPageIsLoaded()

//Go to conversation with Chat User B
cy.goToConversation('Chat User B')

//Find the last reaction message
cy.get('[data-cy=chat-message]').last().as('messageReacted')
//Message reaction should not have blue background image initially. Click on it
cy.get('@messageReacted')
.scrollIntoView()
.parents('[data-cy=message-container]')
.find('[data-cy=reaction-to-message]')
.as('reactionToMessage')
cy.get('@reactionToMessage')
.should(
'have.css',
'background-image',
'linear-gradient(0deg, rgba(34, 44, 63, 0.5) 0%, rgba(36, 40, 57, 0.5) 100%)',
)
.click()

//Validate count of reactors is two
cy.get('@reactionToMessage')
.find('[data-cy=emoji-reaction-count]')
.should('contain', '2')

//Validate reaction background image is now blue
cy.get('@reactionToMessage').should(
'have.css',
'background-image',
'linear-gradient(40deg, rgb(39, 97, 253) 0%, rgb(40, 109, 254) 100%)',
)
})
})
2 changes: 1 addition & 1 deletion cypress/integration/create-account-negative-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Create Account - Negative Tests', () => {
cy.contains('Pin must be at least 5 characters.')
})

it('Try to create account without username', () => {
it.skip('Try to create account without username', () => {
//Enter PIN screen
cy.createAccountPINscreen(randomPIN)

Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/create-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const randomName = faker.internet.userName(name) // generate random name
const randomStatus = faker.lorem.word() // generate random status
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN

describe('Create Account Validations', () => {
describe.skip('Create Account Validations', () => {
Cypress.on('uncaught:exception', (err, runnable) => false) // temporary until AP-48 gets fixed
it('Create Account', () => {
//Testing in a viewport that does not require to scroll
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('Create Account Validations', () => {
cy.createAccountSubmit()
})

it.skip('Create account successfully without image after attempting to add a NSFW picture', () => {
it('Create account successfully without image after attempting to add a NSFW picture', () => {
//Creating pin
cy.createAccountPINscreen(randomPIN)

Expand Down Expand Up @@ -200,7 +200,7 @@ describe('Create Account Validations', () => {
).should('not.exist')
})

it.skip('Create account with valid image after attempting to add an invalid image file', () => {
it('Create account with valid image after attempting to add an invalid image file', () => {
//Creating pin
cy.createAccountPINscreen(randomPIN)

Expand Down
5 changes: 4 additions & 1 deletion cypress/integration/mobiles-responsiveness.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Run responsiveness tests on several devices', () => {
Cypress.config('pageLoadTimeout', 180000) //adding more time for pageLoadTimeout only for this spec
Cypress.on('uncaught:exception', (err, runnable) => false) // to bypass Module build failed: Error: ENOENT: No such file or directory issue randomly presented
data.allDevices.forEach((item) => {
it(`Create Account on ${item.description}`, () => {
it.skip(`Create Account on ${item.description}`, () => {
cy.viewport(item.width, item.height)
cy.createAccountPINscreen(randomPIN)

Expand Down Expand Up @@ -54,6 +54,9 @@ describe('Run responsiveness tests on several devices', () => {
//Setting viewport
cy.viewport(item.width, item.height)

//Validate profile name displayed
cy.validateChatPageIsLoaded()

//Go to conversation
cy.goToConversation('cypress friend', true)

Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/pin-unlock-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const userPassphrase =
'useful wedding venture reopen forest lawsuit essence hamster kitchen bundle level tower'
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN

describe('Unlock pin should be persisted when store pin is enabled', () => {
describe.skip('Unlock pin should be persisted when store pin is enabled', () => {
it.skip('Create Account with store pin disabled', () => {
//Go to URL, add a PIN and make sure that toggle for save pin is disabled
cy.createAccountPINscreen(randomPIN, false, false)
Expand Down
26 changes: 16 additions & 10 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,12 @@ Cypress.Commands.add('chatFeaturesSendMessage', (message) => {
pasteType: 'text',
pastePayload: message,
})
cy.get('[data-cy=send-message]').click() //sending text message
cy.contains(message, { timeout: 15000 })
cy.get('[data-cy=editable-input]')
.should('have.text', message)
.then(() => {
cy.get('[data-cy=send-message]').click() //sending text message
})
cy.contains(message, { timeout: 30000 })
.last()
.scrollIntoView()
.should('exist')
Expand All @@ -332,7 +336,8 @@ Cypress.Commands.add(
)

Cypress.Commands.add('getReply', (messageReplied) => {
cy.contains(messageReplied)
cy.get('[data-cy=chat-message]')
.contains(messageReplied)
.parent()
.parent()
.find('[data-cy=reply-preview]')
Expand All @@ -352,7 +357,8 @@ Cypress.Commands.add('chatFeaturesSendEmoji', (emojiLocator, emojiValue) => {
Cypress.Commands.add(
'chatFeaturesEditMessage',
(messageToEdit, messageEdited) => {
cy.contains(messageToEdit)
cy.get('[data-cy=chat-message]')
.contains(messageToEdit)
.last()
.scrollIntoView()
.should('exist')
Expand All @@ -364,7 +370,7 @@ Cypress.Commands.add(
.trigger('input')
.type(messageEdited) // editing message
cy.get('[data-cy=edit-message-input]').type('{enter}')
cy.contains(messageToEdit + messageEdited)
cy.contains(messageToEdit + messageEdited, { timeout: 30000 })
.last()
.scrollIntoView()
.should('exist')
Expand Down Expand Up @@ -429,7 +435,7 @@ Cypress.Commands.add(
)

Cypress.Commands.add('selectContextMenuOption', (locator, optionText) => {
cy.get(locator).last().scrollIntoView().rightclick()
cy.get(locator).scrollIntoView().rightclick()
cy.contains(optionText).click()
})

Expand Down Expand Up @@ -471,7 +477,7 @@ Cypress.Commands.add('goToConversation', (user, mobile = false) => {
}

//Wait until conversation is fully loaded
cy.get('[data-cy=user-connected]', { timeout: 90000 })
cy.get('[data-cy=user-connected]', { timeout: 120000 })
.should('be.visible')
.should('have.text', user)
})
Expand Down Expand Up @@ -544,9 +550,9 @@ Cypress.Commands.add('validateGlyphsModal', () => {
.then(($text) => {
expect($text).to.be.oneOf(['Astrobunny', 'Genshin Impact 2'])
})
cy.contains('Short description can go here. Lorem ipsum.').should(
'be.visible',
)
cy.contains(
"We're currently in our Alpha stage and working hard on building more features. Follow us on social media for updates on our launch.",
).should('be.visible')
cy.get('.img-container').children().should('have.length', 3)
cy.contains('View Glyph Pack').should('be.visible')
})
Expand Down

0 comments on commit 6a3e1c1

Please sign in to comment.