Skip to content

Commit

Permalink
add cypress for search index app (#16104)
Browse files Browse the repository at this point in the history
(cherry picked from commit 71293e9)
  • Loading branch information
karanh37 committed May 3, 2024
1 parent 31b949c commit a8fe40c
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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');
});
});

0 comments on commit a8fe40c

Please sign in to comment.