Skip to content

Commit

Permalink
fix flaky test and unskip
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed Feb 28, 2023
1 parent a9bcdaf commit 794ce9a
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type { AppContextTestRender } from '../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../common/mock/endpoint';
import { useUserPrivileges } from '../../../common/components/user_privileges';
import { endpointPageHttpMock } from '../endpoint_hosts/mocks';
import { ExperimentalFeaturesService } from '../../../common/experimental_features_service';
import { allowedExperimentalValues } from '../../../../common/experimental_features';

jest.mock('../../../common/components/user_privileges');

Expand All @@ -22,6 +24,12 @@ describe('when in the Administration tab', () => {
let render: () => ReturnType<AppContextTestRender['render']>;
const mockedContext = createAppRootMockRenderer();

beforeAll(() => {
ExperimentalFeaturesService.init({
experimentalFeatures: { ...allowedExperimentalValues },
});
});

beforeEach(() => {
endpointPageHttpMock(mockedContext.coreStart.http);
render = () => mockedContext.render(<ManagementContainer />);
Expand All @@ -33,6 +41,13 @@ describe('when in the Administration tab', () => {
});

describe('when the user has no permissions', () => {
// remove this beforeAll hook when feature flag is removed
beforeAll(() => {
ExperimentalFeaturesService.init({
experimentalFeatures: { ...allowedExperimentalValues, endpointRbacEnabled: true },
});
});

it('should display `no permission` if no `canAccessEndpointManagement`', async () => {
useUserPrivilegesMock.mockReturnValue({
endpointPrivileges: { loading: false, canAccessEndpointManagement: false },
Expand Down Expand Up @@ -96,8 +111,14 @@ describe('when in the Administration tab', () => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/145204
describe.skip('when the user has permissions', () => {
describe('when the user has permissions', () => {
// remove this beforeAll hook when feature flag is removed
beforeAll(() => {
ExperimentalFeaturesService.init({
experimentalFeatures: { ...allowedExperimentalValues, endpointRbacEnabled: true },
});
});

it('should display the Management view if user has privileges', async () => {
useUserPrivilegesMock.mockReturnValue({
endpointPrivileges: { loading: false, canReadEndpointList: true, canAccessFleet: true },
Expand Down

0 comments on commit 794ce9a

Please sign in to comment.