This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Fix quick open mochi#4496
Merged
wldcordeiro merged 3 commits intoOct 27, 2017
Merged
Conversation
wldcordeiro
force-pushed
the
fix-quick-open-mochi
branch
from
October 26, 2017 14:52
4249370 to
eb16cb7
Compare
jasonLaster
reviewed
Oct 26, 2017
jasonLaster
left a comment
Contributor
There was a problem hiding this comment.
left some comments. Sorry for being a nit, trying to use these tests as learning opportunities.
| ## Debugging Tips | ||
|
|
||
| * Run your mochitest with `yarn mochid <filename>` and add a `debugger` statement to your test before or after a failure. | ||
| * Go back to the development server and watch the Redux logs (either with the Redux Devtools or by setting action logging on in your [local config][local-config].) as you perform your mochitest step by step. Watch the actions that fire. Sometimes all you need is a `waitForDispatch("THE_ACTION")` to ensure enough time has passed for your assertion to be true. |
Contributor
There was a problem hiding this comment.
that should now always be on for tests? maybe not though...
Contributor
There was a problem hiding this comment.
waitForDispatch(dbg, "THE_ACTION")
| is(resultCount(dbg), 2); | ||
| pressKey(dbg, "Down"); | ||
| pressKey(dbg, "Enter"); | ||
| await waitForDispatch(dbg, "SELECT_SOURCE"); |
Contributor
There was a problem hiding this comment.
maybe we can make waitForSelectedSource smarter... that will help make the tests easier to write
diff --git a/src/test/mochitest/head.js b/src/test/mochitest/head.js
index 51d659f..e57ff70 100644
--- a/src/test/mochitest/head.js
+++ b/src/test/mochitest/head.js
@@ -218,16 +218,26 @@ async function waitForElement(dbg, selector) {
return findElementWithSelector(dbg, selector);
}
-function waitForSelectedSource(dbg, sourceId) {
+function waitForSelectedSource(dbg, url) {
return waitForState(dbg, state => {
const source = dbg.selectors.getSelectedSource(state);
- const isLoaded =
- source && source.has("loadedState") && sourceUtils.isLoaded(source);
- if (sourceId) {
- return isLoaded && sourceId == source.get("id");
+ const isLoaded = source && sourceUtils.isLoaded(source);
+ if (!isLoaded) {
+ return false;
}
- return isLoaded;
+ if (!url) {
+ return true;
+ }
+
+ const newSource = findSource(dbg, url)
+ if (newSource.id != source.get("id")) {
+ return false;
+ }
+
+ const symbols = dbg.selectors.getSymbolsForSource(state, source.id)
+ return symbols;
+
}, "selected source");
}
|
|
||
| ## Debugging Tips | ||
|
|
||
| * Run your mochitest with `yarn mochid <filename>` and add a `debugger` statement to your test before or after a failure. |
Contributor
There was a problem hiding this comment.
screenshots of the test paused in the debugger code and the test code would help show what it is happening
wldcordeiro
force-pushed
the
fix-quick-open-mochi
branch
2 times, most recently
from
October 26, 2017 23:20
12c534c to
f0b7475
Compare
There were some race issues with the quick open mochitest assertions that this cleared up.
Added some tips to the mochitest debugging docs based on experience debugging race issue. Also Prettier fixed some things.
wldcordeiro
force-pushed
the
fix-quick-open-mochi
branch
from
October 26, 2017 23:22
f0b7475 to
a41e079
Compare
wldcordeiro
force-pushed
the
fix-quick-open-mochi
branch
from
October 27, 2017 00:15
a41e079 to
96777b5
Compare
wldcordeiro
commented
Oct 27, 2017
| } | ||
|
|
||
| // wait for async work to be done | ||
| return dbg.selectors.hasSymbols(state, source.toJS()); |
Contributor
Author
There was a problem hiding this comment.
@jasonLaster you didn't have the toJS call here which is what was making us hang.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Associated Issue: N/A
Summary of Changes
Test Plan
Example test plan:
yarn mochi browser_dbg-quick-open.js