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

Merge branch '523627-policies-fix-compliance-frameworks' into 'master'

Add check for nullability for compliance framework

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



Merged-by: default avatarAlexander Turinske <aturinske@gitlab.com>
Approved-by: default avatarAlexander Turinske <aturinske@gitlab.com>
Reviewed-by: default avatarArtur Fedorov <afedorov@gitlab.com>
Co-authored-by: default avatarArtur Fedorov <afedorov@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -43,13 +43,13 @@ export default { ...@@ -43,13 +43,13 @@ export default {
}; };
}, },
update(data) { update(data) {
return this.getUniqueFrameworks(data.namespace?.complianceFrameworks.nodes); return this.getUniqueFrameworks(data.namespace?.complianceFrameworks?.nodes);
}, },
result({ data }) { result({ data }) {
this.pageInfo = data?.namespace?.complianceFrameworks?.pageInfo || {}; this.pageInfo = data?.namespace?.complianceFrameworks?.pageInfo || {};
if (this.selectedButNotLoadedComplianceIds.length > 0) { if (this.selectedButNotLoadedComplianceIds.length > 0) {
this.fetchComplianceFramoworksByIds(); this.fetchComplianceFrameworksByIds();
} }
}, },
error() { error() {
...@@ -179,7 +179,7 @@ export default { ...@@ -179,7 +179,7 @@ export default {
this.debouncedSearch.cancel(); this.debouncedSearch.cancel();
}, },
methods: { methods: {
async fetchComplianceFramoworksByIds() { async fetchComplianceFrameworksByIds() {
try { try {
const { data } = await this.$apollo.query({ const { data } = await this.$apollo.query({
query: getComplianceFrameworkQuery, query: getComplianceFrameworkQuery,
...@@ -190,7 +190,7 @@ export default { ...@@ -190,7 +190,7 @@ export default {
}); });
this.complianceFrameworks = this.getUniqueFrameworks( this.complianceFrameworks = this.getUniqueFrameworks(
data?.namespace?.complianceFrameworks.nodes, data?.namespace?.complianceFrameworks?.nodes,
); );
} catch { } catch {
this.emitError(); this.emitError();
......
...@@ -360,6 +360,25 @@ describe('ComplianceFrameworkDropdown', () => { ...@@ -360,6 +360,25 @@ describe('ComplianceFrameworkDropdown', () => {
}); });
}); });
describe('when query response has no frameworks', () => {
it('emits error when query does not return frameworks', async () => {
createComponent({
handlers: {
complianceFrameworks: jest.fn().mockResolvedValue({
data: {
namespace: {
id: 1,
name: 'name',
},
},
}),
},
});
await waitForPromises();
expect(wrapper.emitted('framework-query-error')).toHaveLength(1);
});
});
describe('error state', () => { describe('error state', () => {
it.each` it.each`
showError | variant | category | groupErrorAttribute showError | variant | category | groupErrorAttribute
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册