From 5e1590db9027792e7c758c80712ac10b4746f8ea Mon Sep 17 00:00:00 2001 From: Severin Beauvais Date: Mon, 5 Feb 2024 10:52:13 -0800 Subject: [PATCH] - changed re-routing code to not push the wrong route to history - deleted useless isViteRunning getter - fixed amalgamation statement validation (was undefined on draft restore) - update misc comments --- src/App.vue | 20 +++++++++---------- src/components/common/Actions.vue | 2 +- .../common/SummaryDefineCompany.vue | 1 - src/main.ts | 2 +- src/mixins/common-mixin.ts | 5 ----- src/mixins/filing-template-mixin.ts | 5 ++++- src/store/store.ts | 4 ++-- src/views/Amalgamation/ReviewConfirm.vue | 4 ++-- tests/unit/AmalgamationInformation.spec.ts | 2 +- tests/unit/AmalgamationPeopleRoles.spec.ts | 4 ++-- tests/unit/AmalgamationReviewConfirm.spec.ts | 2 +- tests/unit/AmalgamationShareStructure.spec.ts | 2 +- 12 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/App.vue b/src/App.vue index f5c048783..5ba5eca26 100644 --- a/src/App.vue +++ b/src/App.vue @@ -667,8 +667,8 @@ export default class App extends Mixins(CommonMixin, DateMixin, FilingTemplateMi // reset errors in case this method is invoked more than once (ie, retry) this.resetFlags() - // don't check FF during Vitest tests - if (!this.isVitestRunning) { + // only check FF when not in Vitest tests + if (import.meta.env.VITEST === undefined) { // check that current route matches a supported filing type const supportedFilings = await GetFeatureFlag('supported-filings') if (!supportedFilings?.includes(this.$route.meta.filingType)) { @@ -753,31 +753,31 @@ export default class App extends Mixins(CommonMixin, DateMixin, FilingTemplateMi switch (this.getFilingType) { case FilingTypes.AMALGAMATION_APPLICATION: if (this.isAmalgamationFilingRegular) { - this.$router.push(RouteNames.AMALG_REG_INFORMATION).catch(() => {}) + this.$router.replace(RouteNames.AMALG_REG_INFORMATION).catch(() => {}) } else if (this.isAmalgamationFilingHorizontal || this.isAmalgamationFilingVertical) { - this.$router.push(RouteNames.AMALG_SHORT_INFORMATION).catch(() => {}) + this.$router.replace(RouteNames.AMALG_SHORT_INFORMATION).catch(() => {}) } else { throw new Error('invalid amalgamation filing type') } return case FilingTypes.CONTINUATION_IN: - this.$router.push(RouteNames.CONTINUATION_IN_BUSINESS_HOME).catch(() => {}) + this.$router.replace(RouteNames.CONTINUATION_IN_BUSINESS_HOME).catch(() => {}) return case FilingTypes.DISSOLUTION: if (this.isTypeFirm) { - this.$router.push(RouteNames.DISSOLUTION_FIRM).catch(() => {}) + this.$router.replace(RouteNames.DISSOLUTION_FIRM).catch(() => {}) } else { - this.$router.push(RouteNames.DISSOLUTION_DEFINE_DISSOLUTION).catch(() => {}) + this.$router.replace(RouteNames.DISSOLUTION_DEFINE_DISSOLUTION).catch(() => {}) } return case FilingTypes.INCORPORATION_APPLICATION: - this.$router.push(RouteNames.INCORPORATION_DEFINE_COMPANY).catch(() => {}) + this.$router.replace(RouteNames.INCORPORATION_DEFINE_COMPANY).catch(() => {}) return case FilingTypes.REGISTRATION: - this.$router.push(RouteNames.REGISTRATION_DEFINE_BUSINESS).catch(() => {}) + this.$router.replace(RouteNames.REGISTRATION_DEFINE_BUSINESS).catch(() => {}) return case FilingTypes.RESTORATION: - this.$router.push(RouteNames.RESTORATION_BUSINESS_NAME).catch(() => {}) + this.$router.replace(RouteNames.RESTORATION_BUSINESS_NAME).catch(() => {}) return default: this.invalidRouteDialog = true diff --git a/src/components/common/Actions.vue b/src/components/common/Actions.vue index 21de4b41d..ead2b5fca 100644 --- a/src/components/common/Actions.vue +++ b/src/components/common/Actions.vue @@ -303,7 +303,7 @@ export default class Actions extends Mixins(AmalgamationMixin, CommonMixin, this.setIsFilingPaying(false) } } else { - // don't call window.scrollTo during Vitest tests because jsdom doesn't implement it + // otherwise, smooth-scroll to the top of the page window.scrollTo({ top: 0, behavior: 'smooth' }) } } diff --git a/src/components/common/SummaryDefineCompany.vue b/src/components/common/SummaryDefineCompany.vue index 13d674df0..1f288ac9c 100644 --- a/src/components/common/SummaryDefineCompany.vue +++ b/src/components/common/SummaryDefineCompany.vue @@ -236,7 +236,6 @@ export default class SummaryDefineCompany extends Vue { /** Whether this section is invalid. */ get invalidSection (): boolean { if (this.isAmalgamationFiling) { - // *** FUTURE: update this for short-form amalgamation (needs to be valid) return (!this.isAmalgamationInformationValid || !this.isDefineCompanyValid) } return !this.isDefineCompanyValid diff --git a/src/main.ts b/src/main.ts index f4de2a357..a609cec73 100644 --- a/src/main.ts +++ b/src/main.ts @@ -78,7 +78,7 @@ async function start () { await KeycloakService.setKeycloakConfigUrl(keycloakConfig) // initialize token service which will do a check-sso to initiate session - // don't start during Vitest tests as it messes up the test JWT + // only do when not in Vitest tests as it messes up the test JWT if (import.meta.env.VITEST === undefined) { console.info('Starting token refresh service...') // eslint-disable-line no-console await KeycloakService.initializeToken() diff --git a/src/mixins/common-mixin.ts b/src/mixins/common-mixin.ts index ac4201c0d..894480603 100644 --- a/src/mixins/common-mixin.ts +++ b/src/mixins/common-mixin.ts @@ -9,11 +9,6 @@ import { getName } from 'country-list' */ @Component({}) export default class CommonMixin extends Vue { - /** Is True if Vitest is running the code. */ - get isVitestRunning (): boolean { - return (import.meta.env.VITEST !== undefined) - } - /** * Compares two objects while omitting specified properties from the comparison. * @param objA the first object to compare diff --git a/src/mixins/filing-template-mixin.ts b/src/mixins/filing-template-mixin.ts index 8bdd8497e..0502624f4 100644 --- a/src/mixins/filing-template-mixin.ts +++ b/src/mixins/filing-template-mixin.ts @@ -300,7 +300,10 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM } // restore the Amalgamation Court Approval if it's True or False - if (draftFiling.amalgamationApplication.courtApproval !== null) { + if ( + draftFiling.amalgamationApplication.courtApproval === true || + draftFiling.amalgamationApplication.courtApproval === false + ) { this.setAmalgamationCourtApproval(draftFiling.amalgamationApplication.courtApproval) } diff --git a/src/store/store.ts b/src/store/store.ts index 0ae99287d..6c54f3ded 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -600,11 +600,11 @@ export const useStore = defineStore('store', { this.getNameTranslationsValid ) } else { - // NB - this is the only valid Correct Name Option for short-form amalgamations - // NB - there are no name translations for short-form amalgamations return ( this.getAmalgamatingBusinessesValid && + // NB - this is the only valid Correct Name Option for short-form amalgamations: this.getCorrectNameOption === CorrectNameOptions.CORRECT_AML_ADOPT + // NB - there are no name translations for short-form amalgamations ) } }, diff --git a/src/views/Amalgamation/ReviewConfirm.vue b/src/views/Amalgamation/ReviewConfirm.vue index b04c2db6e..89407b58e 100644 --- a/src/views/Amalgamation/ReviewConfirm.vue +++ b/src/views/Amalgamation/ReviewConfirm.vue @@ -362,12 +362,12 @@ export default class AmalgamationReviewConfirm extends Vue { /** Is true when the Folio Number is not valid */ get isFolioInvalid (): boolean { - return this.getValidateSteps && !(this.getFolioNumberValid) + return (this.getValidateSteps && !this.getFolioNumberValid) } /** Is true when the amalgamation statement is not valid */ get isAmalgamationStatementInvalid (): boolean { - return this.getValidateSteps && !(this.getAmalgamationCourtApprovalValid) + return (this.getValidateSteps && !this.getAmalgamationCourtApprovalValid) } } diff --git a/tests/unit/AmalgamationInformation.spec.ts b/tests/unit/AmalgamationInformation.spec.ts index b39ae062a..eecde456b 100644 --- a/tests/unit/AmalgamationInformation.spec.ts +++ b/tests/unit/AmalgamationInformation.spec.ts @@ -25,7 +25,7 @@ const amalgamationRegularBusinessInfo = [ ] for (const test of amalgamationRegularBusinessInfo) { - describe(`Amalgamation Regular Business Information for a ${test.entityType}`, () => { + describe(`Amalgamation-Regular Information for a ${test.entityType}`, () => { let wrapper: any beforeAll(() => { diff --git a/tests/unit/AmalgamationPeopleRoles.spec.ts b/tests/unit/AmalgamationPeopleRoles.spec.ts index 0d9776562..033f7fce9 100644 --- a/tests/unit/AmalgamationPeopleRoles.spec.ts +++ b/tests/unit/AmalgamationPeopleRoles.spec.ts @@ -20,7 +20,7 @@ const amalgamationRegularBusinessInfo = [ ] for (const test of amalgamationRegularBusinessInfo) { - describe(`Amalgamation Regular Business Information for a ${test.entityType}`, () => { + describe(`Amalgamation-Regular People and Roles for a ${test.entityType}`, () => { let wrapper: any beforeAll(() => { @@ -52,7 +52,7 @@ for (const test of amalgamationRegularBusinessInfo) { // *** TODO: finish the tests for short-form amalgamations // especially differences between regular and short-form - describe(`Amalgamation Regular Business Information for a ${test.entityType}`, () => { + describe(`Amalgamation-Regular People and Roles for a ${test.entityType}`, () => { let wrapper: any beforeAll(() => { diff --git a/tests/unit/AmalgamationReviewConfirm.spec.ts b/tests/unit/AmalgamationReviewConfirm.spec.ts index 5505e8772..497e1f0b6 100644 --- a/tests/unit/AmalgamationReviewConfirm.spec.ts +++ b/tests/unit/AmalgamationReviewConfirm.spec.ts @@ -29,7 +29,7 @@ const amalgamationRegularBusinessInfo = [ ] for (const test of amalgamationRegularBusinessInfo) { - describe(`Restoration Review Confirm for a ${test.entityType}`, () => { + describe(`Amalgamation-Regular Review Confirm for a ${test.entityType}`, () => { let wrapper: any beforeAll(() => { diff --git a/tests/unit/AmalgamationShareStructure.spec.ts b/tests/unit/AmalgamationShareStructure.spec.ts index 7001c1cb5..24bb41605 100644 --- a/tests/unit/AmalgamationShareStructure.spec.ts +++ b/tests/unit/AmalgamationShareStructure.spec.ts @@ -21,7 +21,7 @@ const amalgamationRegularBusinessInfo = [ ] for (const test of amalgamationRegularBusinessInfo) { - describe(`Amalgamation Regular Business Information for a ${test.entityType}`, () => { + describe(`Amalgamation-Regular Share Structure for a ${test.entityType}`, () => { let wrapper: any beforeAll(() => {