mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
e2e: fix email check step for case of empty email list
This commit is contained in:
parent
6f708de78d
commit
31f120cfd8
@ -1,31 +1,34 @@
|
||||
import { defineStep } from '@badeball/cypress-cucumber-preprocessor'
|
||||
|
||||
const emailClientList = '.email-list'
|
||||
|
||||
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'
|
||||
{ args: { emailClientList, emailTitle, recipientEmailAddress } },
|
||||
({ emailClientList, emailTitle, recipientEmailAddress }) => {
|
||||
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
|
||||
//----
|
||||
cy.get(emailClientList).then(($list) => {
|
||||
// Check if the list has child elements
|
||||
// const hasEmails = $list.children('li').length > 0
|
||||
|
||||
if ($list.children('li').length > 0) {
|
||||
cy.get(emailClientList).find('li').then(($emails) => {
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user