Skip to content

Commit

Permalink
(PC-34243) feat(BookingPage): do not show Qr code for subcategoies th…
Browse files Browse the repository at this point in the history
…at are event and not coming from syncro
  • Loading branch information
nmajorfrances-pass committed Feb 10, 2025
1 parent ddbcc57 commit 8f1219f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function BookingDetailsTicketContent({
const activationCode = booking.activationCode ? (
<TicketCode withdrawalType={withdrawalType ?? undefined} code={booking.activationCode.code} />
) : null

const accessExternalOfferButton = completedUrl ? (
<ExternalTouchableLink
as={ButtonWithLinearGradient}
Expand All @@ -78,6 +79,7 @@ export function BookingDetailsTicketContent({
qrCodeData={booking.qrCodeData ?? undefined}
externalBookings={externalBookings}
venue={venue}
isEvent={isEvent}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ describe('TicketBody', () => {
})

describe('<QrCode/> display', () => {
it('should display the QR code when the the booking have a QR code and the offer subcategory allows to have a qr code', () => {
render(<TicketBody {...initialProps} venue={venue} />)
it('should display the QR code when booking have a QR code and offer is not an event', () => {
render(
<TicketBody
{...initialProps}
subcategoryId={SubcategoryIdEnum.PARTITION}
venue={venue}
isEvent={false}
/>
)

expect(screen.getByTestId('qr-code')).toBeOnTheScreen()
})

it('should not display the QR code when event subcategory is in subcategories list without QR code display', () => {
it('should not display the QR code when booking is an event and not an external booking', () => {
render(
<TicketBody
{...initialProps}
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
venue={venue}
isEvent
/>
)

Expand All @@ -65,6 +73,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
externalBookings={{ barcode: 'barcode' }}
venue={venue}
isEvent
/>
)

Expand All @@ -79,6 +88,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
externalBookings={{ barcode: 'barcode' }}
venue={venue}
isEvent
/>
)

Expand All @@ -94,6 +104,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
externalBookings={{ barcode: 'barcode' }}
venue={venue}
isEvent
/>
)

Expand All @@ -108,6 +119,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
externalBookings={{ barcode: 'barcode' }}
venue={venue}
isEvent
/>
)

Expand All @@ -126,6 +138,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
externalBookings={{ barcode: 'barcode' }}
venue={venue}
isEvent
/>
)

Expand All @@ -141,6 +154,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.EVENEMENT_PATRIMOINE}
externalBookings={{ barcode: 'barcode' }}
venue={venue}
isEvent
/>
)

Expand All @@ -150,7 +164,7 @@ describe('TicketBody', () => {

describe('Withdrawal', () => {
it("should not display withdrawal informations for legacy offer that doesn't withdrawal informations", () => {
render(<TicketBody {...initialProps} withdrawalType={undefined} venue={venue} />)
render(<TicketBody {...initialProps} withdrawalType={undefined} venue={venue} isEvent />)

expect(screen.queryByTestId('withdrawal-info')).not.toBeOnTheScreen()
})
Expand All @@ -164,6 +178,7 @@ describe('TicketBody', () => {
withdrawalType={WithdrawalTypeEnum.no_ticket}
withdrawalDelay={0}
venue={venue}
isEvent
/>
)

Expand All @@ -182,6 +197,7 @@ describe('TicketBody', () => {
withdrawalType={WithdrawalTypeEnum.by_email}
withdrawalDelay={twoDays}
venue={venue}
isEvent
/>
)

Expand All @@ -196,6 +212,7 @@ describe('TicketBody', () => {
subcategoryId={SubcategoryIdEnum.FESTIVAL_MUSIQUE}
withdrawalType={WithdrawalTypeEnum.on_site}
venue={venue}
isEvent
/>
)

Expand All @@ -205,7 +222,7 @@ describe('TicketBody', () => {

describe('Consulter mes e-mails display', () => {
it('should show the button to open mail', async () => {
render(<TicketBody {...initialProps} withdrawalType={undefined} venue={venue} />)
render(<TicketBody {...initialProps} withdrawalType={undefined} venue={venue} isEvent />)

const checkEmailsButton = screen.queryByText('Consulter mes e-mails')

Expand All @@ -214,7 +231,7 @@ describe('TicketBody', () => {

it('should not show the button to open mail if no mail app is available', async () => {
mockIsMailAppAvailable = false
render(<TicketBody {...initialProps} withdrawalType={undefined} venue={venue} />)
render(<TicketBody {...initialProps} withdrawalType={undefined} venue={venue} isEvent />)

const checkEmailsButton = screen.queryByText('Consulter mes e-mails')

Expand Down
14 changes: 3 additions & 11 deletions src/features/bookings/components/TicketBody/TicketBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@ type Props = {
qrCodeData?: string
externalBookings?: SeatWithQrCodeProps
venue: BookingVenueResponse
isEvent: boolean
}

const notQrCodeSubcategories = [
SubcategoryIdEnum.FESTIVAL_MUSIQUE,
SubcategoryIdEnum.CONCERT,
SubcategoryIdEnum.EVENEMENT_MUSIQUE,
SubcategoryIdEnum.FESTIVAL_SPECTACLE,
SubcategoryIdEnum.SPECTACLE_REPRESENTATION,
]

export const TicketBody: FunctionComponent<Props> = ({
withdrawalDelay,
withdrawalType,
Expand All @@ -36,9 +29,8 @@ export const TicketBody: FunctionComponent<Props> = ({
qrCodeData,
externalBookings,
venue,
isEvent,
}) => {
const subcategoryShouldHaveQrCode = !notQrCodeSubcategories.includes(subcategoryId)

if (externalBookings)
return (
<SafeSeatWithQrCode
Expand All @@ -50,7 +42,7 @@ export const TicketBody: FunctionComponent<Props> = ({
{...externalBookings}
/>
)

const subcategoryShouldHaveQrCode = !isEvent
if (qrCodeData && subcategoryShouldHaveQrCode) return <QrCode qrCode={qrCodeData} />

if (!withdrawalType) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,20 @@ describe('BookingDetails', () => {
expect(screen.queryByText('Accéder à l’offre')).not.toBeOnTheScreen()
})

it('should display booking qr code if offer is physical', async () => {
it('should display booking qr code when offer is not digital and is event and external booking', async () => {
const externalBooking: BookingsResponse['ongoing_bookings'][number] = structuredClone({
...ongoingBookings,
externalBookings: [{ barcode: 'PASSCULTURE:v3;TOKEN:352UW4', seat: 'A12' }],
})
externalBooking.stock.offer.isDigital = false
renderBookingDetails(externalBooking)

await screen.findByText('Ma réservation')

expect(await screen.findByTestId('qr-code')).toBeOnTheScreen()
})

it('should not display booking qr code when offer is not digital and is event and not an external booking', async () => {
const booking: BookingsResponse['ongoing_bookings'][number] = structuredClone(ongoingBookings)
booking.stock.offer.isDigital = false
renderBookingDetails(booking)
Expand Down

0 comments on commit 8f1219f

Please sign in to comment.