-
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...ent/feature/FeatureView/FeatureOverview/FeatureLifecycle/FeatureLifecycleTooltip.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { screen } from '@testing-library/react'; | ||
import { FeatureLifecycleTooltip } from './FeatureLifecycleTooltip'; | ||
import { render } from 'utils/testRenderer'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { vi } from 'vitest'; | ||
import type { LifecycleStage } from './LifecycleStage'; | ||
|
||
const currentTime = '2024-04-25T08:05:00.000Z'; | ||
const twoMinutesAgo = '2024-04-25T08:03:00.000Z'; | ||
const oneHourAgo = '2024-04-25T07:05:00.000Z'; | ||
const twoHoursAgo = '2024-04-25T06:05:00.000Z'; | ||
|
||
const renderOpenTooltip = (stage: LifecycleStage) => { | ||
render( | ||
<FeatureLifecycleTooltip stage={stage}> | ||
<span>child</span> | ||
</FeatureLifecycleTooltip>, | ||
); | ||
|
||
const child = screen.getByText('child'); | ||
|
||
userEvent.hover(child); | ||
}; | ||
|
||
test('render initial stage', async () => { | ||
vi.setSystemTime(currentTime); | ||
const enteredStageAt = twoMinutesAgo; | ||
|
||
renderOpenTooltip({ name: 'initial', enteredStageAt }); | ||
|
||
await screen.findByText('initial'); | ||
await screen.findByText('2 minutes'); | ||
await screen.findByText( | ||
"This feature toggle is currently in the initial phase of it's life cycle.", | ||
); | ||
}); | ||
|
||
test('render pre-live stage', async () => { | ||
vi.setSystemTime(currentTime); | ||
const enteredStageAt = twoMinutesAgo; | ||
const lastSeenAt = oneHourAgo; | ||
|
||
renderOpenTooltip({ | ||
name: 'pre-live', | ||
environments: [{ name: 'development', lastSeenAt }], | ||
enteredStageAt, | ||
}); | ||
|
||
await screen.findByText('pre-live'); | ||
await screen.findByText('development'); | ||
await screen.findByText('1 hour ago'); | ||
}); | ||
|
||
test('render live stage', async () => { | ||
vi.setSystemTime(currentTime); | ||
const enteredStageAt = twoMinutesAgo; | ||
const lastSeenAt = twoHoursAgo; | ||
|
||
renderOpenTooltip({ | ||
name: 'live', | ||
environments: [{ name: 'production', lastSeenAt }], | ||
enteredStageAt, | ||
}); | ||
|
||
await screen.findByText('Is this feature complete?'); | ||
await screen.findByText('live'); | ||
await screen.findByText('production'); | ||
await screen.findByText('2 hours ago'); | ||
}); | ||
|
||
test('render completed stage with still active', async () => { | ||
vi.setSystemTime(currentTime); | ||
const enteredStageAt = twoMinutesAgo; | ||
const lastSeenAt = twoHoursAgo; | ||
|
||
renderOpenTooltip({ | ||
name: 'completed', | ||
status: 'kept', | ||
environments: [{ name: 'production', lastSeenAt }], | ||
enteredStageAt, | ||
}); | ||
|
||
await screen.findByText('completed'); | ||
await screen.findByText('production'); | ||
await screen.findByText('2 hours ago'); | ||
expect(screen.queryByText('Archive feature')).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('render completed stage safe to archive', async () => { | ||
vi.setSystemTime(currentTime); | ||
const enteredStageAt = twoMinutesAgo; | ||
|
||
renderOpenTooltip({ | ||
name: 'completed', | ||
status: 'kept', | ||
environments: [], | ||
enteredStageAt, | ||
}); | ||
|
||
await screen.findByText('completed'); | ||
await screen.findByText('Archive feature'); | ||
}); |