Skip to content
代码片段 群组 项目
未验证 提交 cbfc6bed 编辑于 作者: Alexander Turinske's avatar Alexander Turinske 提交者: GitLab
浏览文件

Merge branch '524637-policies-bug-fix-grapqhql-response' into 'master'

Add additional checks for group projects

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/184350



Merged-by: default avatarAlexander Turinske <aturinske@gitlab.com>
Approved-by: default avatarAlexander Turinske <aturinske@gitlab.com>
Co-authored-by: default avatarArtur Fedorov <afedorov@gitlab.com>
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.
先完成此消息的编辑!
想要评论请 注册