mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
update hosts groups api GET to all_groups
This commit is contained in:
@@ -7,7 +7,7 @@ class Hosts extends Base {
|
|||||||
this.baseUrl = '/api/v2/hosts/';
|
this.baseUrl = '/api/v2/hosts/';
|
||||||
|
|
||||||
this.readFacts = this.readFacts.bind(this);
|
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.readGroupsOptions = this.readGroupsOptions.bind(this);
|
||||||
this.associateGroup = this.associateGroup.bind(this);
|
this.associateGroup = this.associateGroup.bind(this);
|
||||||
this.disassociateGroup = this.disassociateGroup.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/`);
|
return this.http.get(`${this.baseUrl}${id}/ansible_facts/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
readGroups(id, params) {
|
readAllGroups(id, params) {
|
||||||
return this.http.get(`${this.baseUrl}${id}/groups/`, { params });
|
return this.http.get(`${this.baseUrl}${id}/all_groups/`, { params });
|
||||||
}
|
}
|
||||||
|
|
||||||
readGroupsOptions(id) {
|
readGroupsOptions(id) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ function HostGroupsList({ i18n, location, match, host }) {
|
|||||||
},
|
},
|
||||||
actionsResponse,
|
actionsResponse,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
HostsAPI.readGroups(hostId, params),
|
HostsAPI.readAllGroups(hostId, params),
|
||||||
HostsAPI.readGroupsOptions(hostId),
|
HostsAPI.readGroupsOptions(hostId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ describe('<HostGroupsList />', () => {
|
|||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
HostsAPI.readGroups.mockResolvedValue({
|
HostsAPI.readAllGroups.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
count: mockGroups.length,
|
count: mockGroups.length,
|
||||||
results: mockGroups,
|
results: mockGroups,
|
||||||
@@ -114,7 +114,7 @@ describe('<HostGroupsList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should fetch groups from api and render them in the list', async () => {
|
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);
|
expect(wrapper.find('HostGroupItem').length).toBe(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -165,7 +165,9 @@ describe('<HostGroupsList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should show content error when api throws error on initial render', async () => {
|
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 () => {
|
await act(async () => {
|
||||||
wrapper = mountWithContexts(<HostGroupsList host={host} />);
|
wrapper = mountWithContexts(<HostGroupsList host={host} />);
|
||||||
});
|
});
|
||||||
@@ -224,7 +226,7 @@ describe('<HostGroupsList />', () => {
|
|||||||
|
|
||||||
test('expected api calls are made for multi-disassociation', async () => {
|
test('expected api calls are made for multi-disassociation', async () => {
|
||||||
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(0);
|
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(0);
|
||||||
expect(HostsAPI.readGroups).toHaveBeenCalledTimes(1);
|
expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(1);
|
||||||
expect(wrapper.find('DataListCheck').length).toBe(3);
|
expect(wrapper.find('DataListCheck').length).toBe(3);
|
||||||
wrapper.find('DataListCheck').forEach(el => {
|
wrapper.find('DataListCheck').forEach(el => {
|
||||||
expect(el.props().checked).toBe(false);
|
expect(el.props().checked).toBe(false);
|
||||||
@@ -246,7 +248,7 @@ describe('<HostGroupsList />', () => {
|
|||||||
.simulate('click');
|
.simulate('click');
|
||||||
});
|
});
|
||||||
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(3);
|
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(3);
|
||||||
expect(HostsAPI.readGroups).toHaveBeenCalledTimes(2);
|
expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should show error modal for failed disassociation', async () => {
|
test('should show error modal for failed disassociation', async () => {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ function InventoryHostGroupsList({ i18n, location, match }) {
|
|||||||
},
|
},
|
||||||
actionsResponse,
|
actionsResponse,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
HostsAPI.readGroups(hostId, params),
|
HostsAPI.readAllGroups(hostId, params),
|
||||||
HostsAPI.readGroupsOptions(hostId),
|
HostsAPI.readGroupsOptions(hostId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ describe('<InventoryHostGroupsList />', () => {
|
|||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
HostsAPI.readGroups.mockResolvedValue({
|
HostsAPI.readAllGroups.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
count: mockGroups.length,
|
count: mockGroups.length,
|
||||||
results: mockGroups,
|
results: mockGroups,
|
||||||
@@ -106,7 +106,7 @@ describe('<InventoryHostGroupsList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should fetch groups from api and render them in the list', async () => {
|
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);
|
expect(wrapper.find('InventoryHostGroupItem').length).toBe(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,7 +157,9 @@ describe('<InventoryHostGroupsList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should show content error when api throws error on initial render', async () => {
|
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 () => {
|
await act(async () => {
|
||||||
wrapper = mountWithContexts(<InventoryHostGroupsList />);
|
wrapper = mountWithContexts(<InventoryHostGroupsList />);
|
||||||
});
|
});
|
||||||
@@ -216,7 +218,7 @@ describe('<InventoryHostGroupsList />', () => {
|
|||||||
|
|
||||||
test('expected api calls are made for multi-disassociation', async () => {
|
test('expected api calls are made for multi-disassociation', async () => {
|
||||||
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(0);
|
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(0);
|
||||||
expect(HostsAPI.readGroups).toHaveBeenCalledTimes(1);
|
expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(1);
|
||||||
expect(wrapper.find('DataListCheck').length).toBe(3);
|
expect(wrapper.find('DataListCheck').length).toBe(3);
|
||||||
wrapper.find('DataListCheck').forEach(el => {
|
wrapper.find('DataListCheck').forEach(el => {
|
||||||
expect(el.props().checked).toBe(false);
|
expect(el.props().checked).toBe(false);
|
||||||
@@ -238,7 +240,7 @@ describe('<InventoryHostGroupsList />', () => {
|
|||||||
.simulate('click');
|
.simulate('click');
|
||||||
});
|
});
|
||||||
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(3);
|
expect(HostsAPI.disassociateGroup).toHaveBeenCalledTimes(3);
|
||||||
expect(HostsAPI.readGroups).toHaveBeenCalledTimes(2);
|
expect(HostsAPI.readAllGroups).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should show error modal for failed disassociation', async () => {
|
test('should show error modal for failed disassociation', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user