Skip to content

Add license compliance widget mount tests

What does this MR do and why?

Add test coverage for whether the license compliance widget should be mounted by the widget/app.vue.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

No visual changes expected

How to set up and validate locally

to run tests locally

git checkout mfluharty-add-license-compliance-widget-mount-tests
yarn install
yarn jest widget/app
  1. changing the conditions for mounting the license compliance widget in ee/vue_merge_request_widget/components/widget/app.vue should cause the test to fail:
  computed: {
    licenseComplianceWidget() {
-      return this.mr?.enabledReports?.licenseScanning ? 'MrLicenseComplianceWidget' : undefined;
+      return false;
    },
 FAIL  ee/spec/frontend/vue_merge_request_widget/components/widget/app_spec.js
  ● MR Widget App › License Compliance Widget › is mounted when the report is enabled and endpoint is provided

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      74 |       });
      75 |       await waitForPromises();
    > 76 |       expect(wrapper.findComponent(MrLicenseComplianceWidget).exists()).toBe(true);
         |                                                                         ^
      77 |     });
      78 |
      79 |     it('is not mounted when not enabled', async () => {

      at Object.toBe (ee/spec/frontend/vue_merge_request_widget/components/widget/app_spec.js:76:73)
Edited by Miranda Fluharty

Merge request reports