Skip to content

Fix spec violations in /add_edit_rotation_modal_spec.js

What does this MR do and why?

The main improvement here was getting rid of this overwrite:

wrapper.vm.$refs.addEditScheduleRotationModal.hide = mockHideModal;

and deleting mocked data()

I also decided to refactor the test to be more in line with https://docs.gitlab.com/ee/development/fe_guide/graphql.html#mocking-apollo-client

  • 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 a rotation. 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.

Screenshots or screen recordings

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

While refactoring the tests, I also changes when the modal clears. Before, it cleared both on hiding and opening event. I'm leaving it only on opening for two reasons:

  1. To not repeat the same action.
  2. To avoid modal clearing out, when it's still visible.

Comparison below (change is subtle, you might need to stop at the point of closing and go forward in slow motion 🙂 ):

before after
Screen_Recording_2023-06-02_at_14.14.55 Screen_Recording_2023-06-02_at_14.16.07

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/rotations/components/add_edit_rotation_modal_spec.js

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

Edited by Paulina Sedlak-Jakubowska

Merge request reports