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''wheninitial_valueis absentapp/assets/javascripts/vue_merge_request_widget/components/mr_widget_author_time.vue:dateTitleprop optional with default''spec/factories/users.rb: generate the feed token inafter(:build)spec/models/user_spec.rb: regression example for a frozenlet_it_beuser
How to set up and validate locally
- Run
bin/rspec spec/models/user_spec.rb -e "feed token". Verify it passes. - Go to User settings > Profile with no timezone set. Verify the timezone dropdown shows no warning.
- Open a merged MR without merge metrics. Verify the author widget shows no warning.
- 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.
- I have evaluated the MR acceptance checklist for this MR.
References
- Addresses one entry of #628901 (browser console error catalogue, section C: Vue warnings)
- Warnings surfaced by !255207 (closed) (feature specs fail on console errors)
- Sibling fixes from the same section: !255388 (merged), !255389 (merged), !255390 (merged), !255391 (closed), !255392 (merged), !255393 (closed), !255395 (merged), !255396 (merged), !255397 (merged), !255398 (merged)