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

feat(#9413): update dynamic url widget to use MutationObserver #9414

Merged

Conversation

ChinHairSaintClair
Copy link
Contributor

@ChinHairSaintClair ChinHairSaintClair commented Sep 4, 2024

Description

This approach ensures that the assertion occurs as the last action on the macro-task queue, which seems to address our pipeline issue without introducing too much additional code.

Closes #9413

Code review checklist

  • Tested: Unit and/or e2e where appropriate

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@garethbowen garethbowen requested review from jkuester and removed request for garethbowen September 5, 2024 11:22
@garethbowen
Copy link
Member

@jkuester As I'm about to head on leave can I hand this over to you for review?

I've approved so I don't block the eventual merge...

Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

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

Approved to unblock.

@jkuester
Copy link
Contributor

jkuester commented Sep 6, 2024

@ChinHairSaintClair did you mean to push that last commit with the contact summary changes to this branch?

@ChinHairSaintClair
Copy link
Contributor Author

@jkuester no. Accidentally pushed the other branch's work to this one 🤦 .
Will have it fixed in the next few. Thank you for the heads up!

Copy link
Contributor

@jkuester jkuester left a comment

Choose a reason for hiding this comment

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

Very nice, thank you for these updates! (We are only 10+ years behind on removing the deprecated DOMSubtreeModified code....) 😅

I left one minor question about the type check, but besides that this should be good to go!

webapp/src/js/enketo/widgets/dynamic-url.js Outdated Show resolved Hide resolved
Comment on lines +50 to +53
setTimeout(() => {
expect($(DynamicUrlWidget.selector).attr('href')).to.equal(`http://google.com?q=${dynamic}`);
done();
}, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

So just for the record (for anyone that is looking into this in the future) the normal Angular way of testing async UI updates via fakeAsync does not seem to work here. And from reading online this seems to be expected (I guess the MutationObserver falls outside of what Angular has control of). In general the consensus seems to be against trying too hard to unit test MutationObserver behavior. However, since this works (at least for now) I say we ship it as is! 👍

@jkuester jkuester changed the title fix(#9413): add delay to dynamic url widget mutation test feat(#9413): update dynamic url widget to use MutationObserver Sep 9, 2024
Copy link
Contributor

@jkuester jkuester left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @ChinHairSaintClair!

@jkuester jkuester merged commit 3abd39b into medic:master Sep 9, 2024
26 checks passed
@ChinHairSaintClair ChinHairSaintClair deleted the add-deply-to-dynamic-url-test branch September 10, 2024 09:05
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.

Deprecated mutation event
3 participants