-
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
[ResponseOps][Connectors] Move create connector button in Management #190125
[ResponseOps][Connectors] Move create connector button in Management #190125
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
@elasticmachine merge upstream |
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 tested and it's working as expected.
Left some small comments 👍
...i/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx
Show resolved
Hide resolved
expect(createFirstActionButton).toBeEnabled(); | ||
userEvent.click(createFirstActionButton); | ||
expect(setAddFlyoutVisibility).toBeCalled(); |
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.
nit:
expect(createFirstActionButton).toBeEnabled(); | |
userEvent.click(createFirstActionButton); | |
expect(setAddFlyoutVisibility).toBeCalled(); | |
userEvent.click(createFirstActionButton); | |
await waitFor(() => { | |
expect(setAddFlyoutVisibility).toBeCalled(); | |
}); |
Two minor things that I would do differently based on the flaky tests we had in the past:
- no need to check if the button is
enabled
when we are clicking it anyway in the next line. - better to wrap the
expect(function).toBeCalled()
in awaitFor
block for a longer timeout.
const queryClient = new QueryClient(); | ||
|
||
describe('ActionsConnectorsHome', () => { | ||
beforeEach(() => {}); |
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.
beforeEach(() => {}); |
location: createLocation('/logs'), | ||
match: { | ||
isExact: true, | ||
path: `/logs`, |
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.
path: `/logs`, | |
path: '/logs', |
await waitFor(() => { | ||
expect(screen.queryByRole('button', { name: 'Create connector' })).not.toBeInTheDocument(); | ||
}); |
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.
await waitFor(() => { | |
expect(screen.queryByRole('button', { name: 'Create connector' })).not.toBeInTheDocument(); | |
}); | |
expect(screen.queryByRole('button', { name: 'Create connector' })).not.toBeInTheDocument(); |
I don't think you need the waitFor
in this case.
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.
@adcoelho I had doubts here. I render the component. So should wait until it will be render. Everywhere I used find in the same situation. But here I cannot because if queryBy, so I used waitFor to follow the same logic.
So you do not think I need for render to happened? How does it work?
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.
So should wait until it will be render. Everywhere I used find in the same situation. But here I cannot because if queryBy, so I used waitFor to follow the same logic.
So you do not think I need for render to happened? How does it work?
I am not sure I understand what you are trying to say 😅 but all waitFor
does is run the callback you pass it until it either does not throw
or a timeout happens.
In your test, the condition expect(screen.queryByRole('button', ...)).not.toBeInTheDocument();
will never throw because the button is not there so it is pointless to have the waitFor
.
As a side note, I don't think "waiting for render" as you said applies. The documentation as an example where getBy
is used and no waitFor
is there to "wait for render".
test('renders a message', () => {
const {asFragment, getByText} = render(<Greeting />)
expect(getByText('Hello, world!')).toBeInTheDocument()
It is useful if you have lots of async stuff going on that you need to wait for before something happens but it doesn't mean nothing rendered.
...lic/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx
Show resolved
Hide resolved
7ef21c0
to
f90ba9a
Compare
6c42bd0
to
ce762bd
Compare
Why the last commit adding |
9193e85
to
a077119
Compare
a077119
to
f6deeb3
Compare
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @guskovaue |
Issue: #188189
Here "create connector" button should be moved to the header (top right) for consistency with Rules and Cases page.
How to check:
So it should looks like this on Connectors tab:

And like this (without Create connector button) on tab Logs:

Create connector flyout should open when Create connector button will be pushed.

Also good to check if edit flyout will open when edit a connector.
Checklist