Skip to content

Commit

Permalink
(PC-32281)[PRO] test: finish e2e migration desk
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliochka authored and scolson-pass committed Oct 16, 2024
1 parent 9c8c032 commit f2f3749
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 77 deletions.
23 changes: 23 additions & 0 deletions api/src/pcapi/sandboxes/scripts/getters/pro.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pcapi.core.bookings import models as bookings_models
import pcapi.core.bookings.factories as bookings_factories
from pcapi.core.categories import subcategories_v2 as subcategories
from pcapi.core.educational import models as educational_models
import pcapi.core.educational.factories as educational_factories
Expand Down Expand Up @@ -31,6 +33,27 @@ def create_regular_pro_user() -> dict:
return {"user": get_pro_user_helper(pro_user), "siren": offerer.siren}


def create_pro_user_with_bookings() -> dict:
pro_user = users_factories.ProFactory()
offerer = offerers_factories.OffererFactory()
offerers_factories.UserOffererFactory(user=pro_user, offerer=offerer)
venue = offerers_factories.VenueFactory(name="Mon Lieu", managingOfferer=offerer, isPermanent=True)
offerers_factories.VirtualVenueFactory(managingOfferer=offerer)

bookings_factories.BookingFactory(token="2XTM3W", stock__offer__venue=venue)
bookings_factories.BookingFactory(
token="XUSEDX", stock__offer__venue=venue, status=bookings_models.BookingStatus.USED
)
bookings_factories.BookingFactory(token="OTHERX")
bookings_factories.BookingFactory(
token="CANCEL", stock__offer__venue=venue, status=bookings_models.BookingStatus.CANCELLED
)
bookings_factories.BookingFactory(
token="REIMBU", stock__offer__venue=venue, status=bookings_models.BookingStatus.REIMBURSED
)
return {"user": get_pro_user_helper(pro_user)}


def create_regular_pro_user_with_virtual_offer() -> dict:
pro_user = users_factories.ProFactory()
offerer = offerers_factories.OffererFactory()
Expand Down
188 changes: 111 additions & 77 deletions pro/cypress/e2e/migrations/desk.cy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
describe('Desk (Guichet) feature', () => {
const login = 'activation@example.com'
let login: string
const password = 'user@AZERTY123'

before(() => {
// cy.request({
// method: 'GET',
// url: 'http://localhost:5001/sandboxes/pro/create_regular_pro_user',
// }).then((response) => {
// login = response.body.user.email
// })
})

beforeEach(() => {
cy.visit('/connexion')
cy.request({
method: 'GET',
url: 'http://localhost:5001/sandboxes/pro/create_pro_user_with_bookings',
}).then((response) => {
login = response.body.user.email
})
})

it('I should see help information on desk page', () => {
cy.stepLog({ message: 'I am logged in with account' })
cy.login({
email: login,
Expand All @@ -25,9 +25,6 @@ describe('Desk (Guichet) feature', () => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})
})

it('I should see the top of the page when changing page', () => {
cy.stepLog({ message: 'The identity check message is displayed' })
cy.findByText(
'N’oubliez pas de vérifier l’identité du bénéficiaire avant de valider la contremarque.'
Expand All @@ -50,18 +47,43 @@ describe('Desk (Guichet) feature', () => {
})
})

it("Saisie et validation d'une nouvelle contremarque @todo: besoin de données, absentes dans la sandbox", () => {
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.url().then((urlSource) => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})
cy.stepLog({ message: 'I add this countermark "2XTM3W"' })
cy.findByLabelText('Contremarque').type('2XTM3W')

cy.stepLog({ message: 'I validate the countermark' })
cy.findByText('Coupon vérifié, cliquez sur "Valider" pour enregistrer')
cy.findByText('Valider la contremarque').click()

cy.stepLog({ message: 'the booking is done' })
// @todo: Write code here that turns the phrase above into concrete actions
cy.findByText('Contremarque validée !')
})

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.url().then((urlSource) => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})
cy.stepLog({ message: 'I add this countermark "XXXXXX"' })
cy.findByLabelText('Contremarque').type('XXXXXX')

Expand All @@ -73,84 +95,96 @@ describe('Desk (Guichet) feature', () => {
cy.findByText('Valider la contremarque').should('be.disabled')
})

it("Saisie et invalidation d'une contremarque déjà validée @todo: besoin de données, absentes dans la sandbox", () => {
cy.stepLog({ message: 'I add this countermark "2XTM3W"' })
cy.findByLabelText('Contremarque').type('2XTM3W')
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 validate the countermark' })
cy.stepLog({ message: 'I go to the "Guichet" page' })
cy.url().then((urlSource) => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})
cy.stepLog({ message: 'I add this countermark "XUSEDX"' })
cy.findByLabelText('Contremarque').type('XUSEDX')
cy.findByText('Cette contremarque a été validée.')

cy.stepLog({ message: 'I invalidate the countermark' })
cy.findByText('Valider la contremarque').click()
cy.findByText('continuer').click()

cy.stepLog({ message: 'Contremarque déjà validée' })
// @todo: check que se passe-t-il ???
// cy.findByTestId('desk-message').should(
// 'have.text',
// "La contremarque n'existe pas"
// )
// cy.findByText('Valider la contremarque').should('be.disabled')
cy.stepLog({ message: 'The countermark is invalidated' })
cy.findByText('Contremarque invalidée !')
})

it("Saisie d'une contremarque d'un autre pro @todo: besoin de données, absentes dans la sandbox", () => {
// @todo: besoin de données, absentes dans la sandbox", () => {
cy.stepLog({ message: 'I add this countermark "??????"' })
cy.findByLabelText('Contremarque').type('??????')
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 validate the countermark' })
cy.findByText('Valider la contremarque').click()
cy.stepLog({ message: 'I go to the "Guichet" page' })
cy.url().then((urlSource) => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})

cy.stepLog({ message: "contremarque d'un autre pro" })
// @todo: check que se passe-t-il ???
// cy.findByTestId('desk-message').should(
// 'have.text',
// "La contremarque n'existe pas"
// )
// cy.findByText('Valider la contremarque').should('be.disabled')
})
cy.stepLog({ message: 'I add this countermark "OTHERX"' })
cy.findByLabelText('Contremarque').type('OTHERX')

it("Saisie de la contremarque d'une réservation non confirmée @todo: besoin de données, absentes dans la sandbox", () => {
cy.stepLog({ message: 'I add this countermark "??????"' })
cy.findByLabelText('Contremarque').type('??????')
cy.stepLog({ message: 'I cannot validate the countermark' })
cy.findByText('Valider la contremarque').should('be.disabled')
cy.findByText(
"Vous n'avez pas les droits nécessaires pour voir cette contremarque"
)
})

cy.stepLog({ message: 'I validate the countermark' })
cy.findByText('Valider la contremarque').click()
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: "contremarque d'une réservation non confirmée" })
// @todo: check que se passe-t-il ???
// cy.findByTestId('desk-message').should(
// 'have.text',
// "La contremarque n'existe pas"
// )
// cy.findByText('Valider la contremarque').should('be.disabled')
})
cy.stepLog({ message: 'I go to the "Guichet" page' })
cy.url().then((urlSource) => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})

it("Saisie de la contremarque d'une réservation annulée @todo: besoin de données, absentes dans la sandbox", () => {
cy.stepLog({ message: 'I add this countermark "??????"' })
cy.findByLabelText('Contremarque').type('??????')
cy.stepLog({ message: 'I add this countermark "CANCEL"' })
cy.findByLabelText('Contremarque').type('CANCEL')

cy.stepLog({ message: 'I validate the countermark' })
cy.findByText('Valider la contremarque').click()

cy.stepLog({ message: "contremarque d'une réservation annulée" })
// @todo: check que se passe-t-il ???
// cy.findByTestId('desk-message').should(
// 'have.text',
// "La contremarque n'existe pas"
// )
// cy.findByText('Valider la contremarque').should('be.disabled')
cy.findByText('Valider la contremarque').should('be.disabled')
cy.findByText('Cette réservation a été annulée')
})

it("Saisie de la contremarque d'une réservation déjà remboursée @todo: besoin de données, absentes dans la sandbox", () => {
cy.stepLog({ message: 'I add this countermark "??????"' })
cy.findByLabelText('Contremarque').type('??????')
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.url().then((urlSource) => {
cy.findAllByText('Guichet').first().click()
cy.url().should('not.equal', urlSource)
})

cy.stepLog({ message: 'I add this countermark "REIMBU"' })
cy.findByLabelText('Contremarque').type('REIMBU')

cy.stepLog({ message: 'I validate the countermark' })
cy.findByText('Valider la contremarque').click()

cy.stepLog({ message: "contremarque d'une réservation déjà remboursée" })
// @todo: check que se passe-t-il ???
// cy.findByTestId('desk-message').should(
// 'have.text',
// "La contremarque n'existe pas"
// )
// cy.findByText('Valider la contremarque').should('be.disabled')
cy.findByText('Valider la contremarque').should('be.disabled')
cy.findByText('Cette réservation a été remboursée')
})
})

0 comments on commit f2f3749

Please sign in to comment.