Skip to content
This repository was archived by the owner on May 11, 2022. It is now read-only.

Commit 267d275

Browse files
authored
FUSETOOLS2-1014 - adding small delay (#441)
* FUSETOOLS2-1014 - updates to use waitUntil * refactor validateTerminalResponse Signed-off-by: Brian Fitzpatrick <[email protected]>
1 parent fea5109 commit 267d275

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

src/test/suite/stubDemoTutorial.test.ts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import { START_DIDACT_COMMAND, sendTerminalText, gatherAllCommandsLinks, getCont
2121
import { didactManager } from '../../didactManager';
2222
import { DidactUri } from '../../didactUri';
2323
import { handleText } from '../../commandHandler';
24+
import { waitUntil } from 'async-wait-until';
2425

2526
const testMD = Uri.parse('vscode://redhat.vscode-didact?extension=demos/markdown/didact-demo.didact.md');
2627

27-
const delayTime = 1000;
28+
const delayTime = 1500;
2829

2930
suite('stub out a tutorial', () => {
3031

@@ -58,7 +59,7 @@ suite('stub out a tutorial', () => {
5859
expect(outputs).length.to.be.at.least(2);
5960
const terminalName = outputs[0];
6061
const terminalString = outputs[1];
61-
await validateSimpleTerminalResponse(terminalName, terminalString);
62+
await validateTerminalResponse(terminalName, terminalString);
6263
}
6364
});
6465
});
@@ -69,38 +70,23 @@ suite('stub out a tutorial', () => {
6970

7071
});
7172

72-
async function validateSimpleTerminalResponse(terminalName : string, terminalText : string) {
73-
console.log(`validateSimpleTerminalResponse terminal ${terminalName} executing text ${terminalText}`);
73+
async function validateTerminalResponse(terminalName : string, terminalText : string, terminalResponse? : string) {
74+
console.log(`validateTerminalResponse terminal ${terminalName} executing text ${terminalText}`);
7475
const term = window.createTerminal(terminalName);
7576
expect(term).to.not.be.null;
7677
if (term) {
7778
console.log(`-current terminal = ${term?.name}`);
7879
await sendTerminalText(terminalName, terminalText);
79-
await delay(delayTime);
80-
const term2 = focusOnNamedTerminal(terminalName);
81-
await delay(delayTime);
82-
let result = await getTerminalOutput(terminalName);
83-
console.log(`-validateSimpleTerminalResponse terminal output = ${result}`);
84-
85-
// we're just making sure we get something back and can see the text we put into the terminal
86-
expect(result).to.include(terminalText);
87-
findAndDisposeTerminal(terminalName);
88-
}
89-
}
90-
91-
async function validateTerminalResponse(terminalName : string, terminalText : string, terminalResponse : string) {
92-
console.log(`validateTerminalResponse terminal ${terminalName} executing text ${terminalText} and looking for response ${terminalResponse}`);
93-
const term = window.createTerminal(terminalName);
94-
expect(term).to.not.be.null;
95-
if (term) {
96-
console.log(`-current terminal = ${term?.name}`);
97-
await sendTerminalText(terminalName, terminalText);
98-
await delay(delayTime);
99-
const term2 = focusOnNamedTerminal(terminalName);
100-
await delay(delayTime);
101-
let result = await getTerminalOutput(terminalName);
102-
console.log(`-validateTerminalResponse terminal output = ${result}`);
103-
expect(result).to.include(terminalResponse);
80+
const resultValue = await waitUntil(async () => {
81+
focusOnNamedTerminal(terminalName);
82+
const result = await getTerminalOutput(terminalName);
83+
console.log(`-validateTerminalResponse terminal output = ${result}`);
84+
if (terminalResponse) {
85+
return result.includes(terminalResponse);
86+
} else {
87+
return result.includes(terminalText);
88+
}
89+
}, 5000);
10490
findAndDisposeTerminal(terminalName);
10591
}
10692
}

0 commit comments

Comments
 (0)