-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(integration_tests): Added basic integration tests for SubmitQuer…
…yButton
- Loading branch information
Showing
2 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
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,64 @@ | ||
// Libraries | ||
import React from 'react' | ||
|
||
// Components | ||
import SubmitQueryButton from 'src/timeMachine/components/SubmitQueryButton' | ||
|
||
// Utils | ||
import {renderWithRedux} from 'src/mockState' | ||
import {fireEvent, waitFor} from '@testing-library/react' | ||
|
||
// Types | ||
import {RemoteDataState} from 'src/types' | ||
|
||
const stateOverride = { | ||
timeMachines: { | ||
activeTimeMachineID: 'veo', | ||
timeMachines: { | ||
veo: { | ||
draftQueries: [{text: 'this is a draft query'}], | ||
activeQueryIndex: 0, | ||
queryResults: { | ||
status: RemoteDataState.NotStarted, | ||
}, | ||
view: { | ||
properties: { | ||
queries: [{text: 'draftstate'}], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
describe('TimeMachine.Components.SubmitQueryButton', () => { | ||
describe('if button is clicked', () => { | ||
it('disables the submit button when no query is present', () => { | ||
const {getByTitle} = renderWithRedux(<SubmitQueryButton />) | ||
|
||
const SubmitBtn = getByTitle('Submit') | ||
fireEvent.click(SubmitBtn) | ||
// expect the button to still be on submit | ||
expect(getByTitle('Submit')).toBeTruthy() | ||
}) | ||
it('allows the query to be cancelled after submission', async () => { | ||
const {getByTitle, getByText} = renderWithRedux( | ||
<SubmitQueryButton />, | ||
s => ({ | ||
...s, | ||
...stateOverride, | ||
}) | ||
) | ||
|
||
const SubmitBtn = getByTitle('Submit') | ||
fireEvent.click(SubmitBtn) | ||
|
||
const CancelBtn = getByTitle('Cancel') | ||
// expect the button to toggle to Cancel | ||
expect(CancelBtn).toBeTruthy() | ||
fireEvent.click(CancelBtn) | ||
// aborts the query and returns the query to submit mode | ||
expect(await waitFor(() => getByTitle('Submit'))).toBeTruthy() | ||
}) | ||
}) | ||
}) |
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