diff --git a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown.vue b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown.vue index c9f87005cb48c05bfbc0fd8ca5d85801c85b88e4..f232928f537d230aeec3be9834191c07bc02be5c 100644 --- a/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown.vue +++ b/ee/app/assets/javascripts/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown.vue @@ -43,13 +43,13 @@ export default { }; }, update(data) { - return this.getUniqueFrameworks(data.namespace?.complianceFrameworks.nodes); + return this.getUniqueFrameworks(data.namespace?.complianceFrameworks?.nodes); }, result({ data }) { this.pageInfo = data?.namespace?.complianceFrameworks?.pageInfo || {}; if (this.selectedButNotLoadedComplianceIds.length > 0) { - this.fetchComplianceFramoworksByIds(); + this.fetchComplianceFrameworksByIds(); } }, error() { @@ -179,7 +179,7 @@ export default { this.debouncedSearch.cancel(); }, methods: { - async fetchComplianceFramoworksByIds() { + async fetchComplianceFrameworksByIds() { try { const { data } = await this.$apollo.query({ query: getComplianceFrameworkQuery, @@ -190,7 +190,7 @@ export default { }); this.complianceFrameworks = this.getUniqueFrameworks( - data?.namespace?.complianceFrameworks.nodes, + data?.namespace?.complianceFrameworks?.nodes, ); } catch { this.emitError(); diff --git a/ee/spec/frontend/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown_spec.js b/ee/spec/frontend/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown_spec.js index 6dbcfd18328d34ed7f751adbef8b40454b1fbf50..fee87d25291930131a2373e70080d577b65bee42 100644 --- a/ee/spec/frontend/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown_spec.js +++ b/ee/spec/frontend/security_orchestration/components/policy_editor/scope/compliance_framework_dropdown_spec.js @@ -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', () => { it.each` showError | variant | category | groupErrorAttribute