Skip to content

Commit

Permalink
test(cypress): new accounts and unskipping tests (#3117)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm authored May 11, 2022
1 parent 7832b3e commit 11c649b
Show file tree
Hide file tree
Showing 18 changed files with 319 additions and 163 deletions.
51 changes: 51 additions & 0 deletions cypress/fixtures/test-data-accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"dataRecovery": {
"accounts": [
{
"id": 1,
"description": "Chat User A",
"recoverySeed": "entry soccer evoke oak bomb joke ugly safe spend arrest bacon remove"
},
{
"id": 2,
"description": "Chat User B",
"recoverySeed": "youth expand artefact absent clown tattoo skill resist interest pill unit rude"
},
{
"id": 3,
"description": "Chat User C",
"recoverySeed": "short loop typical worth force tragic huge rigid despair tree roast hurdle"
},
{
"id": 4,
"description": "cypress",
"recoverySeed": "slice manual beyond few there among solar melody lizard phone rent steel"
},
{
"id": 5,
"description": "cypress friend",
"recoverySeed": "scrub harsh trip extend retreat denial seed ritual win whale clown employ"
},
{
"id": 6,
"description": "Snap QA",
"recoverySeed": "crane hand goat scorpion crime service cloud traffic kid culture left cover"
},
{
"id": 7,
"description": "Snap Friend",
"recoverySeed": "tired because mansion fabric found opera fantasy disease solve sure neglect job"
},
{
"id": 8,
"description": "Chat Pair A",
"recoverySeed": "opera sphere measure dice ripple female vessel proof topic music actual metal"
},
{
"id": 9,
"description": "Chat Pair B",
"recoverySeed": "metal humor they buyer fan year north habit abuse regret hunt luggage"
}
]
}
}
6 changes: 5 additions & 1 deletion cypress/integration-pair-chat/chat-first-user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { dataRecovery } from '../fixtures/test-data-accounts.json'

const faker = require('faker')
const recoverySeed =
'actress wave guitar resist pretty rifle agree hand assault guess vocal speed{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'Chat Pair A')
.map((item) => item.recoverySeed) + '{enter}'
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN

describe('Chat features with two accounts at the same time - First User', () => {
Expand Down
6 changes: 5 additions & 1 deletion cypress/integration-pair-chat/chat-second-user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { dataRecovery } from '../fixtures/test-data-accounts.json'

const faker = require('faker')
const recoverySeed =
'sword dad network author move fault web mimic develop drill cancel warfare{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'Chat Pair B')
.map((item) => item.recoverySeed) + '{enter}'
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN
const longMessage = faker.lorem.words(250) // generate random sentence

Expand Down
9 changes: 6 additions & 3 deletions cypress/integration/chat-features.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { dataRecovery } from '../fixtures/test-data-accounts.json'

const faker = require('faker')
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN
const randomNumber = faker.datatype.number() // generate random number
const randomMessage = faker.lorem.sentence() // generate random sentence
const imageLocalPath = 'cypress/fixtures/images/logo.png'
const randomTextToCopy = faker.lorem.sentence() // generate random sentence
const recoverySeed =
'useful wedding venture reopen forest lawsuit essence hamster kitchen bundle level tower{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'cypress')
.map((item) => item.recoverySeed) + '{enter}'
let imageURL
let randomTextEdited = randomMessage + randomNumber

describe('Chat Features Tests', () => {
it('Chat - Send message on chat', () => {
it('Chat - Send message on chat', { retries: 2 }, () => {
// Import account
cy.importAccount(randomPIN, recoverySeed)

Expand Down
10 changes: 7 additions & 3 deletions cypress/integration/chat-glyphs-validations.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { dataRecovery } from '../fixtures/test-data-accounts.json'

const faker = require('faker')
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN
const recoverySeed =
'useful wedding venture reopen forest lawsuit essence hamster kitchen bundle level tower{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'cypress')
.map((item) => item.recoverySeed) + '{enter}'

describe.skip('Chat - Sending Glyphs Tests', () => {
it('Send a glyph on chat', () => {
describe('Chat - Sending Glyphs Tests', () => {
it('Send a glyph on chat', { retries: 2 }, () => {
//Import account
cy.importAccount(randomPIN, recoverySeed)

Expand Down
11 changes: 7 additions & 4 deletions cypress/integration/chat-images-validations.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { dataRecovery } from '../fixtures/test-data-accounts.json'

const faker = require('faker')
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN
const recoverySeed =
'useful wedding venture reopen forest lawsuit essence hamster kitchen bundle level tower{enter}'

dataRecovery.accounts
.filter((item) => item.description === 'cypress')
.map((item) => item.recoverySeed) + '{enter}'
const pngImagePath = 'cypress/fixtures/images/logo.png'
const jpgImagePath = 'cypress/fixtures/images/jpeg-test.jpg'
const gifImagePath = 'cypress/fixtures/images/gif-test.gif'
const invalidImagePath = 'cypress/fixtures/images/incorrect-image.png'

describe.skip('Chat - Sending Images Tests', () => {
it('PNG image is sent successfully on chat', () => {
describe('Chat - Sending Images Tests', () => {
it('PNG image is sent successfully on chat', { retries: 2 }, () => {
//Import account
cy.importAccount(randomPIN, recoverySeed)

Expand Down
126 changes: 79 additions & 47 deletions cypress/integration/chat-pair-features.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { dataRecovery } from '../fixtures/test-data-accounts.json'

const faker = require('faker')
const recoverySeedAccountOne =
'memory cherry add return that phrase suit plate ladder earth people gravity{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'Chat User A')
.map((item) => item.recoverySeed) + '{enter}'
const recoverySeedAccountTwo =
'position few settle fold sister transfer song speed million congress acoustic version{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'Chat User B')
.map((item) => item.recoverySeed) + '{enter}'
const recoverySeedAccountThree =
'emerge cat innocent buddy install shy topic goddess legend leisure mutual bitter{enter}'
dataRecovery.accounts
.filter((item) => item.description === 'Chat User C')
.map((item) => item.recoverySeed) + '{enter}'
const randomPIN = faker.internet.password(7, false, /[A-Z]/, 'test') // generate random PIN
const randomMessage = faker.lorem.sentence() // generate random sentence
const randomMessageTwo = faker.lorem.sentence() // generate random sentence
Expand All @@ -13,16 +21,22 @@ const fileLocalPath = 'cypress/fixtures/test-file.txt'
const textReply = 'This is a reply to the message'
let glyphURL, imageURL, fileURL

describe.skip('Chat features with two accounts', () => {
it('Ensure chat window from first account is displayed', () => {
//Import first account
cy.importAccount(randomPIN, recoverySeedAccountOne)
//Validate Chat Screen is loaded
cy.validateChatPageIsLoaded()
})
describe('Chat features with two accounts', () => {
it(
'Ensure chat window from first account is displayed',
{ retries: 2 },
() => {
//Import first account
cy.importAccount(randomPIN, recoverySeedAccountOne)
//Validate Chat Screen is loaded
cy.validateChatPageIsLoaded()

//Go to Conversation
cy.goToConversation('Chat User B')
},
)

it('Send emoji to user B', () => {
cy.goToConversation('Chat User B')
cy.chatFeaturesSendEmoji('[title="smile"]', '😄')
cy.get('[data-cy=chat-message] > span')
.last()
Expand Down Expand Up @@ -73,7 +87,7 @@ describe.skip('Chat features with two accounts', () => {
cy.validateOptionNotInContextMenu('[data-cy=chat-glyph]', 'Edit')
})

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

it.skip('Context Menu Options - Image Message', () => {
it('Context Menu Options - Image Message', () => {
let optionsImage = ['Add Reaction', 'Reply', 'Copy Image', 'Save Image']
cy.get('[data-cy=chat-image]').last().as('lastImage')
cy.validateAllOptionsInContextMenu('@lastImage', optionsImage)
})

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

Expand All @@ -114,14 +128,18 @@ describe.skip('Chat features with two accounts', () => {
cy.validateOptionNotInContextMenu('[data-cy=chat-file]', 'Edit')
})

it('Ensure chat window from second account is displayed', () => {
cy.importAccount(randomPIN, recoverySeedAccountTwo)
cy.validateChatPageIsLoaded()
})
it(
'Ensure chat window from second account is displayed',
{ retries: 2 },
() => {
cy.importAccount(randomPIN, recoverySeedAccountTwo)
cy.validateChatPageIsLoaded()
cy.goToConversation('Chat User A')
},
)

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

it.skip('Assert image received from user A', () => {
it('Assert image received from user A', () => {
cy.goToLastImageOnChat()
.invoke('attr', 'src')
.then((imageSecondAccountSrc) => {
Expand Down Expand Up @@ -221,7 +239,7 @@ describe.skip('Chat features with two accounts', () => {
cy.validateChatReaction('@messageToReact', '😄')
})

it.skip('Add reactions to image in chat', () => {
it('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 @@ -239,14 +257,18 @@ describe.skip('Chat features with two accounts', () => {
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').paste({
pasteType: 'text',
pastePayload: randomMessage,
})
cy.get('[data-cy=editable-input]').clear()
})
it(
'User should be able to reply without first clicking into the chat bar - Chat User C',
{ retries: 2 },
() => {
cy.goToConversation('Chat User C')
cy.get('[data-cy=editable-input]').should('be.visible').paste({
pasteType: 'text',
pastePayload: randomMessage,
})
cy.get('[data-cy=editable-input]').clear()
},
)

it('Assert timestamp immediately after sending message', () => {
//Send a random message
Expand Down Expand Up @@ -276,23 +298,33 @@ describe.skip('Chat features with two accounts', () => {
})
})

it('Send a message from third account to second account', () => {
//import Chat User C account
cy.importAccount(randomPIN, recoverySeedAccountThree)
cy.validateChatPageIsLoaded()
//Send a message to Chat User B
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')

it(
'Send a message from third account to second account',
{ retries: 2 },
() => {
//import Chat User C account
cy.importAccount(randomPIN, recoverySeedAccountThree)
cy.validateChatPageIsLoaded()
//Send a message to Chat User B
cy.goToConversation('Chat User B')
cy.chatFeaturesSendMessage(randomMessage)
},
)

it(
'React to other users reaction - Load Account User A',
{ retries: 2 },
() => {
//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')
},
)

it('React to other users reaction - Execute validation', () => {
//Find the last reaction message
cy.get('[data-cy=chat-message]')
.contains(randomMessage)
Expand Down Expand Up @@ -321,7 +353,7 @@ describe.skip('Chat features with two accounts', () => {
cy.get('@reactionToMessage').should(
'have.css',
'background-image',
'linear-gradient(40deg, rgb(39, 97, 253) 0%, rgb(40, 109, 254) 100%)',
'linear-gradient(40deg, rgb(39, 97, 253) 0%, rgb(39, 97, 253) 100%)',
)
})
})
Loading

0 comments on commit 11c649b

Please sign in to comment.