mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-03-01 12:44:28 +00:00
feat(e2e): e2e - chat notification (#9303)
This commit is contained in:
parent
d0348545ad
commit
795881e5b4
17
cypress/e2e/Chat.Notification.feature
Normal file
17
cypress/e2e/Chat.Notification.feature
Normal file
@ -0,0 +1,17 @@
|
||||
Feature: Chat notification badge
|
||||
As a user
|
||||
I want to see a notification badge on the chat icon
|
||||
When another user sends me a chat message
|
||||
|
||||
Background:
|
||||
Given the following "users" are in the database:
|
||||
| slug | email | password | id | name | termsAndConditionsAgreedVersion |
|
||||
| alice | alice@example.org | 1234 | alice | Alice | 0.0.4 |
|
||||
| bob | bob@example.org | 4321 | bob | Bob | 0.0.4 |
|
||||
|
||||
Scenario: Receive chat notification live via websocket
|
||||
Given I am logged in as "bob"
|
||||
And I navigate to page "/"
|
||||
And I see no unread chat messages in the header
|
||||
When "alice" sends a chat message "Hello Bob!" to "bob"
|
||||
Then I see 1 unread chat message in the header
|
||||
@ -0,0 +1,13 @@
|
||||
import { defineStep } from '@badeball/cypress-cucumber-preprocessor'
|
||||
|
||||
defineStep('I see no unread chat messages in the header', () => {
|
||||
cy.get('.chat-notification-menu:visible', { timeout: 15000 }).should('exist')
|
||||
cy.get('.chat-notification-menu:visible .count.--danger').should('not.exist')
|
||||
})
|
||||
|
||||
defineStep('I see {int} unread chat message in the header', (count) => {
|
||||
cy.get('.chat-notification-menu:visible .count.--danger', { timeout: 15000 }).should(
|
||||
'contain',
|
||||
count,
|
||||
)
|
||||
})
|
||||
@ -0,0 +1,46 @@
|
||||
import { defineStep } from '@badeball/cypress-cucumber-preprocessor'
|
||||
import './../../commands'
|
||||
import './../../factories'
|
||||
|
||||
const createRoomMutation = `
|
||||
mutation ($userId: ID!) {
|
||||
CreateRoom(userId: $userId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const createMessageMutation = `
|
||||
mutation ($roomId: ID!, $content: String) {
|
||||
CreateMessage(roomId: $roomId, content: $content) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
defineStep(
|
||||
'{string} sends a chat message {string} to {string}',
|
||||
(senderSlug, message, recipientSlug) => {
|
||||
cy.neode()
|
||||
.then((neode) => {
|
||||
return neode.cypher(
|
||||
`MATCH (sender:User {slug: $senderSlug})-[:PRIMARY_EMAIL]->(e:EmailAddress)
|
||||
MATCH (recipient:User {slug: $recipientSlug})
|
||||
RETURN e.email AS senderEmail, recipient.id AS recipientId`,
|
||||
{ senderSlug, recipientSlug },
|
||||
)
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result.records).to.have.length.greaterThan(0,
|
||||
`No users found for sender "${senderSlug}" or recipient "${recipientSlug}"`)
|
||||
const senderEmail = result.records[0].get('senderEmail')
|
||||
const recipientId = result.records[0].get('recipientId')
|
||||
return cy.authenticateAs({ email: senderEmail, password: '1234' }).then((client) => {
|
||||
return client.request(createRoomMutation, { userId: recipientId }).then((roomData) => {
|
||||
const roomId = roomData.CreateRoom.id
|
||||
return client.request(createMessageMutation, { roomId, content: message })
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user