-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Ponyfill clock functions via ponyfill
prop
#4662
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compulim
changed the title
[DRAFT] Allow ponyfilling global clock functions
[DRAFT] Ponyfill clock functions via Mar 9, 2023
ponyfill
prop
compulim
changed the title
[DRAFT] Ponyfill clock functions via
Ponyfill clock functions via Mar 9, 2023
ponyfill
propponyfill
prop
compulim
requested review from
a-b-r-o-w-n,
cwhitten,
srinaath,
tdurnford and
beyackle2
as code owners
March 10, 2023 00:34
compulim
added
p1
Painful if we don't fix, won't block releasing
area-accessibility
labels
Mar 23, 2023
tdurnford
previously approved these changes
Mar 29, 2023
compulim
force-pushed
the
feat-clock-ponyfill
branch
from
March 30, 2023 18:26
9578d3a
to
478a2d5
Compare
tdurnford
approved these changes
Mar 31, 2023
This was referenced Apr 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Added
ponyfill
prop to<ReactWebChat>
/<Composer>
andcreateStoreWithOptions
, by @compulim, in PR #4662Fixed
Description
axe-core
usesetTimeout
from global scope.However, for our tests, we are using fake timer (
lolex
) installed at global scope. Thus, our globally installed fake timer is intervening the operation ofaxe-core
.We are adding support to pass ponyfill of clock functions. In our code, instead of using
setTimeout
from global, we will use a ponyfill version ofsetTimeout
, and fallback to globalsetTimeout
.This
ponyfill
prop/options is available on<ReactWebChat>
andcreateStore
.However, since not all of our dependencies support
ponyfill
, it's use is very limited and only targeting development scenarios where fake timer is needed.To-dos
eslint-plugin-html
to extract inlined JavaScript code for ESLint and verifylolex.install
is not usedShould we check if store is ponyfilled, but UI is not, and vice versa?Also, forDirectLineEmulator
to detect if thestore
is ponyfilledDesign
We added
.eslintrc.yml/rules/no-restricted-globals
to make sure our code don't use most clock functions from global.As we are not using high-resolution timer, we are not supporting ponyfill of
window.performance
object.createStore
is internally called by<Composer>
and also externally called by web devs. We are adding a newcreateStoreWithOptions
to allow ponyfill to be passed tocreateStore
.Despite some
new Date()
are purely for formatting, such asnew Date('2023-03-03T12:34:56.000Z').getTime()
. For consistency, we are using the ponyfilled version ofDate
even for formatting.We only pass ponyfill to where it is supported. As none of our dependencies support ponyfill clock functions, that means, the fake timers would only applies to code of Web Chat. For example, the auto-scroll package will not use this ponyfill.
Specific Changes
<PonyfillComposer>
andusePonyfill(): [GlobalThisClock]
createStoreWithOptions
to pass ponyfillno-restricted-globals
rule to disable global clockuseLastTypingAt
,useLocalize
and<Localize>
undefined
valuesuseActiveTyping
anduseTrackTiming
whileConnected
DirectLineEmulator.actPostActivity(() => Promise<void>)
to manipulate outgoing message via send box, in addition to, viaemulateOutgoingActivity
activity
createDirectLineEmulator
will nowcreateStore
DirectLineEmulator
, they are creating Redux store without customizing itAsia/Hong_Kong
timezone to reduce issues with daylight saving timeCHANGELOG.md
Review Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index
)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.json
andpackage-lock.json
reviewed