-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PC-32595)[PRO] refactor: test e2e #14708
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,5 @@ | ||
import { addDays, format } from 'date-fns' | ||
|
||
function expectOffersAreFound(expectedResults: Array<Array<string>>) { | ||
for (let rowLine = 0; rowLine < expectedResults.length - 1; rowLine++) { | ||
const offerLineArray = expectedResults[rowLine + 1] | ||
|
||
cy.findAllByTestId('offer-item-row') | ||
.eq(rowLine) | ||
.within(() => { | ||
cy.get('td').then(($elt) => { | ||
for (let column = 0; column < 5; column++) { | ||
cy.wrap($elt) | ||
.eq(column) | ||
.then((cellValue) => { | ||
if (cellValue.text().length && offerLineArray[column].length) { | ||
return cy | ||
.wrap(cellValue) | ||
.should('contain.text', offerLineArray[column]) | ||
} else { | ||
return true | ||
} | ||
}) | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
function IGoToCollectivePage(login: string) { | ||
const password = 'user@AZERTY123' | ||
|
||
cy.stepLog({ message: 'I am logged in' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
cy.findAllByTestId('spinner').should('not.exist') | ||
|
||
cy.stepLog({ message: 'I open the "reservations/collectives" page' }) | ||
cy.visit('/reservations/collectives') | ||
} | ||
|
||
describe('Search for collective bookings', () => { | ||
let login: string | ||
|
||
|
@@ -178,3 +137,44 @@ describe('Search for collective bookings', () => { | |
expectOffersAreFound(expectedResults) | ||
}) | ||
}) | ||
|
||
function expectOffersAreFound(expectedResults: Array<Array<string>>) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cette fonction peut être mutualisée pour toutes les vérifications d'offres affichées dans:
Plus on peut vérifier le nombre de lignes et le texte |
||
for (let rowLine = 0; rowLine < expectedResults.length - 1; rowLine++) { | ||
const offerLineArray = expectedResults[rowLine + 1] | ||
|
||
cy.findAllByTestId('offer-item-row') | ||
.eq(rowLine) | ||
.within(() => { | ||
cy.get('td').then(($elt) => { | ||
for (let column = 0; column < 5; column++) { | ||
cy.wrap($elt) | ||
.eq(column) | ||
.then((cellValue) => { | ||
if (cellValue.text().length && offerLineArray[column].length) { | ||
return cy | ||
.wrap(cellValue) | ||
.should('contain.text', offerLineArray[column]) | ||
} else { | ||
return true | ||
} | ||
}) | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
function IGoToCollectivePage(login: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Peut-on en faire un fonction pour tous les cas se logguant et allant sur une page précise (également pour accueil):
|
||
const password = 'user@AZERTY123' | ||
|
||
cy.stepLog({ message: 'I am logged in' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
cy.findAllByTestId('spinner').should('not.exist') | ||
|
||
cy.stepLog({ message: 'I open the "reservations/collectives" page' }) | ||
cy.visit('/reservations/collectives') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
function homePageLoaded(): void { | ||
cy.findByText('Bienvenue dans l’espace acteurs culturels') | ||
cy.findByText('Vos adresses') | ||
cy.findByText('Ajouter un lieu') | ||
cy.findAllByTestId('spinner').should('not.exist') | ||
} | ||
|
||
describe('Cookie management with no login', () => { | ||
beforeEach(() => { | ||
cy.visit('/connexion') | ||
|
@@ -242,3 +235,10 @@ describe('Cookie management with login', () => { | |
cy.get('#orejime-app-item-beamer').should('not.be.checked') | ||
}) | ||
}) | ||
|
||
function homePageLoaded(): void { | ||
cy.findByText('Bienvenue dans l’espace acteurs culturels') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. également utilisée par |
||
cy.findByText('Vos adresses') | ||
cy.findByText('Ajouter un lieu') | ||
cy.findAllByTestId('spinner').should('not.exist') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ import { addDays, format } from 'date-fns' | |
|
||
describe('Desk (Guichet) feature', () => { | ||
let login: string | ||
const password = 'user@AZERTY123' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ce password par défaut est défini dans plusieurs tests, on devrait pouvoir le définir une seule fois pour tous les tests |
||
|
||
beforeEach(() => { | ||
cy.visit('/connexion') | ||
|
@@ -15,16 +14,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('I should see help information on desk page', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'The identity check message is displayed' }) | ||
cy.findByText( | ||
|
@@ -49,16 +39,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('Should validate a countermark', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "2XTM3W"' }) | ||
cy.findByLabelText('Contremarque').type('2XTM3W') | ||
|
@@ -72,16 +53,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('It should decline a non-valid countermark', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "XXXXXX"' }) | ||
cy.findByLabelText('Contremarque').type('XXXXXX') | ||
|
@@ -95,16 +67,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('It should decline an event countermark more than 48h before', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "TOSOON"' }) | ||
cy.findByLabelText('Contremarque').type('TOSOON') | ||
|
@@ -121,16 +84,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('Should invalidate a already used countermark', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "XUSEDX"' }) | ||
cy.findByLabelText('Contremarque').type('XUSEDX') | ||
|
@@ -145,16 +99,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('Should not be able to validate an other pro countermark', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "OTHERX"' }) | ||
cy.findByLabelText('Contremarque').type('OTHERX') | ||
|
@@ -167,16 +112,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('Should not be able to validate a cancelled countermark', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "CANCEL"' }) | ||
cy.findByLabelText('Contremarque').type('CANCEL') | ||
|
@@ -187,16 +123,7 @@ describe('Desk (Guichet) feature', () => { | |
}) | ||
|
||
it('Should not be able to validate a reimbursed countermark', () => { | ||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
goToDeskPage(login) | ||
|
||
cy.stepLog({ message: 'I add this countermark "REIMBU"' }) | ||
cy.findByLabelText('Contremarque').type('REIMBU') | ||
|
@@ -206,3 +133,18 @@ describe('Desk (Guichet) feature', () => { | |
cy.findByText('Cette réservation a été remboursée') | ||
}) | ||
}) | ||
|
||
function goToDeskPage(login: string) { | ||
const password = 'user@AZERTY123' | ||
|
||
cy.stepLog({ message: 'I am logged in with account' }) | ||
cy.login({ | ||
email: login, | ||
password: password, | ||
redirectUrl: '/', | ||
}) | ||
|
||
cy.stepLog({ message: 'I go to the "Guichet" page' }) | ||
cy.findAllByText('Guichet').first().click() | ||
cy.url().should('contain', '/guichet') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,9 @@ describe('Financial Management - messages, links to external help page, reimburs | |
login = response.body.user.email | ||
}) | ||
cy.intercept({ method: 'GET', url: '/offerers/*' }).as('getOfferers') | ||
cy.intercept({ method: 'PATCH', url: 'offerers/*/bank-accounts/*' }).as( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attention, ceci a été changé dans le dernier fix financialManagement, à rebaser |
||
'patchBankAccount' | ||
) | ||
}) | ||
|
||
it('Check messages, reimbursement details and offerer selection change', () => { | ||
|
@@ -213,17 +216,13 @@ describe('Financial Management - messages, links to external help page, reimburs | |
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(['@getOfferers', '@patchOfferer']).then((interception) => { | ||
cy.wait(['@getOfferers', '@patchBankAccount']).then((interception) => { | ||
if (interception[0].response) { | ||
expect(interception[0].response.statusCode).to.equal(200) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est pas mal de mettre tous les intercept dans le before, ça posait problème avec cucumber, mais là c'est bien!
J'ai vu, dans
createIndividualOffer
que celle-ci est déclarée 2 fois:Peux-tu en profiter pour éviter ce(s) doublon(s) ?