debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[SourceTree] add integration tests for keyboard arrow behavior

Open jasonLaster opened this issue 8 years ago • 12 comments

We should test what happens when the user:

  • left arrow on a closed directory
  • left arrow on an open directory
  • left arrow on a source
  • right arrow on a closed directory
  • right arrow on an open directory
  • right arrow on a source
  • up arrow on a directory
  • up arrow on a source
  • down arrow on a directory
  • down arrow on a source
  • down arrow at the bottom of the tree
  • up arrow at the top of the tree

jasonLaster avatar Jul 25 '18 20:07 jasonLaster

While someone is writing all these assertions here a few more that are helpful beyond just arrow keys:

  • home takes you to the first node of the tree
  • end takes you to the last node of the tree
  • enter toggles the current selected node state if a parent item or trigger the nodes action if it is a leaf.

It also may be prudent to test things such as, right arrow on a leaf node does nothing. Try to cover as much as the WAI-ARIA guidelines for a tree view as possible in testing. That way changes later don't do something unexpected without setting a bell off.

Garbee avatar Jul 26 '18 00:07 Garbee

Hey @jasonLaster, this looks like it could be a good first issue to take on. I have a good idea of how react components work in general, but I haven't written any integration tests for a react codebase before. This looks like it could be a great introduction into that. Mind if I take a go at this?

This is the component we want to test, right?

WenInCode avatar Aug 26 '18 04:08 WenInCode

Yep. You could write the test with jest. Or mochitests. We document both in the docs dir. Mochitests in some ways is better, but harder to setup.

On Sun, Aug 26, 2018, 12:37 AM Tyler Wendlandt [email protected] wrote:

Hey @jasonLaster https://github.com/jasonLaster, this looks like it could be a good first issue to take on. I have a good idea of how react components work in general, but I haven't written any integration tests for a react codebase before. This looks like it could be a great introduction into that. Mind if I take a go at this?

This https://github.com/devtools-html/debugger.html/blob/master/src/components/PrimaryPanes/SourcesTree.js is the component we want to test, right?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/devtools-html/debugger.html/issues/6700#issuecomment-416013454, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPiYmiD6-_CXfTDAp389AxEv330DGEnks5uUiYWgaJpZM4Vgtoh .

jasonLaster avatar Aug 26 '18 11:08 jasonLaster

/claim

WenInCode avatar Aug 26 '18 14:08 WenInCode

Thanks for claiming the issue! :wave:

!!! Please check your email and confirm the invitation

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Aug 26 '18 14:08 claim

@jasonLaster Hey again,

I spent some time reading up on mochitests, and I watched the video you have on youtube about debugging & mochitests. I thought the video was great. I am running into an issue getting mochitests to run properly though.

I have successfully ran ./bin/prepare-mochitests-dev and when I first ran the existing sources tests they passed:

// I also ran it in headless
yarn mochid browser_dbg-sources

I tried adding an await waitForever() to the end of the existing task and running yarn run copy followed by re-running the tests, but when the browser opened the debugger never loaded, and then the tests timed out. I've tried removing the code I added and re-copying the assets, but now test won't run anymore.

I've also tried running the test from the firefox directory.

./mach mochitest browser_dbg-sources

It still times out. I found these logs to be of interest, but I am not sure what would be causing it.

 0:03.08 INFO *** Start BrowserChrome Test Results ***
 0:03.09 INFO checking window state
 0:03.15 TEST_START: devtools/client/debugger/new/test/mochitest/browser_dbg-sources-named-eval.js
 0:03.21 INFO Entering test bound
 0:03.21 INFO Adding a new tab with URL: http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html
 0:03.55 INFO Console message: [JavaScript Warning: "Loading failed for the <script> with source “http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/nested/deeper/deeper-source.js”." {file: "http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html" line: 23}]
 0:03.56 INFO Tab added and finished loading
 0:03.56 INFO Opening the toolbox
 0:04.19 INFO Console message: [JavaScript Warning: "Removed unsafe attribute. Element: svg. Attribute: xlink." {file: "resource://devtools/shared/base-loader.js -> resource://devtools/client/shared/vendor/react-dom.js" line: 5811}]
 0:04.19 INFO Console message: [JavaScript Warning: "Removed unsafe attribute. Element: svg. Attribute: xlink." {file: "resource://devtools/shared/base-loader.js -> resource://devtools/client/shared/vendor/react-dom.js" line: 5811}]
 0:04.19 INFO Console message: [JavaScript Warning: "Removed unsafe attribute. Element: svg. Attribute: xmlns." {file: "resource://devtools/shared/base-loader.js -> resource://devtools/client/shared/vendor/react-dom.js" line: 5811}]

Is this something you've seen before? Any tips on how to proceed or where to start looking?

WenInCode avatar Aug 28 '18 04:08 WenInCode

Here are the key lines to me:

INFO Adding a new tab with URL: http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html
 0:03.55 INFO Console message: [JavaScript Warning: "Loading failed for the <script> with source “http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/nested/deeper/deeper-source.js”." {file: "http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html" line: 23}]

Where is http://example.com coming from? Search your tests to see if that is something you're programming in. Because that most certainly is not where you're trying to test. You need to point it to open your test file either directly or from an internal web server running for the test suite.

Garbee avatar Aug 28 '18 11:08 Garbee

@Garbee deeper source is a test for a failing source. Example.com comes from mochitest

jasonLaster avatar Aug 28 '18 13:08 jasonLaster

@WenInCode try doing cd firefox; ./mach build; ./mach mochitest devtools/client/debugger/new

also feel free to join our slack https://devtools-html-slack.herokuapp.com/

jasonLaster avatar Aug 28 '18 13:08 jasonLaster

Unfortunately saw similar errors with that. I noticed if I remove the firefox subdirectory and then re run ./bin/prepare-mochitests-dev I can run tests fine. But as soon as I make a change, say adding await waitForever() to the end of a test, it starts to time out. If I remove my changes and re run yarn run copy they continue to time out.

twendlan@Tylers-MBP-2 debugger.html (master) $ yarn mochih browser_dbg-sources
yarn mochih v0.28.4
$ yarn mochi -- --headless -- "browser_dbg-sources"
./mach mochitest --log-tbpl=- --headless /usr/local/bin/iojs /Users/twendlan/Development/Projects/debugger.html/node_modules/.bin/mochii browser_dbg-sources
TEST-START browser_dbg-sources-named-eval.js
   Adding a new tab with URL: http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html
  JS warning:
   "Loading failed for the <script> with source “http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/nested/deeper/deeper-source.js”." {file: "http://example.com/browser/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html" line: 23}]
   1 ADD_SOURCES server1.conn0.child1/source28 - doc-sources.html
   2 ADD_SOURCES
     - server1.conn0.child1/source25 - simple1.js
     - server1.conn0.child1/source26 - simple2.js
     - server1.conn0.child1/source27 - long.js
     - server1.conn0.child1/source29 - nested-source.js
 TEST-UNEXPECTED-FAIL Test timed out

I'm going to see about reaching out to someone for a quick pairing session in slack. Maybe that will help diagnose the issue.

WenInCode avatar Aug 28 '18 20:08 WenInCode

hey @WenInCode sorry. i think this was my fault. try rebasing your branch, yarn install, and re-running prepare mochitest :/

jasonLaster avatar Aug 28 '18 21:08 jasonLaster

@jasonLaster I think that did the trick! Thanks so much

WenInCode avatar Aug 28 '18 23:08 WenInCode