Skip to content

Commit c46435c

Browse files
kubestellar-hive[bot]GitHub CopilotCopilot
authored
🐛 Update mission-control-dialog tests for fresh-session reset behavior (#16095)
Align the MissionControlDialog tests with the #16083 behavior change. The fresh-session token no longer resets state on initial mount, so the tests now cover token increments and historical review-mode close behavior. Signed-off-by: GitHub Copilot <copilot@github.com> Co-authored-by: GitHub Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8c1565f commit c46435c

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

web/src/components/mission-control/__tests__/mission-control-dialog.test.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,42 @@ describe('MissionControlDialog', () => {
9494
expect(screen.getByTestId('phase-define')).toBeDefined()
9595
})
9696

97-
it('resets to a fresh session when opened from the sidebar CTA', () => {
98-
render(<MissionControlDialog open={true} onClose={vi.fn()} freshSessionToken={1} />)
97+
it('preserves seeded state on first sidebar CTA open and resets after the token increments', () => {
98+
const { rerender } = render(
99+
<MissionControlDialog open={true} onClose={vi.fn()} freshSessionToken={1} />
100+
)
101+
102+
expect(mockMC.reset).not.toHaveBeenCalled()
103+
104+
rerender(<MissionControlDialog open={false} onClose={vi.fn()} freshSessionToken={1} />)
105+
rerender(<MissionControlDialog open={true} onClose={vi.fn()} freshSessionToken={2} />)
99106

100107
expect(mockMC.reset).toHaveBeenCalledTimes(1)
101108
})
102109

103-
it('resets after reopening from a historical mission into a fresh sidebar session', () => {
110+
it('resets historical review mode on close without resetting again on the first fresh reopen', () => {
111+
const onClose = vi.fn()
104112
const mcWithHistory = {
105113
...mockMC,
106114
loadHistoricalSession: vi.fn(() => true),
107115
}
108116
vi.mocked(useMissionControl).mockReturnValue(mcWithHistory as unknown as ReturnType<typeof useMissionControl>)
109117

110118
const { rerender } = render(
111-
<MissionControlDialog open={true} onClose={vi.fn()} historicalMissionId="mission-1" />
119+
<MissionControlDialog open={true} onClose={onClose} historicalMissionId="mission-1" />
112120
)
113121

114122
expect(mcWithHistory.loadHistoricalSession).toHaveBeenCalledWith('mission-1')
123+
expect(screen.getByText('REVIEW')).toBeDefined()
115124
expect(mcWithHistory.reset).not.toHaveBeenCalled()
116125

117-
rerender(<MissionControlDialog open={true} onClose={vi.fn()} freshSessionToken={1} />)
126+
fireEvent.click(screen.getByTestId('mission-control-cancel'))
127+
128+
expect(onClose).toHaveBeenCalledTimes(1)
129+
expect(mcWithHistory.reset).toHaveBeenCalledTimes(1)
130+
131+
rerender(<MissionControlDialog open={false} onClose={onClose} freshSessionToken={1} />)
132+
rerender(<MissionControlDialog open={true} onClose={onClose} freshSessionToken={1} />)
118133

119134
expect(mcWithHistory.reset).toHaveBeenCalledTimes(1)
120135
})

0 commit comments

Comments
 (0)