-
Notifications
You must be signed in to change notification settings - Fork 292
Add test case for TypeSpec Extension #6802
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
base: main
Are you sure you want to change the base?
Conversation
All changed packages have been documented.
|
...oject/Azure.AI.DocumentTranslation/examples/2024-05-01/DocumentTranslate_MaximumSet_Gen.json
Outdated
Show resolved
Hide resolved
/** | ||
* Install plugins using the command | ||
*/ | ||
async function installExtensionForCommand(page: Page, extensionDir: string) { |
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.
Back to the previous comment I think this can be greatly simplified by using the command line to install the extension. This feels like a lot of code that is 100% irrelevant to testing our extensions
See how tsp code insall
cli command works to install the vsix via the command line https://github.com/microsoft/typespec/blob/main/packages/compiler/src/core/cli/install-vsix.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.
I see the vitest extension seems to have it even simpler https://github.com/vitest-dev/vscode/blob/fe76c0ff6926c63021ea1983dad96ad928dc27b2/test/e2e/helper.ts#L61
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.
@timotheeguerin Regarding the function installExtensionForCommand
, we have simplified it. This method completes the installation using the code command. The command is: code --install-extension ${vsixPath} --extensions-dir ${extensionDir}
. It is similar to the tsp code install cli
command you mentioned.
For the vitest extension, we also have this part of the code in our project. Currently, the logic involves passing an extensionPath after VS Code is launched. If the vsix file is placed in the extensionPath
beforehand, the extension will not work. The vsix file must be installed via the command line for the extension to function properly.
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.
ok but the point of that path is not to point to the vsix but just the local extension path, like when you debug locally, why is that not working
packages/typespec-vscode/test/extension/create-typespec.config.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Install plugins using the command | ||
*/ | ||
async function installExtensionForCommand(page: Page, extensionDir: string) { |
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.
ok but the point of that path is not to point to the vsix but just the local extension path, like when you debug locally, why is that not working
} | ||
|
||
async function closeVscode() { | ||
execSync("xdotool key Alt+F4"); |
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.
there must be a better way than doing alt f4 which is platform specific
import { test } from "./common/utils"; | ||
|
||
const __dirname = import.meta.dirname; | ||
const projectRoot = path.resolve(__dirname, "./"); |
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 the project root?
import { pressEnter, retry, screenshot, sendKeys, sleep } from "./utils"; | ||
|
||
const __dirname = import.meta.dirname; | ||
const projectRoot = path.resolve(__dirname, "../"); |
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.
inconsitnet across all files. Keep a single projectRoot in utils that actually points to the projectroot(where package.json is)
* @param {string} text The text to input | ||
*/ | ||
export function sendKeys(text: string) { | ||
execSync(`xdotool type --delay 100 "${text}"`); |
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 feels worse, now need this extra tool installed which doesn't seem like would work on windows.
We should never have a test in CI you cannot test locally.
Back again at the same question can you not use vscode.commands.executeCommand
and pass an arg of the folder where you want to do it
https://code.visualstudio.com/api/references/vscode-api#commands.executeCommand
and just have the command take that folder optionally and only show the picker if not provided
Deploy the UI test case demo
Create TypeSpec Project - Generic REST API
to the CI/CD pipeline.