Skip to content

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

Open
wants to merge 65 commits into
base: main
Choose a base branch
from

Conversation

v-xuto
Copy link

@v-xuto v-xuto commented Apr 1, 2025

Deploy the UI test case demo Create TypeSpec Project - Generic REST API to the CI/CD pipeline.

@microsoft-github-policy-service microsoft-github-policy-service bot added the ide Issues for VS, VSCode, Monaco, etc. label Apr 1, 2025
Copy link
Contributor

github-actions bot commented Apr 1, 2025

All changed packages have been documented.

  • typespec-vscode
Show changes

typespec-vscode - feature ✏️

Add test case for TypeSpec Extension

@v-xuto v-xuto changed the title Add test case for TypeSpec Extension Add test case for TypeSpec Extension (Do not merge) Apr 2, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the stale Mark a PR that hasn't been recently updated and will be closed. label May 18, 2025
@msyyc msyyc removed the stale Mark a PR that hasn't been recently updated and will be closed. label May 19, 2025
/**
* Install plugins using the command
*/
async function installExtensionForCommand(page: Page, extensionDir: string) {
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

@v-xuto v-xuto Jul 4, 2025

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.

Copy link
Member

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

@v-xuto v-xuto requested a review from timotheeguerin July 7, 2025 05:01
/**
* Install plugins using the command
*/
async function installExtensionForCommand(page: Page, extensionDir: string) {
Copy link
Member

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");
Copy link
Member

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, "./");
Copy link
Member

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, "../");
Copy link
Member

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}"`);
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide Issues for VS, VSCode, Monaco, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants