Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ public/dist
.luarc.json
.ipynb_checkpoints
/.luarc.json
.vscode-test
*.vsix
1 change: 1 addition & 0 deletions apps/vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
out/
*.vsix
test-out/
8 changes: 8 additions & 0 deletions apps/vscode/.vscode-test.mjs
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',
Copy link
Collaborator Author

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-test cli where to find the files.

workspaceFolder: 'src/test/examples',
},
]);
15 changes: 13 additions & 2 deletions apps/vscode/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
outdir: 'test-out',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This creates the test .js files in the directory where we can tell the vscode-test cli where to find them.

external: ['vscode'],
};

const defaultBuildOptions = {
entryPoints: ['./src/main.ts'],
outfile: './out/main.js',
external: ['vscode'],
minify: !dev,
dev
});
};

runBuild(test ? testBuildOptions : defaultBuildOptions);
8 changes: 6 additions & 2 deletions apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,9 @@
"build": "tsx build.ts",
"dev": "yarn run build dev",
"lint": "eslint src --ext ts",
"build-lang": "node syntaxes/build-lang"
"build-lang": "node syntaxes/build-lang",
"test-build": "yarn run build test",
"test": "vscode-test"
},
"dependencies": {
"axios": "^1.2.1",
Expand All @@ -1422,6 +1424,7 @@
"editor-core": "*",
"editor-server": "*",
"editor-types": "*",
"glob": "^11.0.3",
"highlight.js": "^11.7.0",
"js-yaml": "^4.1.0",
"lodash.debounce": "^4.0.8",
Expand Down Expand Up @@ -1459,7 +1462,8 @@
"@types/which": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"@vscode/test-electron": "^2.2.0",
"@vscode/test-cli": "^0.0.11",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^2.15.0",
"build": "*",
"esbuild": "^0.16.7",
Expand Down
10 changes: 10 additions & 0 deletions apps/vscode/src/test/examples/hello.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Hello, Quarto"
format: html
---

## Header

```{python}
1 + 1
```
26 changes: 26 additions & 0 deletions apps/vscode/src/test/toggle.test.ts
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();

const hello = vscode.Uri.file("/Users/juliasilge/Work/posit/quarto/apps/vscode/src/test/examples/hello.qmd");
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);
});
});
Loading
Loading