diff --git a/pro/cypress/e2e/features/financialManagement.feature b/pro/cypress/e2e/features/financialManagement.feature index 2e94f2223aa..8a9ee7c0cf4 100644 --- a/pro/cypress/e2e/features/financialManagement.feature +++ b/pro/cypress/e2e/features/financialManagement.feature @@ -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 \ No newline at end of file diff --git a/pro/cypress/e2e/step-definitions/financialManagement.cy.ts b/pro/cypress/e2e/step-definitions/financialManagement.cy.ts index 27a1cf08ff5..79279d26c38 100644 --- a/pro/cypress/e2e/step-definitions/financialManagement.cy.ts +++ b/pro/cypress/e2e/step-definitions/financialManagement.cy.ts @@ -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` @@ -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) + }) +}) diff --git a/pro/src/components/ReimbursementBankAccount/ReimbursementBankAccount.tsx b/pro/src/components/ReimbursementBankAccount/ReimbursementBankAccount.tsx index 2288234a327..979a125b2dd 100644 --- a/pro/src/components/ReimbursementBankAccount/ReimbursementBankAccount.tsx +++ b/pro/src/components/ReimbursementBankAccount/ReimbursementBankAccount.tsx @@ -109,7 +109,10 @@ export const ReimbursementBankAccount = ({ ) : ( -
+
Lieu(x) rattaché(s) à ce compte bancaire {hasWarning && managedVenues.length > 0 && (