Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17765 complete resolution fix #565

Merged
merged 4 commits into from Sep 19, 2023

Conversation

JazzarKarim
Copy link
Collaborator

@JazzarKarim JazzarKarim commented Sep 18, 2023

Issue #: /bcgov/entity#17765

Description of changes:

  • Fixed the unit tests of CompleteResolution.vue after the latest hotfix has been deployed
  • Moved from happy-dom to jsdom
  • Fixed other tests
  • Removed isVitestRunning flag

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the bcrs-entities-create-ui license (Apache 2.0).

@JazzarKarim JazzarKarim self-assigned this Sep 18, 2023
@JazzarKarim
Copy link
Collaborator Author

/gcbrun

@bcregistry-sre
Copy link
Collaborator

Temporary Url for review: https://business-create-dev--pr-565-0n72txxt.web.app

@@ -574,7 +574,6 @@ export default class CompleteResolution extends Mixins(CommonMixin, DateMixin) {
// Note: the image file path did not resolve correctly when using the require function directly. In order
// to get the image path resolving correctly, needed to get the image context first and use that to build
// the final image file path
if (this.isVitestRunning) return ''
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis expressed his concerns with this flag. I removed it from here and elsewhere. Unit test was failing:
invalid url

After doing some research (mswjs/msw#1521), I was able to make the unit tests run by moving from happy-dom to jsdom.

@severinbeauvais We might want to do the same across all the UIs to stay consistent.

Note: The isVitestRunning method is still being used in one place (App.vue). For whatever reason, without it, one test fails which is expect(wrapper.findComponent(SbcFeeSummary).exists()).toBe(true). https://github.com/JazzarKarim/business-create-ui/blob/8fab017397867b6e99f862b4e848af095aac1bc3/tests/unit/App.spec.ts#L1094

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing to jsdom as needed? In theory, happy-dom is faster or better or something (happier?).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you mean leave jsdom here and keep happy-dom in the other UIs? Sure! That works too 🙌

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, leave the others until we have a reason to update them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, sounds good.

// eslint-disable-next-line accessor-pairs
Object.defineProperty(window.location, 'href', {
set (url: string) {
redirectedUrl = url
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was failing after moving from happy-dom to jsdom:
cannot redefine property

The new code fixes it. Reference: jestjs/jest#5124

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

@JazzarKarim
Copy link
Collaborator Author

/gcbrun

@bcregistry-sre
Copy link
Collaborator

Temporary Url for review: https://business-create-dev--pr-565-0n72txxt.web.app

@JazzarKarim JazzarKarim merged commit 52f0287 into bcgov:main Sep 19, 2023
5 checks passed
@@ -286,8 +285,8 @@ export default class Actions extends Mixins(CommonMixin, DateMixin, FilingTempla
this.setIsFilingPaying(false)
}
} else {
// don't call window.scrollTo during Vitest tests because happy-dom doesn't implement it
if (!this.isVitestRunning) window.scrollTo({ top: 0, behavior: 'smooth' })
// don't call window.scrollTo during Vitest tests because jsdom doesn't implement it
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, obsolete comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants