Skip to content

Commit

Permalink
Fix Cancel Transport Permit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimak1 committed May 14, 2024
1 parent e77b8c8 commit 50af66b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "3.1.20",
"version": "3.1.21",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
35 changes: 27 additions & 8 deletions ppr-ui/tests/unit/MhrTransportPermit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { mockTransportPermitNewLocation, mockTransportPermitPreviousLocation, mo

import { useStore } from '@/store/store'

import { AuthRoles, LocationChangeTypes, ProductCode, RouteNames } from '@/enums'
import { AuthRoles, HomeLocationTypes, LocationChangeTypes, ProductCode, RouteNames } from '@/enums'

import {
DocumentId,
Expand All @@ -31,6 +31,7 @@ import { BaseDialog } from '@/components/dialogs'
import { MhrInformation, MhrTransportPermit } from '@/views'
import { useTransportPermits } from '@/composables'
import { incompleteRegistrationDialog } from '@/resources/dialogOptions'
import { MhrRegistrationHomeLocationIF } from '@/interfaces'

const store = useStore()

Expand Down Expand Up @@ -778,14 +779,31 @@ describe('Mhr Information Transport Permit', async () => {
defaultFlagSet['mhr-cancel-transport-permit-enabled'] = true
wrapper.vm.dataLoaded = true

// setup current location to be cancelled
const location = {...mockTransportPermitNewLocation }
location.otherType = mockTransportPermitNewLocation.locationType
location.locationType = HomeLocationTypes.HOME_PARK

await store.setMhrLocationAllFields(location)
await nextTick()

wrapper = await createComponent(
MhrInformation,
{ appReady: true, isMhrTransfer: false },
RouteNames.MHR_INFORMATION
)
wrapper.vm.dataLoaded = true

await setupActiveTransportPermit()

// set mhr registration location data for it to be prefilled in Cancelled Location section
const regLocation = store.getMhrRegistrationLocation
store.setMhrLocationAllFields({ ...regLocation, ...mockTransportPermitNewLocation })
// setup previous location to restore
const previousLocation: MhrRegistrationHomeLocationIF = {...mockTransportPermitPreviousLocation}
previousLocation.otherType = mockTransportPermitPreviousLocation.locationType
previousLocation.locationType = HomeLocationTypes.OTHER_LAND

await store.setMhrTransportPermitPreviousLocation(previousLocation)
await nextTick()

// expect(wrapper.findByTestId('cancel-location-change-btn').text()).toBe('Cancel Transport Permit')
wrapper.findComponent(MhrTransportPermit).vm.toggleCancelTransportPermit(true)
await nextTick()

Expand All @@ -799,13 +817,14 @@ describe('Mhr Information Transport Permit', async () => {

const cancelledLocationSection = permitLocationSections[0]
expect(cancelledLocationSection.find('label').text()).toContain('Cancelled Location')
expect(cancelledLocationSection.text()).toContain('Manufactured home park')
expect(cancelledLocationSection.text()).toContain(location.address.street)

const restoredLocationSection = permitLocationSections[1]
expect(restoredLocationSection.find('label').text()).toContain('Restored Location')
expect(restoredLocationSection.text()).toContain(mockTransportPermitPreviousLocation.address.street)
console.log(restoredLocationSection.text());

expect(restoredLocationSection.text()).toContain(mockTransportPermitPreviousLocation.locationType)
expect(restoredLocationSection.text()).toContain('Strata')
expect(restoredLocationSection.text()).toContain(previousLocation.address.street)

// transport permit details should not exist in Restored Location section
expect(restoredLocationSection.findComponent(TransportPermitDetails).exists()).toBeFalsy()
Expand Down

0 comments on commit 50af66b

Please sign in to comment.