Skip to content
代码片段 群组 项目
未验证 提交 5ddc4964 编辑于 作者: Artur Fedorov's avatar Artur Fedorov
浏览文件

Add additional checks for group projects

Add fallback values for grapqhql response
in case of response has some missing values

Changelog: fixed
EE: true
上级 403a58c5
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
......@@ -32,10 +32,11 @@ export default {
* otherwise after performing backend search and selecting found item
* selection is overwritten
*/
return uniqBy([...this.projects, ...data.group.projects.nodes], 'id');
const { projects: { nodes = [] } = {} } = data.group || {};
return uniqBy([...this.projects, ...nodes], 'id');
},
result({ data }) {
this.pageInfo = data?.group?.projects.pageInfo || {};
this.pageInfo = data?.group?.projects?.pageInfo || {};
if (this.selectedButNotLoadedProjectIds.length > 0) {
this.fetchGroupProjectsByIds();
......@@ -176,8 +177,8 @@ export default {
query: getGroupProjects,
variables,
});
this.projects = uniqBy([...this.projects, ...data.group.projects.nodes], 'id');
const { projects: { nodes = [] } = {} } = data.group || {};
this.projects = uniqBy([...this.projects, ...nodes], 'id');
} catch {
this.$emit('projects-query-error');
}
......
......@@ -206,6 +206,26 @@ describe('GroupProjectsDropdown', () => {
});
});
describe('when fetch query returns group as null', () => {
it('renders empty list when group is null', async () => {
createComponent({
handlers: {
handlers: {
getGroupProjects: jest.fn().mockResolvedValue({
data: {
id: 1,
group: null,
},
}),
},
},
});
await waitForPromises();
expect(wrapper.emitted('projects-query-error')).toHaveLength(1);
});
});
describe('when a query is loading a new page of projects', () => {
it('should render the loading spinner', async () => {
createComponent({ handlers: mockApolloHandlers([], true) });
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册