From b6dfdafd4b94eca6b2f9b85f358854f9d597dd78 Mon Sep 17 00:00:00 2001 From: Jerome Lelong Date: Fri, 4 Mar 2022 22:43:01 +0100 Subject: [PATCH] Add waitGivenRootFile --- test/multiroot-ws.test.ts | 20 ++++++-------------- test/utils.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/multiroot-ws.test.ts b/test/multiroot-ws.test.ts index 856136c78..6ace65c52 100644 --- a/test/multiroot-ws.test.ts +++ b/test/multiroot-ws.test.ts @@ -7,9 +7,9 @@ import { assertPdfIsGenerated, executeVscodeCommandAfterActivation, getFixtureDir, isDockerEnabled, runTestWithFixture, + waitGivenRootFile, waitLatexWorkshopActivated, - waitRootFileFound, - waitUntil + waitRootFileFound } from './utils' @@ -165,24 +165,16 @@ suite('Multi-root workspace test suite', () => { const docA = await vscode.workspace.openTextDocument(texFilePathA) await vscode.window.showTextDocument(docA) const extension = await waitLatexWorkshopActivated() - await waitUntil(() => { - const rootFile = extension.exports.realExtension?.manager.rootFile - return rootFile === docA.fileName - }) + await waitGivenRootFile(docA.fileName) await sleep(1000) const docB = await vscode.workspace.openTextDocument(texFilePathB) await vscode.window.showTextDocument(docB) - await waitUntil(() => { - const rootFile = extension.exports.realExtension?.manager.rootFile - return rootFile === docB.fileName - }) + await waitGivenRootFile(docB.fileName) await sleep(1000) await vscode.window.showTextDocument(docA) - await waitUntil(() => { - const rootFile = extension.exports.realExtension?.manager.rootFile - return rootFile === docA.fileName - }) + await waitGivenRootFile(docA.fileName) await sleep(1000) + const structure = extension.exports.realExtension?.structureProvider.ds const filesWatched = extension.exports.realExtension?.manager.getFilesWatched() const isStructureOK = structure && structure.length > 0 && structure[0].fileName === docA.fileName diff --git a/test/utils.ts b/test/utils.ts index 5431f38b9..1cba516be 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -142,6 +142,14 @@ export function waitRootFileFound() { ) } +export function waitGivenRootFile(file: string) { + return waitUntil( async () => { + const extension = await waitLatexWorkshopActivated() + const rootFile = extension.exports.realExtension?.manager.rootFile + return rootFile === file + }) +} + export async function executeVscodeCommandAfterActivation(command: string) { await waitLatexWorkshopActivated() return vscode.commands.executeCommand(command)