mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-19 17:52:45 +02:00
Show usage in change requests if that'd cause you to not be able to move the segment into a project. - [x] ~Relies on changes from #5407 (and #5405, #5406) to go through first.~ 
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import React from 'react';
|
|
import { render } from 'utils/testRenderer';
|
|
import { screen } from '@testing-library/react';
|
|
import { SegmentProjectAlert } from './SegmentProjectAlert';
|
|
|
|
describe('SegmentDeleteUsedSegment', () => {
|
|
it('should link to change requests for change request strategies', async () => {
|
|
const projectId = 'project1';
|
|
|
|
const strategies = [
|
|
{
|
|
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' },
|
|
},
|
|
];
|
|
|
|
const projectsUsed = [...new Set(strategies.map((s) => s.projectId))];
|
|
|
|
render(
|
|
<SegmentProjectAlert
|
|
projects={[]}
|
|
availableProjects={[]}
|
|
projectsUsed={projectsUsed}
|
|
strategies={strategies}
|
|
/>,
|
|
);
|
|
|
|
const links = await screen.findAllByRole('link');
|
|
expect(links).toHaveLength(strategies.length + projectsUsed.length);
|
|
|
|
const [projectLink, crLink1, crLink2] = links;
|
|
|
|
expect(projectLink).toHaveTextContent(projectId);
|
|
expect(projectLink).toHaveAttribute('href', `/projects/${projectId}`);
|
|
|
|
expect(crLink1).toHaveTextContent('#1');
|
|
expect(crLink1).toHaveAccessibleDescription('Change request 1');
|
|
expect(crLink1).toHaveAttribute(
|
|
'href',
|
|
`/projects/${projectId}/change-requests/1`,
|
|
);
|
|
|
|
expect(crLink2).toHaveTextContent('#2 (My cool CR)');
|
|
expect(crLink2).toHaveAccessibleDescription('Change request 2');
|
|
expect(crLink2).toHaveAttribute(
|
|
'href',
|
|
`/projects/${projectId}/change-requests/2`,
|
|
);
|
|
});
|
|
});
|