Skip to content

Commit

Permalink
[8.x] [ResponseOps][Cases] `SyncAlertsToggle` flaky test (#…
Browse files Browse the repository at this point in the history
…201534) (#201574)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases] `SyncAlertsToggle` flaky test
(#201534)](#201534)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Antonio","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T12:38:32Z","message":"[ResponseOps][Cases]
`SyncAlertsToggle` flaky test (#201534)\n\n## Summary\r\n\r\nThe test
failed again after the last fix. I added `within` to try and\r\nimprove
the time of the dom traversals in the failing
test.","sha":"e4d32fd5271ec46d6ba2b9fd9f6bf3c226884c6b","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["technical
debt","release_note:skip","Team:ResponseOps","v9.0.0","Feature:Cases","backport:prev-minor"],"title":"[ResponseOps][Cases]
`SyncAlertsToggle` flaky
test","number":201534,"url":"https://github.com/elastic/kibana/pull/201534","mergeCommit":{"message":"[ResponseOps][Cases]
`SyncAlertsToggle` flaky test (#201534)\n\n## Summary\r\n\r\nThe test
failed again after the last fix. I added `within` to try and\r\nimprove
the time of the dom traversals in the failing
test.","sha":"e4d32fd5271ec46d6ba2b9fd9f6bf3c226884c6b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201534","number":201534,"mergeCommit":{"message":"[ResponseOps][Cases]
`SyncAlertsToggle` flaky test (#201534)\n\n## Summary\r\n\r\nThe test
failed again after the last fix. I added `within` to try and\r\nimprove
the time of the dom traversals in the failing
test.","sha":"e4d32fd5271ec46d6ba2b9fd9f6bf3c226884c6b"}}]}] BACKPORT-->

Co-authored-by: Antonio <[email protected]>
  • Loading branch information
kibanamachine and adcoelho authored Nov 25, 2024
1 parent d152212 commit f002825
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ describe('SyncAlertsToggle', () => {
</FormTestComponent>
);

expect(await screen.findByTestId('caseSyncAlerts')).toBeInTheDocument();
expect(await screen.findByRole('switch')).toHaveAttribute('aria-checked', 'true');
expect(await screen.findByText('On')).toBeInTheDocument();
const syncAlerts = await screen.findByTestId('caseSyncAlerts');
expect(syncAlerts).toBeInTheDocument();
expect(within(syncAlerts).getByRole('switch')).toHaveAttribute('aria-checked', 'true');
expect(within(syncAlerts).getByText('On')).toBeInTheDocument();
});

it('it toggles the switch', async () => {
Expand All @@ -45,9 +46,9 @@ describe('SyncAlertsToggle', () => {
</FormTestComponent>
);

const synAlerts = await screen.findByTestId('caseSyncAlerts');
const syncAlerts = await screen.findByTestId('caseSyncAlerts');

await userEvent.click(within(synAlerts).getByRole('switch'));
await userEvent.click(within(syncAlerts).getByRole('switch'));

expect(await screen.findByRole('switch')).toHaveAttribute('aria-checked', 'false');
expect(await screen.findByText('Off')).toBeInTheDocument();
Expand All @@ -60,9 +61,9 @@ describe('SyncAlertsToggle', () => {
</FormTestComponent>
);

const synAlerts = await screen.findByTestId('caseSyncAlerts');
const syncAlerts = await screen.findByTestId('caseSyncAlerts');

await userEvent.click(within(synAlerts).getByRole('switch'));
await userEvent.click(within(syncAlerts).getByRole('switch'));

await userEvent.click(await screen.findByText('Submit'));

Expand Down

0 comments on commit f002825

Please sign in to comment.