Skip to content

Fix type error when session expires

Savas Vedova requested to merge 413627-fix-type-error into master

What does this MR do and why?

Fixes a type error when user session expires.

Screenshots or screen recordings

Nothing visual here.

How to set up and validate locally

Apply the following diff:

diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue
index 1aed3362c423..a4afdee4d49d 100644
--- a/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue
+++ b/app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue
@@ -48,7 +48,7 @@ export default {
       variables() {
         return this.mergeRequestQueryVariables;
       },
-      update: (data) => data.project?.mergeRequest || {},
+      update: (data) => data.project.mergeRequest,
     },
   },
   components: {
@@ -90,7 +90,7 @@ export default {
       return this.state.rebaseInProgress;
     },
     canPushToSourceBranch() {
-      return this.state.userPermissions?.pushToSourceBranch || false;
+      return this.state.userPermissions.pushToSourceBranch;
     },
     targetBranch() {
       return this.state.targetBranch;

Then execute:

yarn jest spec/frontend/vue_merge_request_widget/components/mr_widget_rebase_spec.js

It should throw an error (same error occurs on production when user session expires).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #413627 (closed)

Merge request reports

Loading