Loading
Fix browser console errors on Vue 3 pages
What does this MR do and why?
Feature specs fail when the browser console logs an error that spec/support/browser_console_allowlist.yml does not allow. This MR fixes four of the errors in that list and removes their entries.
It is split from MR 262368. These four fixes are grouped because their errors show up on pages that run on Vue 3, or through Vue 3 compat code. None of them is a bug in Vue 3 compat itself. Each one is also wrong in Vue 2.
| Allowlist entry | Cause | Fix |
|---|---|---|
TypeError: Cannot read properties of null (reading 'map') |
The branch rule modal maps protectableBranches, which GraphQL can return as null. The local stack ran in pages.projects.settings.repository.show.vue3.bundle.js. |
Default to []. |
TypeError: Cannot read properties of undefined (reading 'replace') |
saveEditedLink runs the editor chain. That can hide the link bubble menu, and its hidden handler clears linkCanonicalSrc. endEditingLink then resolves undefined. The order of events depends on timing, so the error was flaky. The local stack went through Vue 3's callWithAsyncErrorHandling. |
Copy linkCanonicalSrc before the chain runs, and resolve that copy. |
Error: The resource that you are attempting to access does not exist... |
Work item reorder shows an alert and reports the error to Sentry, then re-throws it. The error reached the console through DraggableCompat. |
Do not re-throw. |
Error: The emoji map is uninitialized or initialization has not completed |
The status query can resolve before the emoji map loads. The statusEmoji watcher then reads the map. Vue 3 schedules watcher callbacks differently from Vue 2. |
The watcher awaits initEmojiMap(). It returns the same cached promise to every caller, so the map loads once. |
How to verify
- Jest: the branch rule modal, link bubble menu and greeting fixes each have a test. Each test fails without its fix and passes with it. All tests pass in both Vue lanes.
- The reorder fix has no Jest test.
spec/features/groups/work_items_spec.rbcovers it, because the removed allowlist entry makes that spec fail if the error comes back. - Feature specs: the entries are removed, so any example that still logs one of these errors fails. The affected specs:
ee/spec/features/projects/protected_branches_spec.rbee/spec/features/projects/settings/ee/protected_branches_spec.rbspec/features/work_items/issues/new/user_creates_issue_spec.rbspec/features/groups/work_items_spec.rbspec/features/profiles/user_edit_profile_spec.rb
- An earlier version of these fixes passed all rspec jobs in pipeline 2951299191 of MR 262368, in EE and as-if-foss. The link bubble menu and greeting fixes changed since then.
References
- Split from !262368 (closed)
- Catalogue of console errors in feature specs: #628901
- Added the allowlist: !256639 (merged)
Edited by Miguel Rincon