diff --git a/.github/workflows/cypress-test-multidatasources-enabled-e2e.yml b/.github/workflows/cypress-test-multidatasources-enabled-e2e.yml index 49bdf761a..fbb413dcc 100644 --- a/.github/workflows/cypress-test-multidatasources-enabled-e2e.yml +++ b/.github/workflows/cypress-test-multidatasources-enabled-e2e.yml @@ -123,4 +123,4 @@ jobs: uses: ./.github/actions/run-cypress-tests with: dashboards_config_file: opensearch_dashboards_multidatasources.yml - yarn_command: 'yarn cypress:run --browser chrome --headless --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"' + yarn_command: 'yarn cypress:run --browser electron --headless --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/multi-datasources/multi_datasources_enabled.spec.js"' diff --git a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx index e52cb9128..a8a4284b6 100644 --- a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx @@ -23,7 +23,7 @@ import { EuiSuperSelect, EuiTextArea, } from '@elastic/eui'; -import React, { Dispatch, Fragment, SetStateAction } from 'react'; +import React, { Dispatch, Fragment, SetStateAction, useEffect } from 'react'; import { isEmpty } from 'lodash'; import { RoleIndexPermission } from '../../types'; import { ResourceType } from '../../../../../common'; @@ -320,9 +320,11 @@ export function IndexPermissionPanel(props: { }) { const { state, optionUniverse, setState } = props; // Show one empty row if there is no data. - if (isEmpty(state)) { - setState([getEmptyIndexPermission()]); - } + useEffect(() => { + if (isEmpty(state)) { + setState([getEmptyIndexPermission()]); + } + }, [state, setState]); return ( { + if (isEmpty(state)) { + setState([getEmptyTenantPermission()]); + } + }, [state, setState]); return ( { const state: RoleIndexPermissionStateClass[] = []; const optionUniverse: ComboBoxOptions = []; - shallow(); + render(); expect(setState).toHaveBeenCalledTimes(1); }); diff --git a/public/apps/configuration/panels/role-edit/test/tenant-panel.test.tsx b/public/apps/configuration/panels/role-edit/test/tenant-panel.test.tsx index 6fd5adcdc..d7ad8f36c 100644 --- a/public/apps/configuration/panels/role-edit/test/tenant-panel.test.tsx +++ b/public/apps/configuration/panels/role-edit/test/tenant-panel.test.tsx @@ -24,6 +24,7 @@ import { import { shallow } from 'enzyme'; import React from 'react'; import { EuiComboBox, EuiButton, EuiSuperSelect } from '@elastic/eui'; +import { render } from '@testing-library/react'; jest.mock('../../../utils/array-state-utils'); // eslint-disable-next-line @@ -76,7 +77,7 @@ describe('Role edit - tenant panel', () => { const setState = jest.fn(); it('render an empty row if data is empty', () => { - shallow(); + render(); expect(setState).toHaveBeenCalledWith([ {