From 46e14b79f492fdae5aec133d5c09d0bd46953fd9 Mon Sep 17 00:00:00 2001 From: Karan Hotchandani <33024356+karanh37@users.noreply.github.com> Date: Thu, 16 May 2024 18:19:54 +0530 Subject: [PATCH] fix glossary term selection (#16303) * fix glossary term selection * fix flaky tags cypress --- .../ui/cypress/common/Utils/Glossary.ts | 4 +- .../resources/ui/cypress/common/Utils/Tags.ts | 3 +- .../e2e/Pages/SearchIndexApplication.spec.ts | 54 ++++++++++--------- .../AsyncSelectList/TreeAsyncSelectList.tsx | 6 +++ 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Glossary.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Glossary.ts index 2641cbc2b6e..0f5b13501bb 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Glossary.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Glossary.ts @@ -95,13 +95,13 @@ export const removeGlossaryTerm = ( '[data-testid="entity-right-panel"] [data-testid="glossary-container"] [data-testid="edit-button"]' ).click(); + verifyResponseStatusCode('@fetchGlossaries', 200); + // Remove all added tags cy.get( `[data-testid="selected-tag-${glossaryTerm}"] [data-testid="remove-tags"]` ).click(); - verifyResponseStatusCode('@fetchGlossaries', 200); - cy.get('[data-testid="saveAssociatedTag"]').click(); verifyResponseStatusCode('@removeTags', 200, { requestTimeout: 15000, diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Tags.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Tags.ts index cfedbb16d93..67c2b347c1f 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Tags.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Tags.ts @@ -93,11 +93,12 @@ export const removeTags = ( .scrollIntoView() .click(); + verifyResponseStatusCode('@searchTags', 200); + // Remove all added tags cy.get( `[data-testid="selected-tag-${tag}"] [data-testid="remove-tags"]` ).click(); - verifyResponseStatusCode('@searchTags', 200); cy.get('[data-testid="saveAssociatedTag"]').click(); verifyResponseStatusCode('@removeTags', 200, { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts index 36fc4393b20..01b62e44d43 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts @@ -124,33 +124,35 @@ describe('Search Index Application', { tags: 'Settings' }, () => { ); }); - it('Run application', () => { - interceptURL( - 'GET', - '/api/v1/apps/name/SearchIndexingApplication?fields=*', - 'getSearchIndexingApplication' - ); - interceptURL( - 'POST', - '/api/v1/apps/trigger/SearchIndexingApplication', - 'triggerPipeline' - ); - cy.get( - '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' - ).click(); - verifyResponseStatusCode('@getSearchIndexingApplication', 200); - cy.get('[data-testid="run-now-button"]').click(); - verifyResponseStatusCode('@triggerPipeline', 200); + if (Cypress.env('isOss')) { + it('Run application', () => { + interceptURL( + 'GET', + '/api/v1/apps/name/SearchIndexingApplication?fields=*', + 'getSearchIndexingApplication' + ); + interceptURL( + 'POST', + '/api/v1/apps/trigger/SearchIndexingApplication', + 'triggerPipeline' + ); + cy.get( + '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' + ).click(); + verifyResponseStatusCode('@getSearchIndexingApplication', 200); + cy.get('[data-testid="run-now-button"]').click(); + verifyResponseStatusCode('@triggerPipeline', 200); - cy.wait(120000); // waiting for 2 minutes before we check if reindex was success + cy.wait(120000); // waiting for 2 minutes before we check if reindex was success - interceptURL( - 'GET', - '/api/v1/apps/name/SearchIndexingApplication/status?offset=0&limit=1', - 'lastExecutionRun' - ); + interceptURL( + 'GET', + '/api/v1/apps/name/SearchIndexingApplication/status?offset=0&limit=1', + 'lastExecutionRun' + ); - cy.reload(); - verifyLastExecutionRun('lastExecutionRun'); - }); + cy.reload(); + verifyLastExecutionRun('lastExecutionRun'); + }); + } }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx index 24d6d4eace5..c6fb6ff5f84 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx @@ -183,7 +183,13 @@ const TreeAsyncSelectList: FC> = ({ value: string; }[] ) => { + const lastSelectedMap = new Map( + selectedTagsRef.current.map((tag) => [tag.value, tag]) + ); const selectedValues = values.map(({ value }) => { + if (lastSelectedMap.has(value)) { + return lastSelectedMap.get(value) as SelectOption; + } const initialData = findGlossaryTermByFqn( [ ...glossaries,