From f0028258c5158c3d5d9b6106394c523470e4a12d Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 26 Nov 2024 01:27:59 +1100 Subject: [PATCH] [8.x] [ResponseOps][Cases] `SyncAlertsToggle` flaky test (#201534) (#201574) # Backport This will backport the following commits from `main` to `8.x`: - [[ResponseOps][Cases] `SyncAlertsToggle` flaky test (#201534)](https://github.com/elastic/kibana/pull/201534) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Antonio --- .../case_form_fields/sync_alerts_toggle.test.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx b/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx index fbe7eca218391..238abfefeb474 100644 --- a/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx +++ b/x-pack/plugins/cases/public/components/case_form_fields/sync_alerts_toggle.test.tsx @@ -33,9 +33,10 @@ describe('SyncAlertsToggle', () => { ); - 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 () => { @@ -45,9 +46,9 @@ describe('SyncAlertsToggle', () => { ); - 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(); @@ -60,9 +61,9 @@ describe('SyncAlertsToggle', () => { ); - 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'));