Skip to content

Commit 98ec499

Browse files
authored
Add minimal Cypress tests for integrations (#990)
* Add tests for integrations Signed-off-by: Simeon Widdis <[email protected]> * Add check for test instance page opening Signed-off-by: Simeon Widdis <[email protected]> * Empty commit to re-trigger run Signed-off-by: Simeon Widdis <[email protected]> * Decouple integrations add and search tests Signed-off-by: Simeon Widdis <[email protected]> * Move instance name constant to test Signed-off-by: Simeon Widdis <[email protected]> * Add integrations teardown process Signed-off-by: Simeon Widdis <[email protected]> --------- Signed-off-by: Simeon Widdis <[email protected]>
1 parent 32cba83 commit 98ec499

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/// <reference types="cypress" />
7+
8+
import { BASE_PATH } from '../../../utils/base_constants';
9+
10+
const moveToAvailableNginxIntegration = () => {
11+
cy.visit(`${BASE_PATH}/app/integrations#/available/nginx`);
12+
};
13+
14+
const moveToAddedIntegrations = () => {
15+
cy.visit(`${BASE_PATH}/app/integrations#/installed`);
16+
};
17+
18+
const createSamples = () => {
19+
moveToAvailableNginxIntegration();
20+
cy.get('[data-test-subj="try-it-button"]').click();
21+
cy.get('.euiToastHeader__title').should('contain', 'successfully');
22+
};
23+
24+
const integrationsTeardown = () => {
25+
// Delete all integration instances
26+
cy.request({
27+
method: 'GET',
28+
form: false,
29+
url: `api/integrations/store`,
30+
headers: {
31+
'content-type': 'application/json;charset=UTF-8',
32+
'osd-xsrf': true,
33+
},
34+
}).then((response) => {
35+
for (const instance of response.body.data.hits) {
36+
cy.request({
37+
method: 'DELETE',
38+
url: `/api/integrations/store/${instance.id}`,
39+
headers: {
40+
'content-type': 'application/json;charset=UTF-8',
41+
'osd-xsrf': true,
42+
},
43+
});
44+
}
45+
});
46+
// Also clean up indices
47+
cy.request({
48+
method: 'POST',
49+
form: false,
50+
url: 'api/console/proxy',
51+
headers: {
52+
'content-type': 'application/json;charset=UTF-8',
53+
'osd-xsrf': true,
54+
},
55+
qs: {
56+
path: `ss4o_logs-nginx-*`, // All tests work with ss4o nginx data
57+
method: 'DELETE',
58+
},
59+
body: '{}',
60+
});
61+
};
62+
63+
describe('Add nginx integration instance flow', () => {
64+
beforeEach(() => {
65+
createSamples();
66+
});
67+
68+
afterEach(() => {
69+
integrationsTeardown();
70+
});
71+
72+
it('Navigates to nginx page and triggers the adds the instance flow', () => {
73+
const testInstanceName = 'test_integration_cypress';
74+
moveToAvailableNginxIntegration();
75+
cy.get('[data-test-subj="add-integration-button"]').click();
76+
cy.get('[data-test-subj="new-instance-name"]').should(
77+
'have.value',
78+
'nginx Integration'
79+
);
80+
cy.get('[data-test-subj="create-instance-button"]').should('be.disabled');
81+
// Modifies the name of the integration
82+
cy.get('[data-test-subj="new-instance-name"]').clear();
83+
cy.get('[data-test-subj="new-instance-name"]').type(testInstanceName);
84+
// Validates the created sample index
85+
cy.get('[data-test-subj="data-source-name"]').type(
86+
'ss4o_logs-nginx-sample-sample{enter}'
87+
);
88+
cy.get('[data-test-subj="create-instance-button"]').click();
89+
cy.get('[data-test-subj="eventHomePageTitle"]').should(
90+
'contain',
91+
testInstanceName
92+
);
93+
});
94+
95+
it('Navigates to installed integrations page and verifies that installed integration exists', () => {
96+
const sampleName = 'nginx-sample';
97+
moveToAddedIntegrations();
98+
cy.contains(sampleName).should('exist');
99+
cy.get('input[type="search"]').eq(0).focus();
100+
cy.get('input[type="search"]').eq(0).type(`${sampleName}{enter}`);
101+
cy.get('.euiTableRow').should('have.length', 1); //Filters correctly to the test integration instance
102+
cy.get(`[data-test-subj="${sampleName}IntegrationLink"]`).click();
103+
cy.get('[data-test-subj="eventHomePageTitle"]').should(
104+
'contain',
105+
sampleName
106+
);
107+
});
108+
});

0 commit comments

Comments
 (0)