From b407418e8a06914abb435915580c34d2bd66cdcd Mon Sep 17 00:00:00 2001 From: Amine Louveau <=> Date: Mon, 13 Jan 2025 10:53:01 +0100 Subject: [PATCH] (PC-33349)[PRO] fix: The app preview should not display the venue details. --- .../OfferSection/OfferSection.tsx | 1 + .../__specs__/SummaryScreen.spec.tsx | 35 ++++++++++++++++- .../VenueDetails/VenueDetails.tsx | 38 ++++++++++++++----- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/pro/src/components/IndividualOffer/SummaryScreen/OfferSection/OfferSection.tsx b/pro/src/components/IndividualOffer/SummaryScreen/OfferSection/OfferSection.tsx index 0d538ef696e..1752cd580c8 100644 --- a/pro/src/components/IndividualOffer/SummaryScreen/OfferSection/OfferSection.tsx +++ b/pro/src/components/IndividualOffer/SummaryScreen/OfferSection/OfferSection.tsx @@ -232,6 +232,7 @@ export const OfferSection = ({ {!offerData.isVenueVirtual && isOfferAddressEnabled && ( { expect(screen.getAllByText('mon adresse')).toHaveLength(2) expect(screen.getAllByText('ma street 1 ma ville')).toHaveLength(2) }) + + it('should render component with new sections and empty address data', async () => { + vi.spyOn(api, 'getOfferer').mockResolvedValue( + defaultGetOffererResponseModel + ) + customContext.offer = getIndividualOfferFactory({ + isEvent: true, + address: null, + }) + + renderSummary( + customContext, + generatePath( + getIndividualOfferPath({ + step: OFFER_WIZARD_STEP_IDS.SUMMARY, + mode: OFFER_WIZARD_MODE.CREATION, + }), + { offerId: 'AA' } + ), + { features: ['WIP_ENABLE_OFFER_ADDRESS'] } + ) + + expect(await screen.findByText(/Structure/)).toBeInTheDocument() + expect( + await screen.findByText('Localisation de l’offre') + ).toBeInTheDocument() + + expect( + within(screen.getByTestId('localisation-offer-details')).getAllByText( + '-' + ) + ).toHaveLength(2) + }) }) describe('banners', () => { diff --git a/pro/src/components/OfferAppPreview/VenueDetails/VenueDetails.tsx b/pro/src/components/OfferAppPreview/VenueDetails/VenueDetails.tsx index e19396adb58..816ea5aac4b 100644 --- a/pro/src/components/OfferAppPreview/VenueDetails/VenueDetails.tsx +++ b/pro/src/components/OfferAppPreview/VenueDetails/VenueDetails.tsx @@ -2,6 +2,7 @@ import { AddressResponseIsLinkedToVenueModel, GetOfferVenueResponseModel, } from 'apiClient/v1' +import { useActiveFeature } from 'commons/hooks/useActiveFeature' import { computeAddressDisplayName } from 'repository/venuesService' import style from './VenueDetails.module.scss' @@ -17,18 +18,35 @@ export const VenueDetails = ({ address, withdrawalDetails, }: VenueDetailsProps): JSX.Element => { - const { street, postalCode, city } = address || venue + const isOfferAddressEnabled = useActiveFeature('WIP_ENABLE_OFFER_ADDRESS') - const label = address ? address.label || '' : venue.publicName || venue.name + function computeAddress() { + let venueAddressString = '-' + let label = '-' - const venueAddressString = computeAddressDisplayName( - { - street, - postalCode: postalCode || '', - city: city || '', - }, - false - ) + if (!isOfferAddressEnabled) { + label = venue.publicName || venue.name + venueAddressString = [label, venue.street, venue.postalCode, venue.city] + .filter((str) => Boolean(str)) + .join(' - ') + } else if (address) { + const { street, postalCode, city } = address + + label = address.label || '-' + + venueAddressString = computeAddressDisplayName( + { + street, + postalCode: postalCode || '', + city: city || '', + }, + false + ) + } + return { label, venueAddressString } + } + + const { label, venueAddressString } = computeAddress() return (