mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
lint e2e stepdefinition files files
This commit is contained in:
parent
a0af5d87ae
commit
8db179c517
@ -9,12 +9,9 @@ Given('the user navigates to page {string}', (page: string) => {
|
||||
|
||||
// login related
|
||||
|
||||
Given(
|
||||
'the user is logged in as {string} {string}',
|
||||
(email: string, password: string) => {
|
||||
cy.login(email, password)
|
||||
}
|
||||
)
|
||||
Given('the user is logged in as {string} {string}', (email: string, password: string) => {
|
||||
cy.login(email, password)
|
||||
})
|
||||
|
||||
Then('the user is logged in with username {string}', (username: string) => {
|
||||
const overviewPage = new OverviewPage()
|
||||
|
||||
@ -23,13 +23,15 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri
|
||||
linkPattern = /\/overview/
|
||||
break
|
||||
default:
|
||||
throw new Error(`Error in "Then the user receives an e-mail containing the {string} link" step: incorrect linkname string "${linkName}"`)
|
||||
throw new Error(
|
||||
`Error in "Then the user receives an e-mail containing the {string} link" step: incorrect linkname string "${linkName}"`,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
cy.origin(
|
||||
Cypress.env('mailserverURL'),
|
||||
{ args: { emailSubject, linkPattern, userEMailSite } },
|
||||
({ emailSubject, linkPattern, userEMailSite }) => {
|
||||
({ emailSubject, linkPattern, userEMailSite }) => {
|
||||
cy.visit('/') // navigate to user's e-mail site (on fake mail server)
|
||||
cy.get(userEMailSite.emailInbox).should('be.visible')
|
||||
|
||||
@ -39,11 +41,9 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri
|
||||
.first()
|
||||
.click()
|
||||
|
||||
cy.get(userEMailSite.emailMeta)
|
||||
.find(userEMailSite.emailSubject)
|
||||
.contains(emailSubject)
|
||||
cy.get(userEMailSite.emailMeta).find(userEMailSite.emailSubject).contains(emailSubject)
|
||||
|
||||
cy.get('.email-content', { timeout: 2000})
|
||||
cy.get('.email-content', { timeout: 2000 })
|
||||
.find('.plain-text')
|
||||
.contains(linkPattern)
|
||||
.invoke('text')
|
||||
@ -51,41 +51,42 @@ Then('the user receives an e-mail containing the {string} link', (linkName: stri
|
||||
const emailLink = text.match(linkPattern)[0]
|
||||
cy.task('setEmailLink', emailLink)
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
And('the user receives the transaction e-mail about {string} GDD from {string}', (amount: string, senderName:string) => {
|
||||
cy.origin(
|
||||
Cypress.env('mailserverURL'),
|
||||
{ args: { amount, senderName, userEMailSite } },
|
||||
({ amount, senderName, userEMailSite }) => {
|
||||
const subject = `${senderName} hat dir ${amount} Gradido gesendet`
|
||||
const linkPattern = /\/transactions/
|
||||
cy.visit('/')
|
||||
cy.get(userEMailSite.emailInbox).should('be.visible')
|
||||
And(
|
||||
'the user receives the transaction e-mail about {string} GDD from {string}',
|
||||
(amount: string, senderName: string) => {
|
||||
cy.origin(
|
||||
Cypress.env('mailserverURL'),
|
||||
{ args: { amount, senderName, userEMailSite } },
|
||||
({ amount, senderName, userEMailSite }) => {
|
||||
const subject = `${senderName} hat dir ${amount} Gradido gesendet`
|
||||
const linkPattern = /\/transactions/
|
||||
cy.visit('/')
|
||||
cy.get(userEMailSite.emailInbox).should('be.visible')
|
||||
|
||||
cy.get(userEMailSite.emailList)
|
||||
.find('.email-item')
|
||||
.filter(`:contains(${subject})`)
|
||||
.first()
|
||||
.click()
|
||||
|
||||
cy.get(userEMailSite.emailMeta)
|
||||
.find(userEMailSite.emailSubject)
|
||||
.contains(subject)
|
||||
|
||||
cy.get('.email-content', { timeout: 2000})
|
||||
.find('.plain-text')
|
||||
.contains(linkPattern)
|
||||
.invoke('text')
|
||||
.then((text) => {
|
||||
const emailLink = text.match(linkPattern)[0]
|
||||
cy.task('setEmailLink', emailLink)
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
cy.get(userEMailSite.emailList)
|
||||
.find('.email-item')
|
||||
.filter(`:contains(${subject})`)
|
||||
.first()
|
||||
.click()
|
||||
|
||||
cy.get(userEMailSite.emailMeta).find(userEMailSite.emailSubject).contains(subject)
|
||||
|
||||
cy.get('.email-content', { timeout: 2000 })
|
||||
.find('.plain-text')
|
||||
.contains(linkPattern)
|
||||
.invoke('text')
|
||||
.then((text) => {
|
||||
const emailLink = text.match(linkPattern)[0]
|
||||
cy.task('setEmailLink', emailLink)
|
||||
})
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
When('the user opens the {string} link in the browser', (linkName: string) => {
|
||||
const resetPasswordPage = new ResetPasswordPage()
|
||||
@ -105,6 +106,8 @@ When('the user opens the {string} link in the browser', (linkName: string) => {
|
||||
cy.get(overviewPage.rightLastTransactionsList).should('be.visible')
|
||||
break
|
||||
default:
|
||||
throw new Error(`Error in "Then the user receives an e-mail containing the {string} link" step: incorrect link name string "${linkName}"`)
|
||||
throw new Error(
|
||||
`Error in "Then the user receives an e-mail containing the {string} link" step: incorrect link name string "${linkName}"`,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
@ -9,7 +9,7 @@ When(
|
||||
sendPage.enterReceiverEmail(email)
|
||||
sendPage.enterAmount(amount)
|
||||
sendPage.enterMemoText(memoText)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
And('the user submits the send form', () => {
|
||||
@ -17,15 +17,23 @@ And('the user submits the send form', () => {
|
||||
cy.get(sendPage.confirmationBox).should('be.visible')
|
||||
})
|
||||
|
||||
|
||||
Then('the transaction details are presented for confirmation {string} {string} {string} {string} {string}', (receiverEmail: string, sendAmount: string, memoText: string, senderBalance: string, newSenderBalance: string) => {
|
||||
cy.get('.transaction-confirm-send').contains(receiverEmail)
|
||||
cy.get('.transaction-confirm-send').contains(`+ ${sendAmount} GDD`)
|
||||
cy.get('.transaction-confirm-send').contains(memoText)
|
||||
cy.get('.transaction-confirm-send').contains(`+ ${senderBalance} GDD`)
|
||||
cy.get('.transaction-confirm-send').contains(`− ${sendAmount} GDD`)
|
||||
cy.get('.transaction-confirm-send').contains(`+ ${newSenderBalance} GDD`)
|
||||
})
|
||||
Then(
|
||||
'the transaction details are presented for confirmation {string} {string} {string} {string} {string}',
|
||||
(
|
||||
receiverEmail: string,
|
||||
sendAmount: string,
|
||||
memoText: string,
|
||||
senderBalance: string,
|
||||
newSenderBalance: string,
|
||||
) => {
|
||||
cy.get('.transaction-confirm-send').contains(receiverEmail)
|
||||
cy.get('.transaction-confirm-send').contains(`+ ${sendAmount} GDD`)
|
||||
cy.get('.transaction-confirm-send').contains(memoText)
|
||||
cy.get('.transaction-confirm-send').contains(`+ ${senderBalance} GDD`)
|
||||
cy.get('.transaction-confirm-send').contains(`− ${sendAmount} GDD`)
|
||||
cy.get('.transaction-confirm-send').contains(`+ ${newSenderBalance} GDD`)
|
||||
},
|
||||
)
|
||||
|
||||
When('the user submits the transaction by confirming', (receiverName: string, amount) => {
|
||||
cy.intercept({
|
||||
@ -38,11 +46,14 @@ When('the user submits the transaction by confirming', (receiverName: string, am
|
||||
|
||||
cy.wait('@sendCoins').then((interception) => {
|
||||
cy.wrap(interception.response?.statusCode).should('eq', 200)
|
||||
cy.wrap(interception.request.body)
|
||||
.should('have.property', 'query', `mutation ($identifier: String!, $amount: Decimal!, $memo: String!) {
|
||||
cy.wrap(interception.request.body).should(
|
||||
'have.property',
|
||||
'query',
|
||||
`mutation ($identifier: String!, $amount: Decimal!, $memo: String!) {
|
||||
sendCoins(identifier: $identifier, amount: $amount, memo: $memo)
|
||||
}
|
||||
` )
|
||||
`,
|
||||
)
|
||||
cy.wrap(interception.response?.body)
|
||||
.should('have.nested.property', 'data.sendCoins')
|
||||
.and('equal', true)
|
||||
@ -50,21 +61,30 @@ When('the user submits the transaction by confirming', (receiverName: string, am
|
||||
cy.get('[data-test="send-transaction-success-text"]').should('be.visible')
|
||||
})
|
||||
|
||||
Then('the {string} and {string} are displayed on the {string} page', (name: string, amount: string, page: string) => {
|
||||
switch (page) {
|
||||
case 'overview':
|
||||
cy.get('.align-items-center').contains(`${name}`)
|
||||
cy.get('.align-items-center').contains(`${amount} GDD`)
|
||||
break
|
||||
case 'send':
|
||||
cy.get('.align-items-center').contains(`${name}`)
|
||||
cy.get('.align-items-center').contains(`${amount} GDD`)
|
||||
break
|
||||
case 'transactions':
|
||||
cy.get('div.mt-3 > div > div.test-list-group-item').eq(0).contains('div.gdd-transaction-list-item-name', `${name}`)
|
||||
cy.get('div.mt-3 > div > div.test-list-group-item').eq(0).contains('[data-test="transaction-amount"]', `${amount} GDD`)
|
||||
break
|
||||
default:
|
||||
throw new Error(`Error in "Then the {string} and {string} are displayed on the {string}} page" step: incorrect page name string "${page}"`)
|
||||
}
|
||||
})
|
||||
Then(
|
||||
'the {string} and {string} are displayed on the {string} page',
|
||||
(name: string, amount: string, page: string) => {
|
||||
switch (page) {
|
||||
case 'overview':
|
||||
cy.get('.align-items-center').contains(`${name}`)
|
||||
cy.get('.align-items-center').contains(`${amount} GDD`)
|
||||
break
|
||||
case 'send':
|
||||
cy.get('.align-items-center').contains(`${name}`)
|
||||
cy.get('.align-items-center').contains(`${amount} GDD`)
|
||||
break
|
||||
case 'transactions':
|
||||
cy.get('div.mt-3 > div > div.test-list-group-item')
|
||||
.eq(0)
|
||||
.contains('div.gdd-transaction-list-item-name', `${name}`)
|
||||
cy.get('div.mt-3 > div > div.test-list-group-item')
|
||||
.eq(0)
|
||||
.contains('[data-test="transaction-amount"]', `${amount} GDD`)
|
||||
break
|
||||
default:
|
||||
throw new Error(
|
||||
`Error in "Then the {string} and {string} are displayed on the {string}} page" step: incorrect page name string "${page}"`,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@ -13,26 +13,20 @@ When('the user submits no credentials', () => {
|
||||
loginPage.submitLogin()
|
||||
})
|
||||
|
||||
When(
|
||||
'the user submits the credentials {string} {string}',
|
||||
(email: string, password: string) => {
|
||||
cy.intercept('POST', '/graphql', (req) => {
|
||||
if (
|
||||
req.body.hasOwnProperty('query') &&
|
||||
req.body.query.includes('mutation')
|
||||
) {
|
||||
req.alias = 'login'
|
||||
}
|
||||
})
|
||||
When('the user submits the credentials {string} {string}', (email: string, password: string) => {
|
||||
cy.intercept('POST', '/graphql', (req) => {
|
||||
if (req.body.hasOwnProperty('query') && req.body.query.includes('mutation')) {
|
||||
req.alias = 'login'
|
||||
}
|
||||
})
|
||||
|
||||
loginPage.enterEmail(email)
|
||||
loginPage.enterPassword(password)
|
||||
loginPage.submitLogin()
|
||||
cy.wait('@login').then((interception) => {
|
||||
expect(interception.response.statusCode).equals(200)
|
||||
})
|
||||
}
|
||||
)
|
||||
loginPage.enterEmail(email)
|
||||
loginPage.enterPassword(password)
|
||||
loginPage.submitLogin()
|
||||
cy.wait('@login').then((interception) => {
|
||||
expect(interception.response.statusCode).equals(200)
|
||||
})
|
||||
})
|
||||
|
||||
// password reset related
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ And('the user opens the change password menu', () => {
|
||||
})
|
||||
|
||||
When('the user fills the password form with:', (table) => {
|
||||
let hashedTableRows = table.rowsHash()
|
||||
const hashedTableRows = table.rowsHash()
|
||||
profilePage.enterOldPassword(hashedTableRows['Old password'])
|
||||
profilePage.enterNewPassword(hashedTableRows['New password'])
|
||||
profilePage.enterRepeatPassword(hashedTableRows['Repeat new password'])
|
||||
|
||||
@ -10,7 +10,7 @@ When(
|
||||
registrationPage.enterFirstname(firstname)
|
||||
registrationPage.enterLastname(lastname)
|
||||
registrationPage.enterEmail(email)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
And('the user agrees to the privacy policy', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user