-
Notifications
You must be signed in to change notification settings - Fork 19
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
15 changed files
with
222 additions
and
143 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Tour } from './Tour'; | ||
import { testRender as render, screen } from '../../testUtils/test-utils'; | ||
import { aggsState } from '../../reducers/aggs/aggsSlice'; | ||
import { queryState } from '../../reducers/query/querySlice'; | ||
import { viewState } from '../../reducers/view/viewSlice'; | ||
import { merge } from '../../testUtils/functionHelpers'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { MODE_LIST } from '../../constants'; | ||
import * as viewActions from '../../reducers/view/viewSlice'; | ||
|
||
const renderComponent = (newAggsState, newQueryState, newViewModelState) => { | ||
merge(newAggsState, aggsState); | ||
merge(newQueryState, queryState); | ||
merge(newViewModelState, viewState); | ||
|
||
const data = { | ||
aggs: newAggsState, | ||
query: newQueryState, | ||
view: newViewModelState, | ||
}; | ||
return render(<Tour />, { preloadedState: data }); | ||
}; | ||
|
||
describe('Tour loading behavior', () => { | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
const user = userEvent.setup({ delay: null }); | ||
|
||
test("Tour doesn't load if page still loading", async () => { | ||
renderComponent({}, {}, { showTour: false }); | ||
expect(screen.queryByRole('dialog')).toBeNull(); | ||
}); | ||
|
||
test("Tour doesn't load unless tourShown state is true", async () => { | ||
renderComponent({ activeCall: '' }, {}, { showTour: false }); | ||
expect(screen.queryByRole('dialog')).toBeNull(); | ||
renderComponent({ activeCall: '' }, {}, { showTour: true }); | ||
expect(await screen.findByRole('dialog')).toBeDefined(); | ||
}); | ||
|
||
test('Tour launches by clicking button', async () => { | ||
const tourShownSpy = jest | ||
.spyOn(viewActions, 'tourShown') | ||
.mockImplementation(() => jest.fn()); | ||
|
||
renderComponent( | ||
{ activeCall: '' }, | ||
{ tab: MODE_LIST }, | ||
{ | ||
showTour: false, | ||
}, | ||
); | ||
|
||
expect(screen.getByRole('button', { name: /Take a tour/ })).toBeVisible(); | ||
await user.click(screen.getByRole('button', { name: /Take a tour/ })); | ||
expect(tourShownSpy).toHaveBeenCalled(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.