fix(CDVStatusBarTests): wait for native exec#1680
Conversation
- Sometimes actions will fail due to race conditions on the `testStatusBarBackgroundColor*`-methods. `evaluateJavaScript` completes once JavaScript has executed, but `cordova.exec(...)` queues the native `StatusBarInternal.setBackgroundColor` command asynchronously. The test then immediately reads `statusBarBackgroundColor`, potentially before the native command runs. - Generated-By: GPT-5.5 Medium
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1680 +/- ##
=======================================
Coverage 81.76% 81.76%
=======================================
Files 17 17
Lines 5159 5159
=======================================
Hits 4218 4218
Misses 941 941 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dpogue
left a comment
There was a problem hiding this comment.
oooh, thanks for tracking down the root cause of these random failures!
This is probably fine in the short term for this specific test case, but I wonder if it might be good to have a generic helper that waits until the command queue is empty (i.e., all pending plugin exec calls have been processed)
Would make sense. But I don't know how this could be done :) |
- Add a reusable test helper that evaluates JavaScript and waits until Cordova exec calls queued by that JavaScript have reached native code. - StatusBar tests now use this helper before asserting native status bar state, avoiding races where evaluateJavaScript completes before the native StatusBarInternal command has run. Also register the deviceready expectation before loading the start page. - Generated-By: ChatGPT 5.5
waitForStatusBarBackgroundColor|
I created a generic solution with the help of ChatGPT:
|
Platforms affected
Motivation and Context
testStatusBarBackgroundColor*-methods.evaluateJavaScriptcompletes once JavaScript has executed, butcordova.exec(...)queues the nativeStatusBarInternal.setBackgroundColorcommand asynchronously. The test then immediately readsstatusBarBackgroundColor, potentially before the native command runs.Description
Testing
Checklist
(platform)if this change only applies to one platform (e.g.(android))