@@ -6,56 +6,59 @@ import { extension } from "./extension";
66
77const APPROX_TIME_TO_OPEN_VISUAL_EDITOR = 1600 ;
88
9- const quartoBasicsSuite = suite ( "Quarto basics" , ( ) => {
9+ suite ( "Quarto basics" , function ( ) {
1010 // Before we run any tests, we should copy any files that get edited in the tests to file under `exampleWorkspaceOutPath`
11- suiteSetup ( async ( ) => {
11+ suiteSetup ( async function ( ) {
1212 const didCopyFile = await copyFile ( exampleWorkspacePath ( 'hello.qmd' ) , exampleWorkspaceOutPath ( 'hello.qmd' ) ) ;
1313 assert . ok ( didCopyFile ) ;
1414 } ) ;
1515
16- test ( "Can open a Quarto document" , async ( ) => {
16+ test ( "Can open a Quarto document" , async function ( ) {
1717 const doc = await vscode . workspace . openTextDocument ( exampleWorkspaceOutPath ( "hello.qmd" ) ) ;
1818 const editor = await vscode . window . showTextDocument ( doc ) ;
1919
2020 assert . strictEqual ( editor ?. document . languageId , "quarto" ) ;
2121 assert . strictEqual ( isQuartoDoc ( editor ?. document ) , true ) ;
2222 } ) ;
2323
24- // don't run these in CI for now because we haven't figured out how to get the LSP to start
25- if ( ! process . env [ 'CI' ] ) {
26- // Note: the following tests may be flaky. They rely on waiting estimated amounts of time for commands to complete.
27- test ( "Can edit in visual mode" , async ( ) => {
28- const doc = await vscode . workspace . openTextDocument ( exampleWorkspaceOutPath ( "hello.qmd" ) ) ;
29- const editor = await vscode . window . showTextDocument ( doc ) ;
30-
31- // manually confirm visual mode so dialogue pop-up doesn't show because dialogues cause test errors
32- // and switch to visual editor
33- await vscode . commands . executeCommand ( "quarto.test_setkVisualModeConfirmedTrue" ) ;
34- await wait ( 300 ) ; // It seems necessary to wait around 300ms for this command to be done.
35- await vscode . commands . executeCommand ( "quarto.editInVisualMode" ) ;
36- await wait ( APPROX_TIME_TO_OPEN_VISUAL_EDITOR ) ;
37-
38- assert . ok ( await vscode . commands . executeCommand ( "quarto.test_isInVisualEditor" ) ) ;
39- } ) ;
40- // Note: this test runs after the previous test, so `hello.qmd` has already been touched by the previous
41- // test. That's okay for this test, but could cause issues if you expect a qmd to look how it
42- // does in `/examples`.
43- test ( "Roundtrip doesn't change hello.qmd" , async ( ) => {
44- const doc = await vscode . workspace . openTextDocument ( exampleWorkspaceOutPath ( "hello.qmd" ) ) ;
45- const editor = await vscode . window . showTextDocument ( doc ) ;
46-
47- const docTextBefore = doc . getText ( ) ;
48-
49- // switch to visual editor and back
50- await vscode . commands . executeCommand ( "quarto.test_setkVisualModeConfirmedTrue" ) ;
51- await wait ( 300 ) ;
52- await vscode . commands . executeCommand ( "quarto.editInVisualMode" ) ;
53- await wait ( APPROX_TIME_TO_OPEN_VISUAL_EDITOR ) ;
54- await vscode . commands . executeCommand ( "quarto.editInSourceMode" ) ;
55- await wait ( 300 ) ;
56-
57- const docTextAfter = doc . getText ( ) ;
58- assert . ok ( docTextBefore === docTextAfter ) ;
59- } ) ;
60- }
24+ // Note: the following tests may be flaky. They rely on waiting estimated amounts of time for commands to complete.
25+ test ( "Can edit in visual mode" , async function ( ) {
26+ // don't run this in CI for now because we haven't figured out how to get the LSP to start
27+ if ( process . env [ 'CI' ] ) this . skip ( ) ;
28+
29+ const doc = await vscode . workspace . openTextDocument ( exampleWorkspaceOutPath ( "hello.qmd" ) ) ;
30+ const editor = await vscode . window . showTextDocument ( doc ) ;
31+
32+ // manually confirm visual mode so dialogue pop-up doesn't show because dialogues cause test errors
33+ // and switch to visual editor
34+ await vscode . commands . executeCommand ( "quarto.test_setkVisualModeConfirmedTrue" ) ;
35+ await wait ( 300 ) ; // It seems necessary to wait around 300ms for this command to be done.
36+ await vscode . commands . executeCommand ( "quarto.editInVisualMode" ) ;
37+ await wait ( APPROX_TIME_TO_OPEN_VISUAL_EDITOR ) ;
38+
39+ assert . ok ( await vscode . commands . executeCommand ( "quarto.test_isInVisualEditor" ) ) ;
40+ } ) ;
41+ // Note: this test runs after the previous test, so `hello.qmd` has already been touched by the previous
42+ // test. That's okay for this test, but could cause issues if you expect a qmd to look how it
43+ // does in `/examples`.
44+ test ( "Roundtrip doesn't change hello.qmd" , async function ( ) {
45+ // don't run this in CI for now because we haven't figured out how to get the LSP to start
46+ if ( process . env [ 'CI' ] ) this . skip ( ) ;
47+
48+ const doc = await vscode . workspace . openTextDocument ( exampleWorkspaceOutPath ( "hello.qmd" ) ) ;
49+ const editor = await vscode . window . showTextDocument ( doc ) ;
50+
51+ const docTextBefore = doc . getText ( ) ;
52+
53+ // switch to visual editor and back
54+ await vscode . commands . executeCommand ( "quarto.test_setkVisualModeConfirmedTrue" ) ;
55+ await wait ( 300 ) ;
56+ await vscode . commands . executeCommand ( "quarto.editInVisualMode" ) ;
57+ await wait ( APPROX_TIME_TO_OPEN_VISUAL_EDITOR ) ;
58+ await vscode . commands . executeCommand ( "quarto.editInSourceMode" ) ;
59+ await wait ( 300 ) ;
60+
61+ const docTextAfter = doc . getText ( ) ;
62+ assert . ok ( docTextBefore === docTextAfter ) ;
63+ } ) ;
6164} ) ;
0 commit comments