-
-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show strategies used by segments (#5407)
This PR displays change request usage of segments when such usage is returned from the API. It expects at least #5406 to have been merged before it can be merged. ![image](https://github.com/Unleash/unleash/assets/17786332/c74bb1c9-07f9-4bca-95bb-4ca020398444)
- Loading branch information
1 parent
20bfa73
commit b021e7c
Showing
4 changed files
with
168 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...mponent/segments/SegmentDelete/SegmentDeleteUsedSegment/SegmentDeleteUsedSegment.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import { render } from 'utils/testRenderer'; | ||
import { screen } from '@testing-library/react'; | ||
import { SegmentDeleteUsedSegment } from './SegmentDeleteUsedSegment'; | ||
|
||
describe('SegmentDeleteUsedSegment', () => { | ||
it('should link to change requests for change request strategies', async () => { | ||
const projectId = 'project1'; | ||
|
||
const crStrategies = [ | ||
{ | ||
projectId, | ||
featureName: 'feature1', | ||
strategyName: 'flexible rollout', | ||
environment: 'default', | ||
changeRequest: { id: 1, title: null }, | ||
}, | ||
{ | ||
projectId, | ||
featureName: 'feature1', | ||
strategyName: 'flexible rollout', | ||
environment: 'default', | ||
changeRequest: { id: 2, title: 'My cool CR' }, | ||
}, | ||
]; | ||
|
||
render( | ||
<SegmentDeleteUsedSegment | ||
changeRequestStrategies={crStrategies} | ||
segment={{ | ||
id: 1, | ||
name: 'segment', | ||
description: 'description', | ||
project: projectId, | ||
constraints: [], | ||
createdAt: '', | ||
createdBy: '', | ||
}} | ||
open={true} | ||
strategies={[]} | ||
onClose={() => {}} | ||
/>, | ||
); | ||
|
||
const links = await screen.findAllByRole('link'); | ||
expect(links).toHaveLength(crStrategies.length); | ||
|
||
const [link1, link2] = links; | ||
|
||
expect(link1).toHaveTextContent('#1'); | ||
expect(link1).toHaveAccessibleDescription('Change request 1'); | ||
expect(link1).toHaveAttribute( | ||
'href', | ||
`/projects/${projectId}/change-requests/1`, | ||
); | ||
expect(link2).toHaveTextContent('#2 (My cool CR)'); | ||
expect(link2).toHaveAccessibleDescription('Change request 2'); | ||
expect(link2).toHaveAttribute( | ||
'href', | ||
`/projects/${projectId}/change-requests/2`, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters