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

Commit 8c53e5b

Browse files
authored
FUSETOOLS2-1010 - fixing more code smells (#448)
* FUSETOOLS2-1010 - fixing more code smells * a few adjustments * adding windows specific delay Signed-off-by: Brian Fitzpatrick <[email protected]>
1 parent e8b7b0c commit 8c53e5b

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/extensionFunctions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,19 +469,19 @@ export async function getWebviewContent() : Promise<string|void> {
469469
}
470470

471471
async function loadFileWithRetry ( uri:vscode.Uri ) : Promise<string | void | undefined> {
472-
return await getDataFromFile(uri).catch( async () => {
472+
return getDataFromFile(uri).catch( async () => {
473473
await delay(3000);
474-
return await getDataFromFile(uri).catch( async (error) => {
474+
return getDataFromFile(uri).catch( async (error) => {
475475
showFileUnavailable(error);
476476
});
477477
});
478478
}
479479

480480
async function loadFileFromHTTPWithRetry ( uri:vscode.Uri ) : Promise<string | void | undefined> {
481481
const urlToFetch = uri.toString();
482-
return await getDataFromUrl(urlToFetch).catch( async () => {
482+
return getDataFromUrl(urlToFetch).catch( async () => {
483483
await delay(3000);
484-
return await getDataFromUrl(urlToFetch).catch( async (error) => {
484+
return getDataFromUrl(urlToFetch).catch( async (error) => {
485485
showFileUnavailable(error);
486486
});
487487
});

src/test/suite/stubDemoTutorial.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717

1818
import { 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';
2121
import { didactManager } from '../../didactManager';
2222
import { DidactUri } from '../../didactUri';
2323
import { handleText } from '../../commandHandler';
@@ -27,6 +27,8 @@ const testMD = Uri.parse('vscode://redhat.vscode-didact?extension=demos/markdown
2727

2828
const delayTime = 1500;
2929

30+
const WINDOWS: string = 'win32';
31+
3032
suite('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(/=vscode.didact.sendNamedTerminalAString&/g));
45-
expect(commands).to.not.be.empty;
46-
commands.forEach(function(href: string) {
46+
const commandsToTest : any[] = gatherAllCommandsLinks().filter( (href) => href.match(/=vscode.didact.sendNamedTerminalAString&/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

109114
function delay(ms: number) {

0 commit comments

Comments
 (0)