-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dashboard Navigation] Unit tests #166297
[Dashboard Navigation] Unit tests #166297
Conversation
undefined, | ||
undefined, | ||
savedObjectId | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like that we can use buildMockDashboard
from other plugins. But I really needed it to accept a savedObjectId
parameter. Unfortunately, this looks awful IMO. I wonder if it would be ok for the DashboardContainer
constructor to receive an object of properties rather than a series of arguments?
Or I could just make my own dashboardMock function. But that isn't as much fun. 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely ugly, but it's a mock and they don't have to be pretty! I had to do the exact same thing here.
If you'd like to make the Dashboard Container take an object of arguments that would be great! Alternatively, you can just make buildMockDashboard
optionally take an object of arguments, then pass them into the Dashboard container constructor with undefined
as the defaults. That way it's more flexible.
expect(link).toHaveTextContent('https://example.com'); | ||
const clickEvent = createEvent.click(link, { ctrlKey: true }); | ||
const preventDefault = jest.spyOn(clickEvent, 'preventDefault'); | ||
fireEvent(link, clickEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test logs a console error like Error: Not implemented: navigation (except hash changes)
. This is expected since jsdom does not handle navigation. The tests pass, but the error is annoying. Mocking the window.location
methods did not resolve it. I think the way to fix this is to call preventDefault
, but we need to check that it isn't called. 😖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me! Maybe we should add a comment describing this too? 👀
…vEmbeddable-tests
💔 Build FailedFailed CI Steps
Test Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests look great, thanks so much for tackling it!! 💃 Can't think of anything off the top of my head that wasn't covered.
Part of #161287
These unit tests were designed to test complex cases for the components. Please review carefully and suggest any test cases that I may have overlooked.