Skip to content
代码片段 群组 项目
提交 bcf8dbe0 编辑于 作者: Dave Pisek's avatar Dave Pisek
浏览文件

Add error handling for sec config license fetch

This commit adds an error handler to the query, which is responsible
for fetching the license tier of the current user. Currently if
the query fails, the whole security training feature is not show.

Changelog: fixed
EE: true
上级 06bacac7
No related branches found
No related tags found
无相关合并请求
...@@ -57,6 +57,9 @@ export default { ...@@ -57,6 +57,9 @@ export default {
update({ currentLicense }) { update({ currentLicense }) {
return currentLicense?.plan; return currentLicense?.plan;
}, },
error() {
this.hasCurrentLicenseFetchError = true;
},
}, },
}, },
props: { props: {
...@@ -99,6 +102,7 @@ export default { ...@@ -99,6 +102,7 @@ export default {
autoDevopsEnabledAlertDismissedProjects: [], autoDevopsEnabledAlertDismissedProjects: [],
errorMessage: '', errorMessage: '',
currentLicensePlan: '', currentLicensePlan: '',
hasCurrentLicenseFetchError: false,
}; };
}, },
computed: { computed: {
...@@ -120,7 +124,10 @@ export default { ...@@ -120,7 +124,10 @@ export default {
); );
}, },
shouldShowVulnerabilityManagementTab() { shouldShowVulnerabilityManagementTab() {
return this.currentLicensePlan === LICENSE_ULTIMATE; // if the query fails (if the plan is `null` also means an error has occurred) we still want to show the feature
const hasQueryError = this.hasCurrentLicenseFetchError || this.currentLicensePlan === null;
return hasQueryError || this.currentLicensePlan === LICENSE_ULTIMATE;
}, },
}, },
methods: { methods: {
......
...@@ -54,13 +54,22 @@ describe('App component', () => { ...@@ -54,13 +54,22 @@ describe('App component', () => {
const createComponent = ({ const createComponent = ({
shouldShowCallout = true, shouldShowCallout = true,
license = LICENSE_ULTIMATE, licenseQueryResponse = LICENSE_ULTIMATE,
...propsData ...propsData
}) => { }) => {
userCalloutDismissSpy = jest.fn(); userCalloutDismissSpy = jest.fn();
mockApollo = createMockApollo([ mockApollo = createMockApollo([
[currentLicenseQuery, jest.fn().mockResolvedValue(getCurrentLicensePlanResponse(license))], [
currentLicenseQuery,
jest
.fn()
.mockResolvedValue(
licenseQueryResponse instanceof Error
? licenseQueryResponse
: getCurrentLicensePlanResponse(licenseQueryResponse),
),
],
]); ]);
wrapper = extendedWrapper( wrapper = extendedWrapper(
...@@ -484,19 +493,23 @@ describe('App component', () => { ...@@ -484,19 +493,23 @@ describe('App component', () => {
}); });
it.each` it.each`
license | display licenseQueryResponse | display
${LICENSE_ULTIMATE} | ${true} ${LICENSE_ULTIMATE} | ${true}
${LICENSE_PREMIUM} | ${false} ${LICENSE_PREMIUM} | ${false}
${LICENSE_FREE} | ${false} ${LICENSE_FREE} | ${false}
${null} | ${false} ${null} | ${true}
`('displays $display for license $license', async ({ license, display }) => { ${new Error()} | ${true}
createComponent({ `(
license, 'displays $display for license $licenseQueryResponse',
augmentedSecurityFeatures: securityFeaturesMock, async ({ licenseQueryResponse, display }) => {
augmentedComplianceFeatures: complianceFeaturesMock, createComponent({
}); licenseQueryResponse,
await waitForPromises(); augmentedSecurityFeatures: securityFeaturesMock,
expect(findVulnerabilityManagementTab().exists()).toBe(display); augmentedComplianceFeatures: complianceFeaturesMock,
}); });
await waitForPromises();
expect(findVulnerabilityManagementTab().exists()).toBe(display);
},
);
}); });
}); });
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册