-
Notifications
You must be signed in to change notification settings - Fork 984
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
Fix component tests, upgrade Jest & friends, and a few other goodies #18276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
{:hooks {:analyze-call {utils.i18n/label utils.i18n/label}} | ||
{:hooks | ||
{:analyze-call | ||
{utils.i18n/label utils.i18n/label | ||
test-helpers.component/get-all-by-translation-text utils.i18n/label | ||
test-helpers.component/get-by-translation-text utils.i18n/label | ||
test-helpers.component/query-all-by-translation-text utils.i18n/label | ||
test-helpers.component/query-by-translation-text utils.i18n/label}} | ||
:linters {:status-im.linter/invalid-translation-keyword {:level :error}}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,7 @@ stdenv.mkDerivation { | |
"patchBuildIdPhase" | ||
"patchKeyChainPhase" | ||
"patchGlogPhase" | ||
"patchJestPhase" | ||
"installPhase" | ||
"installPhase" | ||
]; | ||
|
||
# First symlink all modules as is | ||
|
@@ -56,13 +55,6 @@ stdenv.mkDerivation { | |
'-Wl,--build-id=none' | ||
''; | ||
|
||
# Remove when we upgrade jest to 29 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less patches! YAY! |
||
patchJestPhase = '' | ||
substituteInPlace ./node_modules/react-native/jest/setup.js --replace \ | ||
'jest.now()' \ | ||
'Date.now' | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p $out | ||
cp -R node_modules $out/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,18 @@ | |
(let [selected (reagent/atom default-selected) | ||
{window-width :width} (rn/get-window) | ||
ref (atom nil)] | ||
(rn/use-effect #(js/setTimeout (fn [] | ||
(.scrollToIndex ^js @ref | ||
#js | ||
{:animated true | ||
:index (.indexOf colors/account-colors | ||
default-selected) | ||
:viewPosition 0.5})) | ||
50)) | ||
(rn/use-effect | ||
(fn [] | ||
(js/setTimeout | ||
(fn [] | ||
(let [index (.indexOf colors/account-colors default-selected)] | ||
(when (and @ref (>= index 0)) | ||
(some-> ^js @ref | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: The component test caught two potential bugs here, 1st that the index could be -1 and then |
||
(.scrollToIndex #js | ||
{:animated true | ||
:index index | ||
:viewPosition 0.5}))))) | ||
50))) | ||
[rn/flat-list | ||
{:ref #(reset! ref %) | ||
;; TODO: using :feng-shui? temporarily while b & w is being developed. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,7 @@ | |
[test-helpers.component :as h])) | ||
|
||
(h/describe "drawer-buttons" | ||
(h/before-each | ||
(fn [] | ||
(h/use-fake-timers))) | ||
|
||
(h/after-each | ||
(fn [] | ||
(h/clear-all-timers) | ||
(h/use-real-timers))) | ||
(h/setup-fake-timers) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: Fake timers are a nice feature. When I tried to enable them in more places, sometimes they could help make the tests more deterministic due to the elimination of some timing issues, but tests ended up failing for other reasons. It's a tool, and as such should be used only when needed. |
||
|
||
(h/test "the top heading and subheading render" | ||
(h/render [drawer-buttons/view | ||
|
@@ -37,7 +30,6 @@ | |
(-> (js/expect (h/get-by-text "bottom-sub-heading")) | ||
(.toBeTruthy))) | ||
|
||
|
||
(h/test "it clicks the top card" | ||
(let [event (h/mock-fn)] | ||
(with-redefs [safe-area/get-top (fn [] 10)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,10 @@ | |
{:time-frame :empty}]) | ||
(h/is-truthy (h/get-by-label-text :illustration))) | ||
|
||
(h/test "render 1 week wallet graph" | ||
;; NOTE: Throws error: | ||
;; _reactNative.Animated.timing(widthValue2, { | ||
;; Cannot read properties of undefined (reading 'timing') | ||
(h/test-skip "render 1 week wallet graph" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: Using For this particular test, as mentioned in the PR description, I couldn't fix it yet, but it's just one among so many fixed. We will find a way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep it's the way to go 👍 |
||
(h/render [wallet-graph/view | ||
{:time-frame :1-week | ||
:data (data 7)}]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice if we can call these with a shorthand arg, e.g
make component-test-watch --silent
or something to that effect.Also this pr already does so much, so not to worry about that here 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea @J-Son89, but to achieve this DX is impossible I think with
make
. The argument must be passed with a variable, likemake component-test-watch ARG1=--silent
. Maybe we should start to consider scripts instead to create a better CLI, we could even write some with babashka, something to consider cc @yqrashawn