mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: add ui test for mark completed button (#6953)
Co-authored-by: kwasniew <kwasniewski.mateusz@gmail.com>
This commit is contained in:
parent
49e84d3a91
commit
9f6badf5df
@ -4,7 +4,10 @@ import { render } from 'utils/testRenderer';
|
|||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
import type { LifecycleStage } from './LifecycleStage';
|
import type { LifecycleStage } from './LifecycleStage';
|
||||||
import { DELETE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
import {
|
||||||
|
DELETE_FEATURE,
|
||||||
|
UPDATE_FEATURE,
|
||||||
|
} from 'component/providers/AccessProvider/permissions';
|
||||||
|
|
||||||
const currentTime = '2024-04-25T08:05:00.000Z';
|
const currentTime = '2024-04-25T08:05:00.000Z';
|
||||||
const twoMinutesAgo = '2024-04-25T08:03:00.000Z';
|
const twoMinutesAgo = '2024-04-25T08:03:00.000Z';
|
||||||
@ -16,7 +19,7 @@ const renderOpenTooltip = (
|
|||||||
onArchive = () => {},
|
onArchive = () => {},
|
||||||
onComplete = () => {},
|
onComplete = () => {},
|
||||||
onUncomplete = () => {},
|
onUncomplete = () => {},
|
||||||
loading = true,
|
loading = false,
|
||||||
) => {
|
) => {
|
||||||
render(
|
render(
|
||||||
<FeatureLifecycleTooltip
|
<FeatureLifecycleTooltip
|
||||||
@ -28,7 +31,12 @@ const renderOpenTooltip = (
|
|||||||
>
|
>
|
||||||
<span>child</span>
|
<span>child</span>
|
||||||
</FeatureLifecycleTooltip>,
|
</FeatureLifecycleTooltip>,
|
||||||
{ permissions: [{ permission: DELETE_FEATURE }] },
|
{
|
||||||
|
permissions: [
|
||||||
|
{ permission: DELETE_FEATURE },
|
||||||
|
{ permission: UPDATE_FEATURE },
|
||||||
|
],
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const child = screen.getByText('child');
|
const child = screen.getByText('child');
|
||||||
@ -120,8 +128,33 @@ test('render completed stage safe to archive', async () => {
|
|||||||
|
|
||||||
await screen.findByText('completed');
|
await screen.findByText('completed');
|
||||||
const button = await screen.findByText('Archive feature');
|
const button = await screen.findByText('Archive feature');
|
||||||
|
|
||||||
button.click();
|
button.click();
|
||||||
|
|
||||||
expect(onArchiveInvoked).toBe(true);
|
expect(onArchiveInvoked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('mark completed button gets activated', async () => {
|
||||||
|
vi.setSystemTime(currentTime);
|
||||||
|
const enteredStageAt = twoMinutesAgo;
|
||||||
|
const lastSeenAt = twoHoursAgo;
|
||||||
|
let onCompleteInvoked = false;
|
||||||
|
const onComplete = () => {
|
||||||
|
onCompleteInvoked = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
renderOpenTooltip(
|
||||||
|
{
|
||||||
|
name: 'live',
|
||||||
|
environments: [{ name: 'production', lastSeenAt }],
|
||||||
|
enteredStageAt,
|
||||||
|
},
|
||||||
|
() => {},
|
||||||
|
onComplete,
|
||||||
|
);
|
||||||
|
|
||||||
|
await screen.findByText('live');
|
||||||
|
const button = await screen.findByText('Mark completed');
|
||||||
|
button.click();
|
||||||
|
|
||||||
|
expect(onCompleteInvoked).toBe(true);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user