-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testsession and actionmodal tests
- Loading branch information
1 parent
e8a5023
commit 10a79b6
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 20 additions & 1 deletion
21
client/src/components/TestSuite/__tests__/TestSession.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
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
45 changes: 45 additions & 0 deletions
45
client/src/components/_common/__tests__/ActionModal.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,45 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import ThemeProvider from 'components/ThemeProvider'; | ||
import { SnackbarProvider } from 'notistack'; | ||
|
||
import { vi } from 'vitest'; | ||
import ActionModal from '../ActionModal'; | ||
|
||
const cancelTestRunMock = vi.fn(); | ||
|
||
test('Modal visible and inputs are shown', () => { | ||
render( | ||
<ThemeProvider> | ||
<SnackbarProvider> | ||
<ActionModal | ||
modalVisible={true} | ||
message="Mock action message" | ||
cancelTestRun={cancelTestRunMock} | ||
/> | ||
</SnackbarProvider> | ||
</ThemeProvider> | ||
); | ||
|
||
const messageText = screen.getByText('Mock action message'); | ||
expect(messageText).toBeVisible(); | ||
}); | ||
|
||
test('Pressing cancel hides the modal', () => { | ||
render( | ||
<ThemeProvider> | ||
<SnackbarProvider> | ||
<ActionModal | ||
modalVisible={true} | ||
message="Mock action message" | ||
cancelTestRun={cancelTestRunMock} | ||
/> | ||
</SnackbarProvider> | ||
</ThemeProvider> | ||
); | ||
|
||
const cancelButton = screen.getByTestId('cancel-button'); | ||
userEvent.click(cancelButton); | ||
expect(cancelTestRunMock).toHaveBeenCalled(); | ||
}); |