diff --git a/public/apps/configuration/panels/permission-list/permission-list.tsx b/public/apps/configuration/panels/permission-list/permission-list.tsx index 8931ff5c7..ec90dd7d5 100644 --- a/public/apps/configuration/panels/permission-list/permission-list.tsx +++ b/public/apps/configuration/panels/permission-list/permission-list.tsx @@ -87,7 +87,7 @@ export function toggleRowDetails( }); } -export function renderRowExpanstionArrow( +export function renderRowExpansionArrow( itemIdToExpandedRowMap: ExpandedRowMapInterface, actionGroupDict: DataObject, setItemIdToExpandedRowMap: Dispatch> @@ -139,7 +139,7 @@ function getColumns( align: RIGHT_ALIGNMENT, width: '40px', isExpander: true, - render: renderRowExpanstionArrow( + render: renderRowExpansionArrow( itemIdToExpandedRowMap, actionGroupDict, setItemIdToExpandedRowMap @@ -323,7 +323,11 @@ export function PermissionList(props: AppDependencies) { }; const createActionGroupMenuItems = [ - showEditModal('', Action.create, [])}> + showEditModal('', Action.create, [])} + > Create from blank , { describe('renderRowExpanstionArrow', () => { it('should render down arrow when collapsed', () => { - const renderFunc = renderRowExpanstionArrow({}, {}, jest.fn()); + const renderFunc = renderRowExpansionArrow({}, {}, jest.fn()); const Wrapper = () => <>{renderFunc(sampleActionGroup)}; const component = shallow(); @@ -86,7 +86,7 @@ describe('Permission list page ', () => { }); it('should render up arrow when expanded', () => { - const renderFunc = renderRowExpanstionArrow( + const renderFunc = renderRowExpansionArrow( { [sampleActionGroup.name]: sampleActionGroup }, {}, jest.fn() diff --git a/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js b/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js index 699b74b60..261a879b7 100644 --- a/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js +++ b/test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js @@ -22,8 +22,8 @@ const createDataSource = () => { }, body: { attributes: { - title: `9202`, - endpoint: `https://localhost:9202`, + title: '9202', + endpoint: 'https://localhost:9202', auth: { type: 'username_password', credentials: { @@ -36,28 +36,27 @@ const createDataSource = () => { }); }; -const deleteAllDataSources = () => { - cy.request( - 'GET', - `${Cypress.config( - 'baseUrl' - )}/api/saved_objects/_find?fields=id&fields=description&fields=title&per_page=10000&type=data-source` - ).then((resp) => { - if (resp && resp.body && resp.body.saved_objects) { - resp.body.saved_objects.map(({ id }) => { - cy.request({ - method: 'DELETE', - url: `${Cypress.config('baseUrl')}/api/saved_objects/data-source/${id}`, - body: { force: false }, - headers: { - 'osd-xsrf': true, - }, - }); - }); +const closeToast = () => { + // remove browser incompatibiltiy toast causing flakyness (cause it has higher z-index than Create button making it invisible) + cy.get('body').then((body) => { + if (body.find('[data-test-subj="toastCloseButton"]').length > 0) { + cy.get('[data-test-subj="toastCloseButton"]').click(); } }); }; +const deleteAllDataSources = () => { + cy.visit('http://localhost:5601/app/management/opensearch-dashboards/dataSources'); + + closeToast(); + + cy.get('[data-test-subj="checkboxSelectAll"]').should('exist'); + cy.get('[data-test-subj="checkboxSelectAll"]').click(); + cy.get('[data-test-subj="checkboxSelectAll"]').should('be.checked'); + cy.get('[data-test-subj="deleteDataSourceConnections"]').click(); + cy.get('[data-test-subj="confirmModalConfirmButton"]').click(); +}; + describe('Multi-datasources enabled', () => { before(() => { localStorage.setItem('opendistro::security::tenant::saved', '""'); @@ -77,7 +76,7 @@ describe('Multi-datasources enabled', () => { cy.get('.euiToastHeader__title').should('contain', 'successful for Local cluster'); // Remote cluster purge cache cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', '9202').click(); + cy.get('[title="9202"]').click(); cy.get('[data-test-subj="purge-cache"]').click(); cy.get('.euiToastHeader__title').should('contain', 'successful for 9202'); cy.visit('http://localhost:5601/app/security-dashboards-plugin#/auth'); @@ -91,21 +90,23 @@ describe('Multi-datasources enabled', () => { cy.get('.panel-header-count').first().invoke('text').should('contain', '(6)'); // Remote cluster auth cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', '9202').click(); + cy.get('[title="9202"]').click(); cy.get('.panel-header-count').first().invoke('text').should('contain', '(2)'); - cy.visit('http://localhost:5601/app/security-dashboards-plugin#/users'); - // Data source persisted across tabs - cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').contains('9202'); }); - it.skip('Checks Users Tab', () => { + it('Checks Users Tab', () => { cy.visit('http://localhost:5601/app/security-dashboards-plugin#/users'); // Create an internal user in the remote cluster cy.contains('h3', 'Internal users'); cy.contains('a', 'admin'); - // TODO replace these with navigating to urls that get read to determine datasource, since these are flaky + + closeToast(); + + // select remote data source cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', '9202').click(); + cy.get('[title="9202"]').click(); + + // create a user on remote data source cy.get('[data-test-subj="create-user"]').click(); cy.get('[data-test-subj="name-text"]').focus().type('9202-user'); cy.get('[data-test-subj="password"]').focus().type('myStrongPassword123!'); @@ -113,14 +114,19 @@ describe('Multi-datasources enabled', () => { cy.get('[data-test-subj="submit-save-user"]').click(); // Internal user exists on the remote - cy.visit('http://localhost:5601/app/security-dashboards-plugin#/users'); - cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', '9202').click(); + cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').should( + 'contain', + '9202' + ); cy.get('[data-test-subj="checkboxSelectRow-9202-user"]').should('exist'); // Internal user doesn't exist on local cluster cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', 'Local cluster').click(); + cy.get('[title="Local cluster"]').click(); + cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').should( + 'contain', + 'Local cluster' + ); cy.get('[data-test-subj="checkboxSelectRow-9202-user"]').should('not.exist'); }); @@ -128,26 +134,39 @@ describe('Multi-datasources enabled', () => { cy.visit('http://localhost:5601/app/security-dashboards-plugin#/permissions'); // Create a permission in the remote cluster cy.contains('h3', 'Permissions'); - // Select 9202 cluster + + closeToast(); + + // Select remote cluster cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', '9202').click(); + cy.get('[title="9202"]').click(); + cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').should( + 'contain', + '9202' + ); // Create an action group cy.get('[id="Create action group"]').click(); - cy.contains('li.euiFlexItem', 'Create from blank').click(); - cy.get('[data-test-subj="name-text"]').focus().type('test-permission-ag'); + cy.contains('div.euiFlexItem > button', 'Create from blank').click(); + cy.get('[data-test-subj="name-text"]') + .focus() + .type('test_permission_ag', { force: true }) + .should('have.value', 'test_permission_ag'); cy.get('[data-test-subj="comboBoxInput"]').focus().type('some_permission'); cy.get('[id="submit"]').click(); // Permission exists on the remote data source - cy.visit('http://localhost:5601/app/security-dashboards-plugin#/permissions'); - cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', '9202').click(); - cy.get('[data-test-subj="checkboxSelectRow-test-permission-ag"]').should('exist'); + cy.get('[data-text="Customization"]').click(); + cy.contains('div.euiFilterSelect__items > button', 'Custom').click(); + cy.get('[data-test-subj="checkboxSelectRow-test_permission_ag"]').should('exist'); // Permission doesn't exist on local cluster cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').click(); - cy.contains('li.euiSelectableListItem', 'Local cluster').click(); - cy.get('[data-test-subj="checkboxSelectRow-test-permission-ag"]').should('not.exist'); + cy.get('[title="Local cluster"]').click(); + cy.get('[data-test-subj="dataSourceSelectableContextMenuHeaderLink"]').should( + 'contain', + 'Local cluster' + ); + cy.get('[data-test-subj="checkboxSelectRow-test_permission_ag"]').should('not.exist'); }); });