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

Merge branch '510296-resolve-error-race-condition' into 'master'

Resolve vulnerability modal error race condition

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



Merged-by: default avatarDavid Pisek <dpisek@gitlab.com>
Approved-by: default avatarDavid Pisek <dpisek@gitlab.com>
Reviewed-by: default avatarDavid Pisek <dpisek@gitlab.com>
Co-authored-by: default avatarSamantha Ming <sming@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -106,9 +106,6 @@ export default {
})
.then(({ data }) => {
this.createdVulnerabilityId = data.securityFindingCreateVulnerability.vulnerability.id;
})
.catch((e) => {
this.handleError(e);
});
},
resolveVulnerabilityWithAi() {
......@@ -142,7 +139,12 @@ export default {
this.isResolving = true;
// if there is no vulnerability then kick of the mutation to create one
if (!this.vulnerabilityId) {
await this.createVulnerabilityForFinding();
try {
await this.createVulnerabilityForFinding();
} catch (e) {
this.handleError(e);
return;
}
}
this.startResolveWithAISubscription();
this.$emit('resolveStart');
......
......@@ -173,15 +173,19 @@ describe('ee/security_dashboard/components/pipeline/resolve_with_ai_button.vue',
});
describe('error handling', () => {
it('emits an error when the "securityFindingCreateVulnerability" errors', async () => {
const setupErrorFindingCreationSpy = () => {
const findingCreationSpy = jest.fn().mockRejectedValue(new Error('creation error'));
createWrapperWithApollo({
responseHandlers: {
securityFindingCreateVulnerability: findingCreationSpy,
},
propsData: { vulnerabilityId: undefined },
});
return findingCreationSpy;
};
it('emits an error when the "securityFindingCreateVulnerability" errors', async () => {
const findingCreationSpy = setupErrorFindingCreationSpy();
expect(wrapper.emitted('error')).toBeUndefined();
......@@ -192,6 +196,20 @@ describe('ee/security_dashboard/components/pipeline/resolve_with_ai_button.vue',
expect(findingCreationSpy).toHaveBeenCalledWith({ uuid: '1' });
expect(wrapper.emitted('error')).toHaveLength(1);
expect(wrapper.emitted('error')[0][0]).toEqual(new Error('creation error'));
expect(wrapper.emitted('resolveStart')).toBeUndefined();
});
it('prevents error message from being cleared by "resolveStart" when "securityFindingCreateVulnerability" errors', async () => {
setupErrorFindingCreationSpy();
expect(wrapper.emitted('error')).toBeUndefined();
expect(wrapper.emitted('resolveStart')).toBeUndefined();
clickButton();
await waitForPromises();
expect(wrapper.emitted('error')).toHaveLength(1);
expect(wrapper.emitted('resolveStart')).toBeUndefined();
});
});
});
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册