bcgov / gwells

Groundwater Wells and Aquifers application for the Ministry of Environment
https://apps.nrs.gov.bc.ca/gwells/
Apache License 2.0
30 stars 36 forks source link

Rebuild Testing Suite - Part 2 - Frontend #2141

Open LolandaE opened 8 months ago

LolandaE commented 8 months ago

Describe the task

Bring the test suite to an 85-90% Coverage rate

Purpose

Since the test suite is in an unmanaged position, overall testing in the application has reduced to just over 50% total coverage.

Acceptance Criteria

Additional context

File. % Stmts % Branch % Funcs % Lines
All Files 51.71 18.45 21.67 52.27

Challenges

davidclaveau commented 7 months ago

Working on this ticket, there are a few additional things to note.

The coverage provided when running npm run coverage:test from the frontend directory is showing incorrectly.

This might be related to similar issues others have seen, like in this thread. Regardless if this is an issue or not, it might be good indicator that further updates are required to the frontend on the whole before moving further, such as updating dependencies or updating to Vue 3.

If it is an issue, it's probably an issue with a dependency mismatch. I attempted to some trial and error tests to see if there was a change in the printout, but these changes didn't prove fruitful. I attempted to incrementally update the devDependcies from their current versions to newer version:

As well as update the Vue 2 version from 2.6.10 to 2.7.16, but still no luck with running the test. (Several other issues crop up where there are issues with the jest.config.js file that I wasn't able to identify, but this might just need some more debugging to get working).

This was running this relatively feeble test for the aquifers/components/Documents.js file running this command npm run coverage:test tests/unit/specs/aquifers/components/Documents.spec.js.

It shows the coverage at 100% for a test suite with two very limited tests.

Image

The test file:

/* eslint-disable indent */
import { mount, createLocalVue } from '@vue/test-utils'
import Documents from '../../../../../src/aquifers/components/Documents.vue'
import Vuex from 'vuex'

const localVue = createLocalVue()
localVue.use(Vuex)

describe('Documents.vue', () => {
  describe('When loaded', () => {
    const store = new Vuex.Store({
      getters: {
        userRoles: () => ({
          aquifers: {
            edit: true
          }
        })
     }
    })
    const activity = 'DRILL'

    const wrapper = mount(Documents, {
      store,
      propsData: {
        files: {
          'public': []
        },
        id: 0,
        editMode: false,
        loading: false,
        highlightRegexp: /[_ -]factsheet[_ -]*.*\.pdf$/i,
        highlightTitle: '',
        publicFilesTitle: ''
      },
      localVue
    })

    it('renders correctly', () => {
      expect(wrapper.exists()).toBe(true)
    })

    it('displays loading indicator when loading', () => {
      const wrapper = mount(Documents, {
         propsData: {
           loading: true
         }
      })
      expect(wrapper.find('.fa-circle-o-notch').exists()).toBe(true)
     })
  })
})
jakemorr commented 7 months ago

Fergus to review, likely wont be completed unitl after pipeline work and Node is updated