Skip to content

Commit

Permalink
chore(RHIF-169): hide system update method filter untill API is ready (
Browse files Browse the repository at this point in the history
  • Loading branch information
mkholjuraev authored Feb 14, 2023
1 parent 9c8e3a0 commit d360856
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/InventoryTable/EntityTableToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
updateMethodFilterState
} from '../filters';
import useOperatingSystemFilter from '../filters/useOperatingSystemFilter';
import useFeatureFlag from '../../Utilities/useFeatureFlag';

/**
* Table toolbar used at top of inventory table.
Expand Down Expand Up @@ -100,6 +101,8 @@ const EntityTableToolbar = ({
const [osFilterConfig, osFilterChips, osFilterValue, setOsFilterValue] = useOperatingSystemFilter();
const [updateMethodConfig, updateMethodChips, updateMethodValue, setUpdateMethodValue] = useUpdateMethodFilter(reducer);

const isUpdateMethodEnabled = useFeatureFlag('hbi.ui.system-update-method');

const {
tagsFilter,
tagsChip,
Expand Down Expand Up @@ -127,7 +130,10 @@ const EntityTableToolbar = ({
operatingSystem: !(hideFilters.all && hideFilters.operatingSystem !== false) && !hideFilters.operatingSystem,
tags: !(hideFilters.all && hideFilters.tags !== false) && !hideFilters.tags,
rhcdFilter: !(hideFilters.all && hideFilters.rhcdFilter !== false) && !hideFilters.rhcdFilter,
updateMethodFilter: !(hideFilters.all && hideFilters.updateMethodFilter !== false) && !hideFilters.updateMethodFilter
//hides the filter untill API is ready. JIRA: RHIF-169
updateMethodFilter: isUpdateMethodEnabled &&
!(hideFilters.all && hideFilters.updateMethodFilter !== false)
&& !hideFilters.updateMethodFilter
};

/**
Expand Down
16 changes: 16 additions & 0 deletions src/components/InventoryTable/EntityTableToolbar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import toJson from 'enzyme-to-json';
import { mockTags, mockSystemProfile } from '../../__mocks__/hostApi';
import TitleColumn from './TitleColumn';
import debounce from 'lodash/debounce';
import useFeatureFlag from '../../Utilities/useFeatureFlag';

jest.mock('lodash/debounce');
jest.mock('../../Utilities/useFeatureFlag');

describe('EntityTableToolbar', () => {
let initialState;
Expand Down Expand Up @@ -92,6 +94,8 @@ describe('EntityTableToolbar', () => {
});

describe('DOM', () => {
useFeatureFlag.mockReturnValue(true);

it('should render correctly - no data', () => {
const store = mockStore({
entities: {
Expand Down Expand Up @@ -386,4 +390,16 @@ describe('EntityTableToolbar', () => {
expect(toJson(wrapper.find('Test Reset Filter'))).toBeFalsy();
});
});

describe('System update method filter', () => {
it('Should hide the filter when flag is disabled', () => {
useFeatureFlag.mockReturnValue(false);
const store = mockStore(initialState);
const wrapper = mount(<Provider store={store}>
<EntityTableToolbar hasItems onRefreshData={onRefreshData} loaded
activeFiltersConfig={{ deleteTitle: 'Test Reset Filters' }} />
</Provider>);
expect(toJson(wrapper.find('System Update Method'))).toBeFalsy();
});
});
});
4 changes: 4 additions & 0 deletions src/components/InventoryTable/InventoryTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import toJson from 'enzyme-to-json';
import { ConditionalFilter } from '@redhat-cloud-services/frontend-components/ConditionalFilter';
import * as loadSystems from '../../Utilities/sharedFunctions';
import { mockSystemProfile } from '../../__mocks__/hostApi';
import useFeatureFlag from '../../Utilities/useFeatureFlag';

jest.mock('../../Utilities/useFeatureFlag');

describe('InventoryTable', () => {
let initialState;
Expand Down Expand Up @@ -208,6 +211,7 @@ describe('InventoryTable', () => {
});

it('should disable only one filter', () => {
useFeatureFlag.mockReturnValue(true);
const store = mockStore(initialState);
const wrapper = mount(<Provider store={ store }>
<Router>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import debounce from 'lodash/debounce';
import { mockSystemProfile } from '../../__mocks__/hostApi';

jest.mock('lodash/debounce');
jest.mock('../../Utilities/useFeatureFlag');

describe('InventoryTable - initial loading', () => {
let initialState;
Expand Down
1 change: 1 addition & 0 deletions src/routes/InventoryTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
on: jest.fn()
})
}));
jest.mock('../Utilities/useFeatureFlag');

describe('InventoryTable', () => {
let mockStore;
Expand Down

0 comments on commit d360856

Please sign in to comment.