Fix org team link url

This commit is contained in:
Marliana Lara 2020-01-28 12:26:21 -05:00
parent 7d74999851
commit 9cb7b0902a
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
2 changed files with 18 additions and 3 deletions

View File

@ -30,7 +30,9 @@ function OrganizationTeams({ id, i18n }) {
data: { count = 0, results = [] },
} = await OrganizationsAPI.readTeams(id, params);
setItemCount(count);
setTeams(results);
setTeams(
results.map(team => ({ ...team, url: `/teams/${team.id}/details` }))
);
} catch (error) {
setContentError(error);
} finally {

View File

@ -2,7 +2,7 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { OrganizationsAPI } from '@api';
import { mountWithContexts } from '@testUtils/enzymeHelpers';
import { mountWithContexts, waitForElement } from '@testUtils/enzymeHelpers';
import { sleep } from '@testUtils/testUtils';
import OrganizationTeams from './OrganizationTeams';
@ -65,7 +65,9 @@ describe('<OrganizationTeams />', () => {
wrapper.update();
const list = wrapper.find('PaginatedDataList');
expect(list.prop('items')).toEqual(listData.data.results);
list.find('DataListCell').forEach((el, index) => {
expect(el.text()).toBe(listData.data.results[index].name);
});
expect(list.prop('itemCount')).toEqual(listData.data.count);
expect(list.prop('qsConfig')).toEqual({
namespace: 'team',
@ -78,4 +80,15 @@ describe('<OrganizationTeams />', () => {
integerFields: ['page', 'page_size'],
});
});
test('should show content error for failed instance group fetch', async () => {
OrganizationsAPI.readTeams.mockImplementationOnce(() =>
Promise.reject(new Error())
);
let wrapper;
await act(async () => {
wrapper = mountWithContexts(<OrganizationTeams id={1} />);
});
await waitForElement(wrapper, 'ContentError', el => el.length === 1);
});
});