Skip to content
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 into
firefox-devtools:masterfrom
wldcordeiro:fix-quick-open-mochi
Oct 27, 2017
Merged

Fix quick open mochi#4496
wldcordeiro merged 3 commits into
firefox-devtools:masterfrom
wldcordeiro:fix-quick-open-mochi

Conversation

@wldcordeiro

@wldcordeiro wldcordeiro commented Oct 26, 2017

Copy link
Copy Markdown
Contributor

Associated Issue: N/A

Summary of Changes

  • Fix up the quick open mochitest that had a failure. Not 100% certain if it was just racy before or if this was to adjust to changes from @jasonLaster's recent work. 🙁
  • Doc some tips based on what I did here.
  • Prettier did its thing here.

Test Plan

Example test plan:

  • yarn mochi browser_dbg-quick-open.js

@jasonLaster jasonLaster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments. Sorry for being a nit, trying to use these tests as learning opportunities.

Comment thread docs/mochitests.md Outdated
## 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that should now always be on for tests? maybe not though...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitForDispatch(dbg, "THE_ACTION")

is(resultCount(dbg), 2);
pressKey(dbg, "Down");
pressKey(dbg, "Enter");
await waitForDispatch(dbg, "SELECT_SOURCE");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
 }
 

Comment thread docs/mochitests.md Outdated

## Debugging Tips

* Run your mochitest with `yarn mochid <filename>` and add a `debugger` statement to your test before or after a failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screenshots of the test paused in the debugger code and the test code would help show what it is happening

@wldcordeiro
wldcordeiro force-pushed the fix-quick-open-mochi branch 2 times, most recently from 12c534c to f0b7475 Compare October 26, 2017 23:20
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.
}

// wait for async work to be done
return dbg.selectors.hasSymbols(state, source.toJS());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonLaster you didn't have the toJS call here which is what was making us hang.

@wldcordeiro
wldcordeiro merged commit 0fa40b8 into firefox-devtools:master Oct 27, 2017
@wldcordeiro
wldcordeiro deleted the fix-quick-open-mochi branch October 27, 2017 01:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants