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

test(e2e): detect redbox in ci #5233

Closed
wants to merge 5 commits into from
Closed

Conversation

mikehardy
Copy link
Collaborator

Description

Attempt to verify after each test that the main app is still displaying, to make sure we don't have a redbox in place or similar

This is a WIP at the moment as it has E2E flakiness noted below, but I have it working locally so I wanted to make sure it was at least posted on github just in case.

Related issues

Related - #5225 - issue generated a redbox and CI is blind to redboxes

Release Summary

Conventional commits - rebase merge

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

The whole PR is a test. That said, you should have a test that triggers a redbox to verify redbox detection is working

Note that right now this is flaky on CI, unknown reasons why but it appears to be that the heuristic-based Espresso Root View detector (used by Detox under the covers to do layout matching and determine main app visibility) is sometimes picking the wrong RootView so we aren't matching against the app layout. It's possible the screen is locked or that there is an ANR or welcome dialog or similar confusing it.

Related information:


Think react-native-firebase is great? Please consider supporting the project with any of the below:

Access to the collection of TaskExecutors wasn't correctly synchronized
in all places

Fixes #5225
previously they were the ugliest, my fault
This correctly identifies that #5225 can happen, where previously
it passed CI with no problem. Tested by applying / removing the fix
for 5225 and now CI will fail if a redbox ever happens again
@vercel
Copy link

vercel bot commented Apr 29, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/invertase/react-native-firebase/Fx1cyaqi6wnoMFJBD2jGapfEJ6Y6
✅ Preview: https://react-native-f-git-mikehardy-detect-redbox-in-ci-in-6b9f53.vercel.app

@mikehardy mikehardy marked this pull request as draft April 29, 2021 16:14
@mikehardy
Copy link
Collaborator Author

Pre-flake - working on a view matcher test and battling this:


Thu, 29 Apr 2021 03:32:21 GMT   1) "after each" hook: afterEach for "should be an array":
Thu, 29 Apr 2021 03:32:21 GMT      Test Failed: Waited for the root of the view hierarchy to have window focus and not request layout for 10 seconds. If you specified a non default root matcher, it may be picking a root that never takes focus. Root:
Thu, 29 Apr 2021 03:32:21 GMT Root{application-window-token=android.view.ViewRootImpl$W@20d31b1, window-token=android.view.ViewRootImpl$W@20d31b1, has-window-focus=false, layout-params-type=1, layout-params-string={(0,0)(fillxfill) sim={adjust=resize forwardNavigation} ty=BASE_APPLICATION wanim=0x10302fe
Thu, 29 Apr 2021 03:32:21 GMT detox[4366] ERROR: [cli.js] Error: Command failed: mocha --config e2e/.mocharc.js --cleanup --configuration android.emu.debug --grep :ios: --invert --use-custom-logger true e2e
Thu, 29 Apr 2021 03:32:21 GMT   fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
Thu, 29 Apr 2021 03:32:21 GMT
Thu, 29 Apr 2021 03:32:21 GMT   pfl=FORCE_DRAW_STATUS_BAR_BACKGROUND FIT_INSETS_CONTROLLED
Thu, 29 Apr 2021 03:32:21 GMT   fitSides=}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=false, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params={(0,0)(fillxfill) sim={adjust=resize forwardNavigation} ty=BASE_APPLICATION wanim=0x10302fe
Thu, 29 Apr 2021 03:32:21 GMT   fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
Thu, 29 Apr 2021 03:32:21 GMT   pfl=FORCE_DRAW_STATUS_BAR_BACKGROUND FIT_INSETS_CONTROLLED
Thu, 29 Apr 2021 03:32:21 GMT   fitSides=}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}}
Thu, 29 Apr 2021 03:32:21 GMT   Error: Test Failed: Waited for the root of the view hierarchy to have window focus and not request layout for 10 seconds. If you specified a non default root matcher, it may be picking a root that never takes focus. Root:
Thu, 29 Apr 2021 03:32:21 GMT   Root{application-window-token=android.view.ViewRootImpl$W@20d31b1, window-token=android.view.ViewRootImpl$W@20d31b1, has-window-focus=false, layout-params-type=1, layout-params-string={(0,0)(fillxfill) sim={adjust=resize forwardNavigation} ty=BASE_APPLICATION wanim=0x10302fe
Thu, 29 Apr 2021 03:32:21 GMT     fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
Thu, 29 Apr 2021 03:32:21 GMT     pfl=FORCE_DRAW_STATUS_BAR_BACKGROUND FIT_INSETS_CONTROLLED
Thu, 29 Apr 2021 03:32:21 GMT     fitSides=}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=false, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params={(0,0)(fillxfill) sim={adjust=resize forwardNavigation} ty=BASE_APPLICATION wanim=0x10302fe
Thu, 29 Apr 2021 03:32:21 GMT     fl=LAYOUT_IN_SCREEN LAYOUT_INSET_DECOR SPLIT_TOUCH HARDWARE_ACCELERATED DRAWS_SYSTEM_BAR_BACKGROUNDS
Thu, 29 Apr 2021 03:32:21 GMT     pfl=FORCE_DRAW_STATUS_BAR_BACKGROUND FIT_INSETS_CONTROLLED

May be related to a few things

recommended to add

    @Before
    public void unlockScreen() {
        final TaskCreateActivity activity = activityRule.getActivity();
        Runnable wakeUpDevice = new Runnable() {
            public void run() {
                activity.getWindow().addFlags(
                        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                                | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            }
        };
        activity.runOnUiThread(wakeUpDevice);
    }

to Activity for test

@codecov
Copy link

codecov bot commented Apr 29, 2021

Codecov Report

Merging #5233 (51834a9) into master (574f691) will decrease coverage by 3.61%.
The diff coverage is n/a.

❗ Current head 51834a9 differs from pull request most recent head b9e8b1f. Consider uploading reports for the commit b9e8b1f to get more accurate results

@@            Coverage Diff             @@
##           master    #5233      +/-   ##
==========================================
- Coverage   88.86%   85.26%   -3.60%     
==========================================
  Files         109      109              
  Lines        3743     3743              
  Branches      360      360              
==========================================
- Hits         3326     3191     -135     
- Misses        370      481     +111     
- Partials       47       71      +24     

@mikehardy
Copy link
Collaborator Author

https://stackoverflow.com/questions/39457305/android-testing-waited-for-the-root-of-the-view-hierarchy-to-have-window-focus

  • can auto-disable some dialogs but not ANRs, ANRs can be disabled with some code though

Also maybe https://github.com/linkedin/test-butler for techniques, but that won't work on Google APIs emulator images (which we require for firebase)

@mikehardy
Copy link
Collaborator Author

I think this is unworkable here. May take the idea to jet-next. It's really hard to do 🤷

@mikehardy mikehardy closed this Nov 13, 2021
@mikehardy mikehardy deleted the @mikehardy/detect-redbox-in-ci branch November 13, 2021 21:04
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.

1 participant