diff --git a/awx/ui_next/src/api/models/Hosts.js b/awx/ui_next/src/api/models/Hosts.js index 72ee919dae..f9f5fe5542 100644 --- a/awx/ui_next/src/api/models/Hosts.js +++ b/awx/ui_next/src/api/models/Hosts.js @@ -7,7 +7,7 @@ class Hosts extends Base { this.baseUrl = '/api/v2/hosts/'; this.readFacts = this.readFacts.bind(this); - this.readGroups = this.readGroups.bind(this); + this.readAllGroups = this.readAllGroups.bind(this); this.readGroupsOptions = this.readGroupsOptions.bind(this); this.associateGroup = this.associateGroup.bind(this); this.disassociateGroup = this.disassociateGroup.bind(this); @@ -17,8 +17,8 @@ class Hosts extends Base { return this.http.get(`${this.baseUrl}${id}/ansible_facts/`); } - readGroups(id, params) { - return this.http.get(`${this.baseUrl}${id}/groups/`, { params }); + readAllGroups(id, params) { + return this.http.get(`${this.baseUrl}${id}/all_groups/`, { params }); } readGroupsOptions(id) { diff --git a/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx b/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx index 9576f710b6..4da7fdb023 100644 --- a/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx +++ b/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.jsx @@ -46,7 +46,7 @@ function HostGroupsList({ i18n, location, match, host }) { }, actionsResponse, ] = await Promise.all([ - HostsAPI.readGroups(hostId, params), + HostsAPI.readAllGroups(hostId, params), HostsAPI.readGroupsOptions(hostId), ]); diff --git a/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.test.jsx b/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.test.jsx index c748263eaf..4bb2a89b7a 100644 --- a/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.test.jsx +++ b/awx/ui_next/src/screens/Host/HostGroups/HostGroupsList.test.jsx @@ -71,7 +71,7 @@ describe('', () => { let wrapper; beforeEach(async () => { - HostsAPI.readGroups.mockResolvedValue({ + HostsAPI.readAllGroups.mockResolvedValue({ data: { count: mockGroups.length, results: mockGroups, @@ -114,7 +114,7 @@ describe('', () => { }); test('should fetch groups from api and render them in the list', async () => { - expect(HostsAPI.readGroups).toHaveBeenCalled(); + expect(HostsAPI.readAllGroups).toHaveBeenCalled(); expect(wrapper.find('HostGroupItem').length).toBe(3); }); @@ -165,7 +165,9 @@ describe('', () => { }); test('should show content error when api throws error on initial render', async () => { - HostsAPI.readGroups.mockImplementation(() => Promise.reject(new Error())); + HostsAPI.readAllGroups.mockImplementation(() => + Promise.reject(new Error()) + ); await act(async () => { wrapper = mountWithContexts(); }); @@ -224,7 +226,7 @@ describe('', () => { test('expected api calls are made for multi-disassociation', async () => { expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(0); - expect(HostsAPI.readGroups).toHaveBeenCalledTimes(1); + expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(1); expect(wrapper.find('DataListCheck').length).toBe(3); wrapper.find('DataListCheck').forEach(el => { expect(el.props().checked).toBe(false); @@ -246,7 +248,7 @@ describe('', () => { .simulate('click'); }); expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(3); - expect(HostsAPI.readGroups).toHaveBeenCalledTimes(2); + expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(2); }); test('should show error modal for failed disassociation', async () => { diff --git a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx index 7d260f7782..e049b1d596 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.jsx @@ -45,7 +45,7 @@ function InventoryHostGroupsList({ i18n, location, match }) { }, actionsResponse, ] = await Promise.all([ - HostsAPI.readGroups(hostId, params), + HostsAPI.readAllGroups(hostId, params), HostsAPI.readGroupsOptions(hostId), ]); diff --git a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.test.jsx b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.test.jsx index c31f996c10..8347494c2d 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.test.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHostGroups/InventoryHostGroupsList.test.jsx @@ -63,7 +63,7 @@ describe('', () => { let wrapper; beforeEach(async () => { - HostsAPI.readGroups.mockResolvedValue({ + HostsAPI.readAllGroups.mockResolvedValue({ data: { count: mockGroups.length, results: mockGroups, @@ -106,7 +106,7 @@ describe('', () => { }); test('should fetch groups from api and render them in the list', async () => { - expect(HostsAPI.readGroups).toHaveBeenCalled(); + expect(HostsAPI.readAllGroups).toHaveBeenCalled(); expect(wrapper.find('InventoryHostGroupItem').length).toBe(3); }); @@ -157,7 +157,9 @@ describe('', () => { }); test('should show content error when api throws error on initial render', async () => { - HostsAPI.readGroups.mockImplementation(() => Promise.reject(new Error())); + HostsAPI.readAllGroups.mockImplementation(() => + Promise.reject(new Error()) + ); await act(async () => { wrapper = mountWithContexts(); }); @@ -216,7 +218,7 @@ describe('', () => { test('expected api calls are made for multi-disassociation', async () => { expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(0); - expect(HostsAPI.readGroups).toHaveBeenCalledTimes(1); + expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(1); expect(wrapper.find('DataListCheck').length).toBe(3); wrapper.find('DataListCheck').forEach(el => { expect(el.props().checked).toBe(false); @@ -238,7 +240,7 @@ describe('', () => { .simulate('click'); }); expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(3); - expect(HostsAPI.readGroups).toHaveBeenCalledTimes(2); + expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(2); }); test('should show error modal for failed disassociation', async () => {