From a8fe40c3cc2fa778a14f7fc8a3e58b73c623a01e Mon Sep 17 00:00:00 2001 From: Karan Hotchandani <33024356+karanh37@users.noreply.github.com> Date: Thu, 2 May 2024 18:56:06 +0530 Subject: [PATCH] add cypress for search index app (#16104) (cherry picked from commit 71293e9fbdce7c417e146380f57e373371fc065a) --- .../e2e/Pages/SearchIndexApplication.spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) 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 3a4c16e0fa23..192a2a318416 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 @@ -25,6 +25,19 @@ const visitSearchApplicationPage = () => { verifyResponseStatusCode('@getSearchIndexingApplication', 200); }; +const verifyLastExecutionRun = (interceptedUrlLabel: string) => { + cy.wait(`@${interceptedUrlLabel}`).then((interception) => { + expect(interception.response.statusCode).to.eq(200); + + // Validate the last execution run response + const responseData = interception.response.body; + if (responseData.data.length > 0) { + expect(responseData.data).to.have.length(1); + expect(responseData.data[0].status).to.equal('success'); + } + }); +}; + describe('Search Index Application', { tags: 'Settings' }, () => { beforeEach(() => { cy.login(); @@ -36,6 +49,16 @@ describe('Search Index Application', { tags: 'Settings' }, () => { verifyResponseStatusCode('@getApplications', 200); }); + it('Verify last execution run', () => { + interceptURL( + 'GET', + '/api/v1/apps/name/SearchIndexingApplication/status?offset=0&limit=1', + 'lastExecutionRun' + ); + visitSearchApplicationPage(); + verifyLastExecutionRun('lastExecutionRun'); + }); + it('Edit application', () => { interceptURL('PATCH', '/api/v1/apps/*', 'updateApplication'); visitSearchApplicationPage(); @@ -114,5 +137,16 @@ describe('Search Index Application', { tags: 'Settings' }, () => { 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 + + interceptURL( + 'GET', + '/api/v1/apps/name/SearchIndexingApplication/status?offset=0&limit=1', + 'lastExecutionRun' + ); + + cy.reload(); + verifyLastExecutionRun('lastExecutionRun'); }); });