Skip to content

Commit

Permalink
(BSR)[PRO] test: add financial management test
Browse files Browse the repository at this point in the history
(BSR)[PRO] test: fix intercept url matching

(BSR)[PRO] test: add a data-test-id + Prettier
  • Loading branch information
ncanseco-pass authored and scolson-pass committed Sep 5, 2024
1 parent 83accee commit 59391ec
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pro/cypress/e2e/features/financialManagement.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ Feature: Financial Management - messages, links to external help page, reimburse
Then I can see the reimbursement details
# Scenario: I can download accounting receipt as pdf
# Then I can download accounting receipt as pdf

Scenario: Automatic link venue with bank account
Given I am logged in with account 2
And I go to the "Gestion financière" page
And I go to "Informations bancaires" view
When I remove "Lieu avec justificatif à 0€" venue from my bank account
Then no venue should be linked to my account
When I add "Lieu avec justificatif à 0€" venue to my bank account
Then "Lieu avec justificatif à 0€" venue should be linked to my account
54 changes: 54 additions & 0 deletions pro/cypress/e2e/step-definitions/financialManagement.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,45 @@ When('I download reimbursement details', () => {
// })
// })

When('I remove {string} venue from my bank account', (venue: string) => {
cy.findByTestId('reimbursement-bank-account-linked-venues').within(() => {
cy.contains('Lieu(x) rattaché(s) à ce compte bancaire')
cy.contains('Certains de vos lieux ne sont pas rattachés.')
cy.contains(venue)

cy.findByText('Modifier').click()
})

cy.findByRole('dialog').within(() => {
cy.findByLabelText(venue).should('be.checked')
cy.findByLabelText(venue).uncheck()

cy.findByText('Enregistrer').click()
cy.findByText('Confirmer').click()
})
})

When('I add {string} venue to my bank account', (venue: string) => {
cy.findByTestId('reimbursement-bank-account-linked-venues').within(() => {
cy.contains('Aucun lieu n’est rattaché à ce compte bancaire.')

cy.findByText('Rattacher un lieu').click()
})

cy.intercept({ method: 'PATCH', url: 'offerers/*/bank-accounts/*' }).as(
'patchOfferer'
)

cy.findByRole('dialog').within(() => {
cy.findByLabelText(venue).should('not.be.checked')
cy.findByLabelText(venue).check()

cy.findByText('Enregistrer').click()
})

cy.wait('@patchOfferer').its('response.statusCode').should('equal', 204)
})

Then('I can see the reimbursement details', () => {
const filename = `${Cypress.config('downloadsFolder')}/remboursements_pass_culture.csv`

Expand Down Expand Up @@ -109,3 +148,18 @@ Then('No receipt results should be displayed', () => {
'Vous n’avez pas encore de justificatifs de remboursement disponibles'
)
})

Then('no venue should be linked to my account', () => {
cy.findAllByTestId('global-notification-success').should(
'contain',
'Vos modifications ont bien été prises en compte.'
)
})

Then('{string} venue should be linked to my account', (venue: string) => {
cy.findByTestId('reimbursement-bank-account-linked-venues').within(() => {
cy.contains('Lieu(x) rattaché(s) à ce compte bancaire')
cy.contains('Certains de vos lieux ne sont pas rattachés.')
cy.contains(venue)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ export const ReimbursementBankAccount = ({
</ButtonLink>
</div>
) : (
<div className={styles['linked-venues-section']}>
<div
className={styles['linked-venues-section']}
data-testid="reimbursement-bank-account-linked-venues"
>
<div className={styles['linked-venues-section-title']}>
Lieu(x) rattaché(s) à ce compte bancaire
{hasWarning && managedVenues.length > 0 && (
Expand Down

0 comments on commit 59391ec

Please sign in to comment.