mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
Adds a Biome rule for "no unused imports", which is something we sometimes have trouble catching. We're adding this as a warning for now. It is safely and easily fixable with `yarn lint:fix`.  
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
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`,
|
|
);
|
|
});
|
|
});
|