-
Notifications
You must be signed in to change notification settings - Fork 338
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
fix: Improve visibility of message to enable "Remote Debugging via USB" with web-ext run -t firefox-android #2038
Conversation
@sonalprabhu as a side note, don't worry about the audit-deps failure in the travis CI job, it is unrelated to the changes in this PR, we'll take care of that and you'll just need to rebase this PR once we merged a fix for it. |
Co-authored-by: Renovate Bot <bot@renovateapp.com>
…la#2034) Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sonalprabhu good job, this looks almost ready, there are just a few more tweaks needed (and a small fix to the test case, which is currently not failing even if it is expecting the wrong log level).
src/util/adb.js
Outdated
|
||
while (rdpUnixSockets.length === 0) { | ||
log.info(`\n${msg}\n`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we can remove the additional '\n' from this log message, they were meant to make that log to stand out and be more visible (which was clearly not enough :-P), now we are going to keep printing this message until we find the unix socket file and so we don't need this additional space.
Let's just change this into log.info(msg)
.
tests/unit/test-util/test.adb.js
Outdated
@@ -1129,6 +1131,44 @@ describe('utils/adb', () => { | |||
); | |||
}); | |||
|
|||
it('informs the user if remote debugging is not enabled', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, we don't really check if the remote debugging is enabled, we just wait for it to be available and so the description of this test may be a bit misleading, how about: it('reminds the user to enable remote debugging', ...
instead?
tests/unit/test-util/test.adb.js
Outdated
consoleStream.stopCapturing(); | ||
consoleStream.flushCapturedLogs(); | ||
consoleStream.startCapturing(); | ||
consoleStream.makeVerbose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the following tweaked version should be enough and slightly better:
consoleStream.flushCapturedLogs(); <--- clear the captured logs
consoleStream.makeVerbose(); <--- make the log verbose (to be able to assert the log level)
consoleStream.startCapturing(); <--- make sure that we start capturing logs
...
const promise = ... <-- get the promise
await assert.isRejected(promise, WebExtError); <--- wait the async function to complete
... // get the message that we expect by filtering the captured logs
consoleStream.stopCapturing(); <--- stop capturing we don't need it anymore
... // assertions on the expected message and log level
tests/unit/test-util/test.adb.js
Outdated
const maxDiscoveryTime = 50; | ||
const retryInterval = 10; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, let's remove this two consts and just pass the value in the call to adb.discoverRDPUnixSocket
(we are not using them for any assertion and so we can make this test a bit shorter by making this small optional change).
tests/unit/test-util/test.adb.js
Outdated
|
||
assert.ok(capturedMessages.some( | ||
(message) => ( | ||
message.match('[debug]') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly this assertion doesn't seem to be fully working, the log we are expecting is emitted with log.info
and so this test should actually fail and pass if we use '[info]' instead.
Another thing that we may also take care of is to make it clear when this test fails if the message wasn't found or wasn't emitted with the right log level, at the moment the two conditions are checked by a single assertion and so a failure would make it immediately clear.
Let's change this to get the message that we want using something like const foundMessage = consoleStream.caputedMessages.find((message) => message.includes(expectedMessage))
, then check the two conditions in separate assertions:
assert.ok(foundMessage);
assert.ok(foundMessage &&
foundMessage.includes(expectedLogLevel));
(NOTE: the foundMessage && foundMessage.includes
is mainly needed to make the flow type checker happy ;-))
@sonalprabhu the last CI jobs did fail because of some trailing spaces in test.adb.js (added when you added back the empty line that was previously there): You can fix that issue manually (by removing the trailing spaces and leave it as just an empty line as it was originally) or by running eslint --fix on that test file. |
it would be better to don't create a new one, I can help you to figure out how to handle the issue (if you have still any issue on this branch), describe me what is the issue that you are facing and I'll look into it and provide you more hints on how to deal with it. |
I cleared the issues with that. |
@sonalprabhu looks great! I just approved this version of the patch 🎉 |
Thanks a lot for your detailed guidelines :) |
Thanks so much for the patch, @sonalprabhu! 🙌 Your contribution has been added to our recognition wiki. Welcome onboard! We look forward to seeing you around the project. |
Fixes #1969
fix: Looped the "Check Remote Debugging is ON" warning and highlighted it