Add waitGivenRootFile

This commit is contained in:
Jerome Lelong 2022-03-04 22:43:01 +01:00
parent 5a33152ecc
commit b6dfdafd4b
2 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -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)