Skip to content

Commit

Permalink
feat: add ui test for mark completed button (#6953)
Browse files Browse the repository at this point in the history
Co-authored-by: kwasniew <kwasniewski.mateusz@gmail.com>
  • Loading branch information
sjaanus and kwasniew committed Apr 26, 2024
1 parent 49e84d3 commit 9f6badf
Showing 1 changed file with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { render } from 'utils/testRenderer';
import userEvent from '@testing-library/user-event';
import { vi } from 'vitest';
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 twoMinutesAgo = '2024-04-25T08:03:00.000Z';
Expand All @@ -16,7 +19,7 @@ const renderOpenTooltip = (
onArchive = () => {},
onComplete = () => {},
onUncomplete = () => {},
loading = true,
loading = false,
) => {
render(
<FeatureLifecycleTooltip
Expand All @@ -28,7 +31,12 @@ const renderOpenTooltip = (
>
<span>child</span>
</FeatureLifecycleTooltip>,
{ permissions: [{ permission: DELETE_FEATURE }] },
{
permissions: [
{ permission: DELETE_FEATURE },
{ permission: UPDATE_FEATURE },
],
},
);

const child = screen.getByText('child');
Expand Down Expand Up @@ -120,8 +128,33 @@ test('render completed stage safe to archive', async () => {

await screen.findByText('completed');
const button = await screen.findByText('Archive feature');

button.click();

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

0 comments on commit 9f6badf

Please sign in to comment.