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

Show 'Not set' in details page when company has no address #7603

Merged
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 @@ -7,6 +7,7 @@ import { SPACING_POINTS } from '@govuk-react/constants'

import { Badge, SummaryTable } from '../../../components'
import urls from '../../../../lib/urls'
import { NOT_SET_TEXT } from '../../../../apps/companies/constants'

const StyledAddressList = styled('ul')`
margin-top: ${SPACING_POINTS[2]}px;
Expand Down Expand Up @@ -59,13 +60,16 @@ const SectionAddresses = ({ company, isDnbCompany, isArchived }) => {
)
}
>
<Table.Row>
{!hasOnlyOneAddress && (
<Address address={company.registeredAddress} isRegistered={true} />
)}

<Address address={company.address} isRegistered={hasOnlyOneAddress} />
</Table.Row>
{company.address ? (
<Table.Row>
{!hasOnlyOneAddress && (
<Address address={company.registeredAddress} isRegistered={true} />
)}
<Address address={company.address} isRegistered={hasOnlyOneAddress} />
</Table.Row>
) : (
<SummaryTable.Row>{NOT_SET_TEXT}</SummaryTable.Row>
)}
</SummaryTable>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const { assertCompanyBreadcrumbs } = require('../../support/assertions')
const {
assertCompanyBreadcrumbs,
assertSummaryTable,
} = require('../../support/assertions')
const fixtures = require('../../fixtures')
const selectors = require('../../../../selectors')
const urls = require('../../../../../src/lib/urls')
const { companyFaker } = require('../../fakers/companies')
const { addressFaker } = require('../../fakers/addresses')

describe('Companies business details', () => {
context(
Expand Down Expand Up @@ -196,4 +200,40 @@ describe('Companies business details', () => {
cy.get('[data-test="edit-one-list-information"]').should('not.exist')
})
})

context(
'when viewing the company address on the buisness details page',
() => {
it('should display the address for a company with an address', () => {
const companyWithAddress = companyFaker({
address: addressFaker({ line_1: 'Address Line 1' }),
})
cy.intercept(
'GET',
`/api-proxy/v4/company/${companyWithAddress.id}`,
companyWithAddress
).as('businessDetails')
cy.visit(urls.companies.businessDetails(companyWithAddress.id))
cy.wait('@businessDetails')
cy.contains('Address Line 1').should('be.visible')
})

it('should display the not set text for a company without an address', () => {
const companyWithoutAddress = companyFaker({ address: null })
cy.intercept(
'GET',
`/api-proxy/v4/company/${companyWithoutAddress.id}`,
companyWithoutAddress
).as('businessDetails')
cy.visit(urls.companies.businessDetails(companyWithoutAddress.id))
cy.wait('@businessDetails')
assertSummaryTable({
dataTest: 'addressesDetailsContainer',
heading: 'Addresses',
showEditLink: true,
content: ['Not set'],
})
})
}
)
})