Skip to content

Commit ab60398

Browse files
Fixes mds cypress test
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent a251535 commit ab60398

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const createDataSource = () => {
2525
title: Cypress.env('externalDataSourceLabel'),
2626
endpoint: Cypress.env('externalDataSourceEndpoint'),
2727
installedPlugins: ['opensearch-security'],
28-
dataSourceVersion: '2.15.0',
28+
dataSourceVersion: '3.4.0',
2929
auth: {
3030
type: 'username_password',
3131
credentials: {
@@ -232,7 +232,9 @@ describe('Multi-datasources enabled', () => {
232232
});
233233

234234
it('Checks Resource Access Management with external data source', () => {
235-
// Visit resource access management with external data source
235+
// Set up intercept BEFORE visiting the page since the API call happens on page load
236+
cy.intercept('GET', '/api/resource/types*').as('getResourceTypes');
237+
236238
cy.visit(`http://localhost:5601/app/resource_access_management${externalDataSourceUrl}`);
237239

238240
// Verify page title
@@ -247,49 +249,35 @@ describe('Multi-datasources enabled', () => {
247249
// Verify the resource type selector is present
248250
cy.contains('h3', 'Resources').should('be.visible');
249251

250-
// Intercept API calls to verify dataSourceId is passed
251-
cy.intercept('GET', '/api/resource/types*', (req) => {
252-
// Verify dataSourceId query parameter is included
253-
expect(req.url).to.include(`dataSourceId=${externalDataSourceId}`);
252+
// Wait for the API call and verify dataSourceId is passed
253+
cy.wait('@getResourceTypes', { timeout: 10_000 }).then((interception) => {
254+
expect(interception.request.url).to.include(`dataSourceId=${externalDataSourceId}`);
254255
cy.log(`API call includes correct dataSourceId: ${externalDataSourceId}`);
255-
}).as('getResourceTypes');
256-
257-
// Trigger API call by clicking the resource type selector
258-
cy.get('button.euiSuperSelectControl').click();
259-
260-
// Wait for the API call to complete
261-
cy.wait('@getResourceTypes', { timeout: 10_000 });
256+
});
262257
});
263258

264259
it('Checks Resource Access Management with local cluster', () => {
265-
// Visit resource access management with local cluster
260+
// Set up intercept BEFORE visiting the page since the API call happens on page load
261+
cy.intercept('GET', '/api/resource/types*').as('getResourceTypesLocal');
262+
266263
cy.visit(`http://localhost:5601/app/resource_access_management${localDataSourceUrl}`);
267264

268265
// Verify page title
269266
cy.contains('h1', 'Resource Access Management', { timeout: 20_000 }).should('be.visible');
270267

271268
// Verify data source picker shows local cluster
272-
cy.get('[data-test-subj="dataSourceViewButton"]', { timeout: 10_000 }).should(
269+
cy.get('[data-test-subj="dataSourceSelectableButton"]', { timeout: 10_000 }).should(
273270
'contain',
274271
'Local cluster'
275272
);
276273

277274
// Verify the resource type selector is present
278275
cy.contains('h3', 'Resources').should('be.visible');
279276

280-
// Intercept API calls to verify dataSourceId is NOT passed for local cluster
281-
cy.intercept('GET', '/api/resource/types*', (req) => {
282-
// For local cluster, dataSourceId should not be in the URL or should be empty
283-
if (req.url.includes('dataSourceId=')) {
284-
expect(req.url).to.include('dataSourceId=');
285-
}
277+
// Wait for the API call - for local cluster, dataSourceId may or may not be present
278+
cy.wait('@getResourceTypesLocal', { timeout: 10_000 }).then((interception) => {
286279
cy.log('API call for local cluster completed');
287-
}).as('getResourceTypesLocal');
288-
289-
// Trigger API call by clicking the resource type selector
290-
cy.get('button.euiSuperSelectControl').click();
291-
292-
// Wait for the API call to complete
293-
cy.wait('@getResourceTypesLocal', { timeout: 10_000 });
280+
cy.log(`Request URL: ${interception.request.url}`);
281+
});
294282
});
295283
});

0 commit comments

Comments
 (0)