From 9c2f68934a3ce81e81dd8b03e09b90c91923074f Mon Sep 17 00:00:00 2001 From: Alexi Doak <109488926+doakalexi@users.noreply.github.com> Date: Fri, 30 May 2025 11:25:51 -0700 Subject: [PATCH] [ResponseOps] Fixes failing test: Jest Integration Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests - unrecognized task types should be no workload aggregator errors when there are removed task types (#221854) Resolves https://github.com/elastic/kibana/issues/208459 ## Summary Unskips flaky test that was failing with the error below. This PR updates the test to wait until the task is finished running before checking that the status is marked as `unrecognized`. ``` Error: expect(received).toBe(expected) // Object.is equality Expected: "unrecognized" Received: "idle" at toBe (/opt/buildkite-agent/ ``` (cherry picked from commit bc22fe09b4ac47b42f4d4e9522698569556260f8) --- .../server/integration_tests/removed_types.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x-pack/platform/plugins/shared/task_manager/server/integration_tests/removed_types.test.ts b/x-pack/platform/plugins/shared/task_manager/server/integration_tests/removed_types.test.ts index 6601449a379f1..2edd4ee48c2a3 100644 --- a/x-pack/platform/plugins/shared/task_manager/server/integration_tests/removed_types.test.ts +++ b/x-pack/platform/plugins/shared/task_manager/server/integration_tests/removed_types.test.ts @@ -126,6 +126,15 @@ describe('unrecognized task types', () => { } }); + // wait until the task finishes + await retry(async () => { + const hasRun = await taskManagerPlugin + .get('mark_removed_tasks_as_unrecognized') + .then((t) => t.runAt != null) + .catch(() => false); + expect(hasRun).toBe(true); + }); + await retry(async () => { const task = await getTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser); expect(task?._source?.task?.status).toBe('unrecognized');