From 7d8f89c35cf068777efdcdc5744c2d89048b6ec7 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Thu, 31 Oct 2024 16:33:17 +0100 Subject: [PATCH] [ML] Fix Trained model deletion with expanded row (#198530) ## Summary Fixes #198408. Fixes trained model item deletion with expanded row. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit bd21496b3c0af2167918bd385bd259b05c8e765d) --- .../public/application/model_management/models_list.tsx | 8 ++++++++ .../apps/ml/short_tests/model_management/model_list.ts | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/model_management/models_list.tsx b/x-pack/plugins/ml/public/application/model_management/models_list.tsx index 9dbdf6069aff6..a717995d4ee14 100644 --- a/x-pack/plugins/ml/public/application/model_management/models_list.tsx +++ b/x-pack/plugins/ml/public/application/model_management/models_list.tsx @@ -957,6 +957,14 @@ export const ModelsList: FC = ({ } }); + setItemIdToExpandedRowMap((prev) => { + const newMap = { ...prev }; + modelsToDelete.forEach((model) => { + delete newMap[model.model_id]; + }); + return newMap; + }); + setModelsToDelete([]); if (refreshList) { diff --git a/x-pack/test/functional/apps/ml/short_tests/model_management/model_list.ts b/x-pack/test/functional/apps/ml/short_tests/model_management/model_list.ts index c828e8da1f3af..7977f17bf5f65 100644 --- a/x-pack/test/functional/apps/ml/short_tests/model_management/model_list.ts +++ b/x-pack/test/functional/apps/ml/short_tests/model_management/model_list.ts @@ -416,7 +416,8 @@ export default function ({ getService }: FtrProviderContext) { it('displays a model without an ingest pipeline and model can be deleted', async () => { await ml.testExecution.logTestStep('should display the model in the table'); - await ml.trainedModelsTable.filterWithSearchString(modelWithoutPipelineData.modelId, 1); + await ml.testExecution.logTestStep('expands the row to show the model details'); + await ml.trainedModelsTable.ensureRowIsExpanded(modelWithoutPipelineData.modelId); await ml.testExecution.logTestStep( 'displays expected row values for the model in the table'