Accept empty values for props that Vue 2 flagged in feature specs

What does this MR do and why?

Three Invalid prop: type check failed warnings in CE appear across different pages.

(a) prop "token". Expected String, got Null in NewToken and SimpleCopyButton: this warning comes from the test setup, not from the component. Feature specs create the user with let_it_be, which freezes the record. sign_in(user) uses the Warden test helpers, which pass the same frozen object to the next request. The user factory never set a feed token, and since commit c7037f0a ensure_token! skips the lazy write on frozen records and returns nil. So tokens_app_data serialized token: null. Production records are never frozen, so the token prop stays required: true. Fix: the user factory now generates the feed token on build, with a regression example in spec/models/user_spec.rb.

(b) prop "value". Expected String, got Undefined in TimezoneDropdown: the initial_value data attribute is absent when the user has no timezone set. Fix: pass initialValue ?? '' instead of initialValue.

(c) prop "dateTitle". Expected String, got Null in MrWidgetAuthorTime: the merged MR and closed MR widgets pass mr.metrics.mergedAt and closedAt, which can be null. Fix: the dateTitle prop is now optional with default ''.

Changes made:

  • app/assets/javascripts/pages/user_settings/profiles/show/init_timezone_dropdown.js: pass '' when initial_value is absent
  • app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author_time.vue: dateTitle prop optional with default ''
  • spec/factories/users.rb: generate the feed token in after(:build)
  • spec/models/user_spec.rb: regression example for a frozen let_it_be user

How to set up and validate locally

  1. Run bin/rspec spec/models/user_spec.rb -e "feed token". Verify it passes.
  2. Go to User settings > Profile with no timezone set. Verify the timezone dropdown shows no warning.
  3. Open a merged MR without merge metrics. Verify the author widget shows no warning.
  4. Check the browser console shows no [Vue warn] lines for these warnings.

MR acceptance checklist

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

References

🤖 Generated with Claude Code

Edited by Miguel Rincon

Merge request reports

Loading
Loading