mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
update hosts groups api GET to all_groups
This commit is contained in:
parent
cc4c514103
commit
4e64b17712
@ -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) {
|
||||
|
||||
@ -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),
|
||||
]);
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ describe('<HostGroupsList />', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
HostsAPI.readGroups.mockResolvedValue({
|
||||
HostsAPI.readAllGroups.mockResolvedValue({
|
||||
data: {
|
||||
count: mockGroups.length,
|
||||
results: mockGroups,
|
||||
@ -114,7 +114,7 @@ describe('<HostGroupsList />', () => {
|
||||
});
|
||||
|
||||
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('<HostGroupsList />', () => {
|
||||
});
|
||||
|
||||
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(<HostGroupsList host={host} />);
|
||||
});
|
||||
@ -224,7 +226,7 @@ describe('<HostGroupsList />', () => {
|
||||
|
||||
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('<HostGroupsList />', () => {
|
||||
.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 () => {
|
||||
|
||||
@ -45,7 +45,7 @@ function InventoryHostGroupsList({ i18n, location, match }) {
|
||||
},
|
||||
actionsResponse,
|
||||
] = await Promise.all([
|
||||
HostsAPI.readGroups(hostId, params),
|
||||
HostsAPI.readAllGroups(hostId, params),
|
||||
HostsAPI.readGroupsOptions(hostId),
|
||||
]);
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ describe('<InventoryHostGroupsList />', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
HostsAPI.readGroups.mockResolvedValue({
|
||||
HostsAPI.readAllGroups.mockResolvedValue({
|
||||
data: {
|
||||
count: mockGroups.length,
|
||||
results: mockGroups,
|
||||
@ -106,7 +106,7 @@ describe('<InventoryHostGroupsList />', () => {
|
||||
});
|
||||
|
||||
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('<InventoryHostGroupsList />', () => {
|
||||
});
|
||||
|
||||
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(<InventoryHostGroupsList />);
|
||||
});
|
||||
@ -216,7 +218,7 @@ describe('<InventoryHostGroupsList />', () => {
|
||||
|
||||
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('<InventoryHostGroupsList />', () => {
|
||||
.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 () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user