Skip to content

Commit

Permalink
feat(Inventory table): Add static groups column (#1772)
Browse files Browse the repository at this point in the history
This makes the Inventory table always render the groups column if the feature flag is true.
  • Loading branch information
Fewwy authored Mar 3, 2023
1 parent 884609f commit 94db33f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 258 deletions.
4 changes: 4 additions & 0 deletions src/components/InventoryTable/EntityTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import InsightsDisconnected from '../../Utilities/InsightsDisconnected';
import { defaultColumns } from '../../store/entities';
import { createMemoryHistory } from 'history';

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

describe('EntityTable', () => {
let initialState;
let mockStore;
Expand Down Expand Up @@ -463,6 +465,7 @@ describe('EntityTable', () => {
});

it('should disable just one default column', () => {
jest.mock('../../Utilities/useFeatureFlag');
initialState = {
entities: {
...initialState.entities,
Expand Down Expand Up @@ -530,6 +533,7 @@ describe('EntityTable', () => {
});

describe('API', () => {
jest.mock('../../Utilities/useFeatureFlag');
it('should call default onRowClick', () => {
const history = createMemoryHistory();
const store = mockStore(initialState);
Expand Down
3 changes: 0 additions & 3 deletions src/components/InventoryTable/EntityTableToolbar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ 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');
Expand Down Expand Up @@ -94,7 +93,6 @@ describe('EntityTableToolbar', () => {
});

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

it('should render correctly - no data', () => {
const store = mockStore({
Expand Down Expand Up @@ -393,7 +391,6 @@ describe('EntityTableToolbar', () => {

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
Expand Down
2 changes: 2 additions & 0 deletions src/components/InventoryTable/InventoryList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { createPromise as promiseMiddleware } from 'redux-promise-middleware';
import { MemoryRouter } from 'react-router-dom';
import toJson from 'enzyme-to-json';

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

jest.mock('../../store/actions', () => {
const actions = jest.requireActual('../../store/actions');
const { ACTION_TYPES } = jest.requireActual('../../store/action-types');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,6 @@ exports[`EntityTableToolbar DOM should render correctly - no data 1`] = `
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
],
}
}
Expand Down Expand Up @@ -329,31 +304,6 @@ exports[`EntityTableToolbar DOM should render correctly - with children 1`] = `
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
],
}
}
Expand Down Expand Up @@ -548,31 +498,6 @@ exports[`EntityTableToolbar DOM should render correctly - with custom activeFilt
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
Object {
"filterValues": Object {
"className": "ins-c-tagfilter",
Expand Down Expand Up @@ -785,31 +710,6 @@ exports[`EntityTableToolbar DOM should render correctly - with custom filters 1`
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
Object {
"filterValues": Object {
"isDisabled": false,
Expand Down Expand Up @@ -1012,31 +912,6 @@ exports[`EntityTableToolbar DOM should render correctly - with customFilters 1`]
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
Object {
"filterValues": Object {
"className": "ins-c-tagfilter",
Expand Down Expand Up @@ -1262,31 +1137,6 @@ exports[`EntityTableToolbar DOM should render correctly - with default filters 1
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
],
}
}
Expand Down Expand Up @@ -1469,31 +1319,6 @@ exports[`EntityTableToolbar DOM should render correctly - with default tag filte
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
],
}
}
Expand Down Expand Up @@ -1692,31 +1517,6 @@ exports[`EntityTableToolbar DOM should render correctly - with no access 1`] = `
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": true,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
],
}
}
Expand Down Expand Up @@ -1907,31 +1707,6 @@ exports[`EntityTableToolbar DOM should render correctly - with tags 1`] = `
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
Object {
"filterValues": Object {
"className": "ins-c-tagfilter",
Expand Down Expand Up @@ -2152,31 +1927,6 @@ exports[`EntityTableToolbar DOM should render correctly 1`] = `
"type": "checkbox",
"value": "rhc-status",
},
Object {
"filterValues": Object {
"isDisabled": false,
"items": Array [
Object {
"label": "yum",
"value": "yum",
},
Object {
"label": "dnf",
"value": "dnf",
},
Object {
"label": "rpm-ostree",
"value": "rpm-ostree",
},
],
"onChange": [Function],
"placeholder": "Filter by system update method",
"value": undefined,
},
"label": "System Update Method",
"type": "checkbox",
"value": "update-method",
},
],
}
}
Expand Down
Loading

0 comments on commit 94db33f

Please sign in to comment.