Skip to content

Commit

Permalink
(PC-32595)[PRO] refactor: test e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliochka committed Oct 22, 2024
1 parent fc6c6de commit fc36021
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 191 deletions.
16 changes: 8 additions & 8 deletions pro/cypress/e2e/adage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ describe('ADAGE discovery', () => {
},
})
).as('searchOfferTemplate')
cy.intercept({
method: 'DELETE',
url: '/adage-iframe/collective/template/**/favorites',
}).as('delete_fav')
cy.intercept({
method: 'POST',
url: '/adage-iframe/logs/fav-offer/',
}).as('fav-offer')
})

it('It should put an offer in favorite', () => {
Expand All @@ -194,10 +202,6 @@ describe('ADAGE discovery', () => {

cy.stepLog({ message: 'I add first offer to favorites' })
cy.findByText(offerName).parent().click()
cy.intercept({
method: 'POST',
url: '/adage-iframe/logs/fav-offer/',
}).as('fav-offer')
cy.findByTestId('favorite-inactive').click()
cy.wait('@fav-offer', { responseTimeout: 30 * 1000 })
.its('response.statusCode')
Expand All @@ -212,10 +216,6 @@ describe('ADAGE discovery', () => {
cy.contains(offerName).should('be.visible')

cy.stepLog({ message: 'we can remove it from favorites' })
cy.intercept({
method: 'DELETE',
url: '/adage-iframe/collective/template/**/favorites',
}).as('delete_fav')
cy.findByTestId('favorite-active').click()
cy.wait('@delete_fav').its('response.statusCode').should('eq', 204)
cy.findByTestId('global-notification-success').should(
Expand Down
82 changes: 41 additions & 41 deletions pro/cypress/e2e/collectiveBooking.cy.ts
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

Expand Down Expand Up @@ -178,3 +137,44 @@ describe('Search for collective bookings', () => {
expectOffersAreFound(expectedResults)
})
})

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')
}
14 changes: 7 additions & 7 deletions pro/cypress/e2e/cookieBanner.cy.ts
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')
Expand Down Expand Up @@ -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')
cy.findByText('Vos adresses')
cy.findByText('Ajouter un lieu')
cy.findAllByTestId('spinner').should('not.exist')
}
104 changes: 23 additions & 81 deletions pro/cypress/e2e/desk.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { addDays, format } from 'date-fns'

describe('Desk (Guichet) feature', () => {
let login: string
const password = 'user@AZERTY123'

beforeEach(() => {
cy.visit('/connexion')
Expand All @@ -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(
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
}
8 changes: 6 additions & 2 deletions pro/cypress/e2e/financialManagement.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +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: 'GET', url: '/offerers/*/bank-accounts' }).as('getOfferersBankAccounts')
cy.intercept({ method: 'GET', url: '/offerers/*/bank-accounts' }).as(
'getOfferersBankAccounts'
)
})

it('Check messages, reimbursement details and offerer selection change', () => {
Expand Down Expand Up @@ -181,7 +183,9 @@ describe('Financial Management - messages, links to external help page, reimburs
cy.findByLabelText(venue).uncheck()
cy.findByText('Enregistrer').click()
cy.findByText('Confirmer').click()
cy.wait('@getOfferersBankAccounts').its('response.statusCode').should('equal', 200)
cy.wait('@getOfferersBankAccounts')
.its('response.statusCode')
.should('equal', 200)
})

cy.stepLog({ message: 'no venue should be linked to my account' })
Expand Down
2 changes: 1 addition & 1 deletion pro/cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Navigation', () => {
let login = ''
const password = 'user@AZERTY123'

before(() => {
beforeEach(() => {
cy.visit('/connexion')
cy.request({
method: 'GET',
Expand Down
Loading

0 comments on commit fc36021

Please sign in to comment.