add cypress for search index app (#16104)

This commit is contained in:
Karan Hotchandani 2024-05-02 18:56:06 +05:30 committed by GitHub
parent e2de16bbaa
commit 71293e9fbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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();
@ -118,5 +141,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');
});
});