-
Notifications
You must be signed in to change notification settings - Fork 45
Add infrastructure for VS Code extension tests #757
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
80ad154
First draft of simple extension test
juliasilge 1d6d2e9
Update dependencies
juliasilge d8a09cf
Oops didn't use yarn
juliasilge 6c79915
Iterate on tests
juliasilge f248b3e
Update build scripts to hopefully run and compile tests
juliasilge d59b40a
I keep accidentally using npm
juliasilge 3f19991
Make a simpler test and simpler `yarn test` setup
juliasilge 39ad547
Add some help for working from the root
juliasilge fa3e13b
First go at GH actions
juliasilge 979b1a8
Try using xvfb-run
juliasilge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,5 @@ public/dist | |
| .luarc.json | ||
| .ipynb_checkpoints | ||
| /.luarc.json | ||
| .vscode-test | ||
| *.vsix | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| out/ | ||
| *.vsix | ||
| test-out/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { defineConfig } from '@vscode/test-cli'; | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: 'test-out/*.test.js', | ||
| workspaceFolder: 'src/test/examples', | ||
| }, | ||
| ]); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,14 +14,25 @@ | |
| */ | ||
|
|
||
| import { runBuild } from "build"; | ||
| import * as glob from "glob"; | ||
|
|
||
| const args = process.argv; | ||
| const dev = args[2] === "dev"; | ||
| const test = args[2] === "test"; | ||
| const testFiles = glob.sync("src/test/*.ts"); | ||
|
|
||
| runBuild({ | ||
| const testBuildOptions = { | ||
| entryPoints: testFiles, | ||
juliasilge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| outdir: 'test-out', | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This creates the test |
||
| external: ['vscode'], | ||
| }; | ||
|
|
||
| const defaultBuildOptions = { | ||
| entryPoints: ['./src/main.ts'], | ||
| outfile: './out/main.js', | ||
| external: ['vscode'], | ||
| minify: !dev, | ||
| dev | ||
| }); | ||
| }; | ||
|
|
||
| runBuild(test ? testBuildOptions : defaultBuildOptions); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| title: "Hello, Quarto" | ||
| format: html | ||
| --- | ||
|
|
||
| ## Header | ||
|
|
||
| ```{python} | ||
| 1 + 1 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import * as vscode from "vscode"; | ||
| import * as assert from "assert"; | ||
| import { isQuartoDoc } from "../core/doc"; | ||
| import { VisualEditorProvider } from "../providers/editor/editor"; | ||
|
|
||
| suite("Toggle editors", () => { | ||
| test("Switch from source to visual", async () => { | ||
|
|
||
| await vscode.extensions.getExtension('quarto.quarto')!.activate(); | ||
juliasilge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const hello = vscode.Uri.file("/Users/juliasilge/Work/posit/quarto/apps/vscode/src/test/examples/hello.qmd"); | ||
juliasilge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await vscode.commands.executeCommand("vscode.open", hello); | ||
| const editor = vscode.window.activeTextEditor; | ||
| assert.strictEqual(isQuartoDoc(editor?.document), true); | ||
| assert.strictEqual(editor?.document.languageId, "quarto"); | ||
|
|
||
| const beforeSwitchingEditor = VisualEditorProvider.activeEditor(); | ||
| assert.strictEqual(beforeSwitchingEditor, undefined); | ||
|
|
||
| await vscode.commands.executeCommand("quarto.editInVisualMode"); | ||
| const afterSwitchingEditor = VisualEditorProvider.activeEditor(); | ||
| assert.strictEqual(afterSwitchingEditor?.textEditor, undefined); | ||
|
|
||
| assert.strictEqual(1, 2); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 where we tell the
vscode-testcli where to find the files.