1616 */
1717
1818import { expect } from 'chai' ;
19- import { window , commands , env , Uri , Terminal , Pseudoterminal , Event , TerminalDimensions , EventEmitter } from 'vscode' ;
20- import { START_DIDACT_COMMAND , sendTerminalText , gatherAllCommandsLinks , getContext , findTerminal } from '../../extensionFunctions' ;
19+ import { window , commands , env , Uri , Terminal } from 'vscode' ;
20+ import { START_DIDACT_COMMAND , sendTerminalText , gatherAllCommandsLinks , getContext } from '../../extensionFunctions' ;
2121import { didactManager } from '../../didactManager' ;
2222import { DidactUri } from '../../didactUri' ;
2323import { handleText } from '../../commandHandler' ;
@@ -27,6 +27,8 @@ const testMD = Uri.parse('vscode://redhat.vscode-didact?extension=demos/markdown
2727
2828const delayTime = 1500 ;
2929
30+ const WINDOWS : string = 'win32' ;
31+
3032suite ( 'stub out a tutorial' , ( ) => {
3133
3234 test ( 'that we can send an echo command to the terminal and get the response' , async ( ) => {
@@ -41,9 +43,9 @@ suite('stub out a tutorial', () => {
4143 if ( didactManager . active ( ) ) {
4244
4345 suite ( 'walk through all the sendNamedTerminalAString commands in the demo' , ( ) => {
44- const commands : any [ ] = gatherAllCommandsLinks ( ) . filter ( ( href ) => href . match ( / = v s c o d e .d i d a c t .s e n d N a m e d T e r m i n a l A S t r i n g & / g) ) ;
45- expect ( commands ) . to . not . be . empty ;
46- commands . forEach ( function ( href : string ) {
46+ const commandsToTest : any [ ] = gatherAllCommandsLinks ( ) . filter ( ( href ) => href . match ( / = v s c o d e .d i d a c t .s e n d N a m e d T e r m i n a l A S t r i n g & / g) ) ;
47+ expect ( commandsToTest ) . to . not . be . empty ;
48+ commandsToTest . forEach ( function ( href : string ) {
4749 test ( `test terminal command "${ href } "` , async ( ) => {
4850 const ctxt = getContext ( ) ;
4951 if ( ctxt ) {
@@ -77,16 +79,19 @@ async function validateTerminalResponse(terminalName : string, terminalText : st
7779 if ( term ) {
7880 console . log ( `-current terminal = ${ term ?. name } ` ) ;
7981 await sendTerminalText ( terminalName , terminalText ) ;
80- const resultValue = await waitUntil ( async ( ) => {
82+ await waitUntil ( async ( ) => {
8183 focusOnNamedTerminal ( terminalName ) ;
84+ if ( process . platform === WINDOWS ) {
85+ await delay ( 1000 ) ;
86+ }
8287 const result = await getTerminalOutput ( terminalName ) ;
8388 console . log ( `-validateTerminalResponse terminal output = ${ result } ` ) ;
8489 if ( terminalResponse ) {
8590 return result . includes ( terminalResponse ) ;
8691 } else {
8792 return result . includes ( terminalText ) ;
8893 }
89- } , 5000 ) ;
94+ } , 10000 ) ;
9095 findAndDisposeTerminal ( terminalName ) ;
9196 }
9297}
@@ -103,7 +108,7 @@ async function getTerminalOutput(terminalName : string) : Promise<string> {
103108 await executeAndWait ( 'workbench.action.terminal.copySelection' ) ;
104109 await executeAndWait ( 'workbench.action.terminal.clearSelection' ) ;
105110 const clipboard_content = await env . clipboard . readText ( ) ;
106- return clipboard_content . trim ( ) ; ;
111+ return clipboard_content . trim ( ) ;
107112}
108113
109114function delay ( ms : number ) {
0 commit comments