e2e: add email check step to chat notification test

This commit is contained in:
mahula 2025-04-11 12:59:27 +02:00
parent ac57bd85e8
commit 8abef9c932
2 changed files with 36 additions and 4 deletions

View File

@ -16,8 +16,8 @@ Feature: Notifications for Chat Messages via E-Mail
Scenario: No Chat Notification Email when Online
Given I am logged in as "bob-der-baumeister"
When "jenny-rostock" sends a chat message to "bob-der-baumeister"
And "nathan-narrator" sends a chat message to "bob-der-baumeister"
Then "Bob der Baumeister" should receive "one" chat notification email (referencing "Jenny Rostock")
But "Bob der Baumeister" should receive "no" chat notification email (referencing "nathan-narrator")
# When "Jenny Rostock" sends a chat message to "Bob der Baumeister"
# And "Nathan Narrator" sends a chat message to "Bob der Baumeister"
Then "moderator@example.org" should receive no chat notification email
# And "Bob der Baumeister" should receive "0" chat notification email referencing "Nathan Narrator"

View File

@ -0,0 +1,32 @@
import { defineStep } from '@badeball/cypress-cucumber-preprocessor'
defineStep('{string} should receive no chat notification email', (recipientEmailAddress) => {
const emailTitle = 'Neue Chat-Nachricht | New chat message'
cy.origin(
Cypress.env('mailserverURL'),
{ args: { recipientEmailAddress, emailTitle } },
({ recipientEmailAddress, emailTitle }) => {
const emailClientList = '.email-list'
cy.visit('/')
cy.get(emailClientList).should('be.visible')
// check the email list for unread emails with the specific title and recipient address
cy.get(emailClientList).find('li').then(($emails) => {
if ($emails.length === 0) {
expect($emails.length).to.equal(0)
return
}
const unreadEmails = $emails.filter((_, email) => {
const subjectText = Cypress.$(email).find('.title').text().trim()
const senderEmail = Cypress.$(email).find('.subline-from').text().trim()
const isUnread = Cypress.$(email).find('.unread-icon').not('.ng-hide').length > 0
return subjectText.includes(emailTitle) && senderEmail === recipientEmailAddress && isUnread
})
expect(unreadEmails.length).to.equal(0)
})
},
)
})