1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/segments/SegmentProjectAlert.test.tsx
Nuno Góis b496990f79
chore: add no unused imports biome rule (#5855)
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`.


![image](https://github.com/Unleash/unleash/assets/14320932/fd84dea8-6b20-4ba5-bfd8-047b9dcf2bff)

![image](https://github.com/Unleash/unleash/assets/14320932/990bb0b0-760a-4c5e-8136-d957e902bf0b)
2024-01-11 12:44:05 +00:00

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`,
);
});
});