Skip to content

Commit

Permalink
Add export win button behind a user feature group
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgain committed Mar 1, 2024
1 parent 8464c63 commit 4670ea5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/client/components/CompanyLocalHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const CompanyLocalHeader = ({
flashMessages,
company,
csrfToken,
hasExportWinFeatureGroup,
}) =>
company && (
<>
Expand Down Expand Up @@ -188,6 +189,18 @@ const CompanyLocalHeader = ({
>
Add export project
</Button>
{hasExportWinFeatureGroup && (
<Button
as={StyledButtonLink}
data-test="header-add-export-win"
href={`${urls.companies.exportWins.create()}?step=officer_details&company=${company.id}`}
aria-label={`Add export win`}
buttonColour={GREY_3}
buttonTextColour={TEXT_COLOUR}
>
Add export win
</Button>
)}
</StyledButtonContainer>
</GridCol>
</GridRow>
Expand Down
1 change: 1 addition & 0 deletions src/client/components/CompanyLocalHeader/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const state2props = (state) => state[ID]

export const companyState2Props = (state) => ({
csrfToken: state.csrfToken,
hasExportWinFeatureGroup: state.activeFeatureGroups?.includes('export-wins'),
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const company = '/companies/00009ae3-1912-e411-8a2b-e4115bead28a/overview'

describe('Export win user feature groups', () => {
context('Company page"', () => {
it('should render the "Add export win" button', () => {
cy.setUserFeatureGroups(['export-wins'])
cy.visit(company)
cy.get('[data-test="header-add-export-win"]').should('exist')
})
it('should hide the "Add export win" button', () => {
cy.setUserFeatureGroups([])
cy.visit(company)
cy.get('[data-test="header-add-export-win"]').should('not.exist')
})
})
})

0 comments on commit 4670ea5

Please sign in to comment.