From 5b7124683a93f0a035955c5ea1b29c9c312c8456 Mon Sep 17 00:00:00 2001 From: Nora Date: Mon, 11 Sep 2023 12:34:02 +0000 Subject: [PATCH 1/4] Replace void with await --- extensions/ql-vscode/src/databases/ui/db-panel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/databases/ui/db-panel.ts b/extensions/ql-vscode/src/databases/ui/db-panel.ts index ea898cf9c..f3f2e20bc 100644 --- a/extensions/ql-vscode/src/databases/ui/db-panel.ts +++ b/extensions/ql-vscode/src/databases/ui/db-panel.ts @@ -409,7 +409,7 @@ export class DbPanel extends DisposableObject { return; } - void window.withProgress( + await window.withProgress( { location: ProgressLocation.Notification, title: "Searching for repositories... This might take a while", From f82b51f7c513bbc5540c03e059bc10dd5a31534a Mon Sep 17 00:00:00 2001 From: Nora Date: Mon, 11 Sep 2023 12:35:08 +0000 Subject: [PATCH 2/4] Add comment --- .../activated-extension/databases/db-panel.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts b/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts index 7b72a571b..6d3429095 100644 --- a/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts @@ -21,6 +21,12 @@ import { AllCommands } from "../../../../src/common/commands"; jest.setTimeout(60_000); describe("Db panel UI commands", () => { + // This test has some serious problems: + // a) it runs twice: we couldn't find out why + // b) all tests use the same dbConfig file, hence the tests depend on ORDER and have to use the same list name! + // c) since we use a file watcher to update the config we sometimes need to wait (sleep) before accessing the config again + // d) we depend on highlighted list items when adding a repo to a list. If there's not enough time in between, a test might think a list is highlighted that doesn't exist anymore + let storagePath: string; const commandManager = createVSCodeCommandManager(); From 681a15ce45d280a1f0adbd23f0b238f76a8c6a82 Mon Sep 17 00:00:00 2001 From: Nora Date: Mon, 11 Sep 2023 12:35:31 +0000 Subject: [PATCH 3/4] Extract dbConfigFilePath --- .../databases/db-panel.test.ts | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts b/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts index 6d3429095..f99962e07 100644 --- a/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts @@ -28,6 +28,8 @@ describe("Db panel UI commands", () => { // d) we depend on highlighted list items when adding a repo to a list. If there's not enough time in between, a test might think a list is highlighted that doesn't exist anymore let storagePath: string; + let dbConfigFilePath: string; + const commandManager = createVSCodeCommandManager(); beforeEach(async () => { @@ -35,6 +37,11 @@ describe("Db panel UI commands", () => { storagePath = extension.ctx.storageUri?.fsPath || extension.ctx.globalStorageUri.fsPath; + + dbConfigFilePath = path.join( + storagePath, + DbConfigStore.databaseConfigFileName, + ); }); it("should add new remote db list", async () => { @@ -45,10 +52,6 @@ describe("Db panel UI commands", () => { ); // Check db config - const dbConfigFilePath = path.join( - storagePath, - DbConfigStore.databaseConfigFileName, - ); const dbConfig: DbConfig = await readJson(dbConfigFilePath); expect(dbConfig.databases.variantAnalysis.repositoryLists).toHaveLength(1); expect(dbConfig.databases.variantAnalysis.repositoryLists[0].name).toBe( @@ -67,10 +70,6 @@ describe("Db panel UI commands", () => { ); // Check db config - const dbConfigFilePath = path.join( - storagePath, - DbConfigStore.databaseConfigFileName, - ); const dbConfig: DbConfig = await readJson(dbConfigFilePath); expect(dbConfig.databases.local.lists).toHaveLength(1); expect(dbConfig.databases.local.lists[0].name).toBe("my-list-1"); @@ -88,10 +87,6 @@ describe("Db panel UI commands", () => { ); // Check db config - const dbConfigFilePath = path.join( - storagePath, - DbConfigStore.databaseConfigFileName, - ); const dbConfig: DbConfig = await readJson(dbConfigFilePath); expect(dbConfig.databases.variantAnalysis.repositories).toHaveLength(1); expect(dbConfig.databases.variantAnalysis.repositories[0]).toBe( @@ -111,10 +106,6 @@ describe("Db panel UI commands", () => { ); // Check db config - const dbConfigFilePath = path.join( - storagePath, - DbConfigStore.databaseConfigFileName, - ); const dbConfig: DbConfig = await readJson(dbConfigFilePath); expect(dbConfig.databases.variantAnalysis.owners).toHaveLength(1); expect(dbConfig.databases.variantAnalysis.owners[0]).toBe("owner1"); @@ -134,10 +125,6 @@ describe("Db panel UI commands", () => { ); // Check db config - const dbConfigFilePath = path.join( - storagePath, - DbConfigStore.databaseConfigFileName, - ); const dbConfig: DbConfig = await readJson(dbConfigFilePath); expect(dbConfig.selected).toBeDefined(); expect(dbConfig.selected).toEqual({ From 9aff9891d32d88abb439b0dda5ab6e5ad945913a Mon Sep 17 00:00:00 2001 From: Nora Date: Thu, 28 Sep 2023 08:18:44 +0000 Subject: [PATCH 4/4] Fix comment --- .../activated-extension/databases/db-panel.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts b/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts index f99962e07..55c0b76d8 100644 --- a/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts @@ -22,10 +22,8 @@ jest.setTimeout(60_000); describe("Db panel UI commands", () => { // This test has some serious problems: - // a) it runs twice: we couldn't find out why - // b) all tests use the same dbConfig file, hence the tests depend on ORDER and have to use the same list name! - // c) since we use a file watcher to update the config we sometimes need to wait (sleep) before accessing the config again - // d) we depend on highlighted list items when adding a repo to a list. If there's not enough time in between, a test might think a list is highlighted that doesn't exist anymore + // - all tests use the same dbConfig file, hence the tests depend on ORDER and have to use the same list name! + // - we depend on highlighted list items when adding a repo to a list. If there's not enough time in between, a test might think a list is highlighted that doesn't exist anymore let storagePath: string; let dbConfigFilePath: string;