-
Notifications
You must be signed in to change notification settings - Fork 406
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
Feature: "SFDX: Open Documentation" (on web) #4414
Conversation
@@ -22,7 +22,7 @@ export const messages = { | |||
up_to_five_checkpoints: | |||
'You have %s of the maximum 5 enabled checkpoints. Remove or disable checkpoints until 5 or fewer are active.', | |||
no_enabled_checkpoints: | |||
'You don\'t have any checkpoints enabled. Enable a checkpoint and try again.', | |||
"You don't have any checkpoints enabled. Enable a checkpoint and try again.", |
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.
This change was auto-made when I saved.
@@ -13,7 +13,7 @@ | |||
* decorations, e.g., $(x) uses the https://octicons.github.com/ and should not | |||
* be localized | |||
* | |||
* If ommitted, we will assume _message. | |||
* If omitted, we will assume _message. |
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.
ha! that explains the 26 files...I was like 👀
const functionsPath = '/functions/'; | ||
|
||
const apexExtension = '.apex'; | ||
const soqlExtension = '.soql'; |
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.
The const above seem like they are reusable outside this command (esp the path/extension values). Think we could move these all to packages/salesforcedx-utils-vscode/src/constants.ts
?
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.
It turns out there are 11 files named, "constants.ts". There doesn't seem to be any occurrences of constants being using from other packages (like utils) so I placed the extension constants in packages/salesforcedx-vscode-core/src/constants.ts, Let me know if you think they should be in a different file.
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.
👍 that works. we can figure out the right place for all the constants later.
export const lwcDocUrl = | ||
'https://developer.salesforce.com/tools/vscode/en/lwc/writing'; | ||
export const functionsDocUrl = | ||
'https://developer.salesforce.com/tools/vscode/en/functions/overview'; |
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.
Should we add these to the messages files since they include the language?
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.
@sbudhirajadoc are there localized versions of these pages?
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 only ja and en are supported looking at the site (basically en or ja in the URL). @sbudhirajadoc please correctly me if I'm wrong.
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.
done
|
||
if (docUrl === '') { | ||
docUrl = defaultDocUrl; | ||
} |
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.
nice job handling the case where it doesn't get an active editor.
let openExternalStub: SinonStub; | ||
|
||
beforeEach(() => { | ||
sb = createSandbox(); |
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.
This should go outside the before each I think https://sinonjs.org/releases/latest/sandbox/
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.
That's not what we have in our code. Most(and I thought all) of our test code have the createSandbox() call in the beforeEach(). Searching the codebase, I found...
packages/salesforcedx-utils-vscode/test/unit/commands/channelService.test.ts
packages/salesforcedx-utils-vscode/test/unit/commands/commandletExecutor.test.ts
packages/salesforcedx-utils-vscode/test/unit/helpers/traceFlags.test.ts
.
.
.
There are some with it outside the beforeEach(), like in packages/salesforcedx-utils-vscode/test/unit/helpers/paths.test.ts, but the majority of our code has it in there.
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.
Yup, I think it's wrong in most of our code :)
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.
done
expect(openExternalStub.getCall(0).args[0].toString()).to.equal( | ||
defaultDocUrl | ||
); | ||
}); |
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.
nice tests. Are there any failure conditions we can verify? What happens if vscode.env.openExternal
throws?
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 wasn't able to think of any failure conditions, and I haven't found cases where openExternal fails.
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.
It's a corner case, but what if the user doesn't have a default browser? It's usually good to know the behaviour (via a unit test) even if we don't expect failure. It documents what we expect to happen. Like if we can't open a browser we should probably be outputting to the user that something went wrong verse just silently doing nothing.
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.
This is something we get automatically from VSC, and I think writing a unit test for it is writing a test validating VS Code, and doesn't validate our code. As an example, I ran this:
export async function forceOpenDocumentation() {
let docUrl = '';
const editor = vscode.window.activeTextEditor;
if (editor) {
const filePath = editor.document.fileName;
const extension = path.extname(filePath);
throw Error('OK dont do that');
.
.
.
And the user sees this:
...so we get the error notification "for free" from VS Code.
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.
cool. The main thing I'd have expected in the unit test would be validating that the error thrown by the called function is what is get thrown from our calling code. Granted there's not error handling here so we don't have anything extra to verify so I'm cool with just calling it a day. Error conditions is just always something to consider in unit tests.
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.
a few comments to consider. I can QE after you check em out.
…/salesforcedx-vscode into jb/open-documentation-on-web
const auraPath = '/force-app/main/default/aura/'; | ||
const apexClassesPath = '/force-app/main/default/classes/'; | ||
const lwcPath = '/force-app/main/default/lwc/'; | ||
const functionsPath = '/functions/'; |
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: FWIW I would have also put these in the constants file. Same deal where any time we need the auraPath we should always use the same value across the codebase. First other place it could be used is in the unit tests to build the stub responses.
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'll go and move them
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.
Thanks for the updates...started QE
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.
Command run: SFDX: Open Documentation
- ✅ Open Apex section from Apex code
- ✅ Aura from an Aura Component
- ✅ Main site from a random non-SF file
- ✅ Soql doc from soql builder
- ✅ Functions
- ✅ Lightning
…/salesforcedx-vscode into jb/open-documentation-on-web
What does this PR do?
New feature to open up our docs
What issues does this PR fix or reference?
#https://github.com/forcedotcom/easywriter/issues/85, @W-11683184, W-1168318r@