Skip to content
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-33349)[PRO] fix: The app preview should not display the venue det… #15824

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export const OfferSection = ({
{!offerData.isVenueVirtual && isOfferAddressEnabled && (
<SummarySubSection title="Localisation de l’offre">
<SummaryDescriptionList
listDataTestId="localisation-offer-details"
descriptions={[
{
title: 'Intitulé',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen, waitFor } from '@testing-library/react'
import { screen, waitFor, within } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { addDays, format } from 'date-fns'
import { generatePath, Route, Routes } from 'react-router-dom'
Expand Down Expand Up @@ -663,6 +663,39 @@ describe('Summary', () => {
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', () => {
Expand Down
38 changes: 28 additions & 10 deletions pro/src/components/OfferAppPreview/VenueDetails/VenueDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 (
<div className={style['venue-details']}>
Expand Down
Loading