Skip to content

Fix spec violations in add_edit_schedule_modal_spec.js

What does this MR do and why?

The main changes listed as spec violations are:

  • getting rid of mocking data()
  • getting rid of wrapper.vm.$refs.addEditScheduleRotationModal.hide = mockHideModal;

Additionally:

  • I deleted two separate functions for creating the component and use only one in the whole file. This allowed for removing outdated { mocks: { $apollo ...}} on mount
  • I consolidated assertions for creating and editing schedules. Previously they where tested with the mock once and then just as calls to GraphQL API.
  • I reorganized the file a bit, so that all the declarations are in one place at the top.
  • I refactored mocks to share one defined object and only overwrite the properties needed in tests.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Here's the comparison of assertions before and after refactor:

Before After
Screenshot_2023-06-05_at_16.47.10 Screenshot_2023-06-05_at_16.29.19

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Checkout the branch locally
  2. Run yarn jest ee/spec/frontend/oncall_schedule/add_edit_schedule_modal_spec.js to validate the refactored spec
  3. Run yarn jest ee/spec/frontend/oncall_schedule to validate the refactored mocks for the whole module

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 #413340 (closed)

Edited by Paulina Sedlak-Jakubowska

Merge request reports