Skip to content

Commit 1043448

Browse files
Add types to command runners
1 parent a27f58d commit 1043448

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-
1616
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
1717
import { getActivatedExtension } from "../../global.helper";
1818
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
19+
import { AllCommands } from "../../../../src/common/commands";
1920

2021
jest.setTimeout(60_000);
2122

2223
describe("Db panel UI commands", () => {
2324
let storagePath: string;
24-
const commandManager = createVSCodeCommandManager();
25+
const commandManager = createVSCodeCommandManager<AllCommands>();
2526

2627
beforeEach(async () => {
2728
const extension = await getActivatedExtension();

extensions/ql-vscode/test/vscode-tests/cli-integration/queries.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { CompletedQueryInfo } from "../../../src/query-results";
2626
import { SELECT_QUERY_NAME } from "../../../src/contextual/locationFinder";
2727
import { createMockCommandManager } from "../../__mocks__/commandsMock";
2828
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
29+
import { AllCommands, QueryServerCommands } from "../../../src/common/commands";
2930

3031
jest.setTimeout(20_000);
3132

@@ -40,7 +41,9 @@ describeWithCodeQL()("Queries", () => {
4041
const progress = jest.fn();
4142
let token: CancellationToken;
4243
let ctx: ExtensionContext;
43-
const commandManager = createVSCodeCommandManager();
44+
const appCommandManager = createVSCodeCommandManager<AllCommands>();
45+
const queryServerCommandManager =
46+
createVSCodeCommandManager<QueryServerCommands>();
4447

4548
let qlpackFile: string;
4649
let qlpackLockFile: string;
@@ -178,7 +181,7 @@ describeWithCodeQL()("Queries", () => {
178181

179182
// Asserts a fix for bug https://github.com/github/vscode-codeql/issues/733
180183
it("should restart the database and run a query", async () => {
181-
await commandManager.execute("codeQL.restartQueryServer");
184+
await appCommandManager.execute("codeQL.restartQueryServer");
182185
const queryPath = join(__dirname, "data", "simple-query.ql");
183186
const result = await qs.compileAndRunQueryAgainstDatabase(
184187
dbItem,
@@ -192,7 +195,7 @@ describeWithCodeQL()("Queries", () => {
192195
});
193196

194197
it("should create a quick query", async () => {
195-
await commandManager.execute("codeQL.quickQuery");
198+
await queryServerCommandManager.execute("codeQL.quickQuery");
196199

197200
// should have created the quick query file and query pack file
198201
expect(pathExistsSync(qlFile)).toBe(true);
@@ -225,7 +228,7 @@ describeWithCodeQL()("Queries", () => {
225228
}),
226229
);
227230
writeFileSync(qlFile, "xxx");
228-
await commandManager.execute("codeQL.quickQuery");
231+
await queryServerCommandManager.execute("codeQL.quickQuery");
229232

230233
// should not have created the quick query file because database schema hasn't changed
231234
expect(readFileSync(qlFile, "utf8")).toBe("xxx");

extensions/ql-vscode/test/vscode-tests/cli-integration/sourcemap.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { join, basename } from "path";
33
import { tmpDir } from "../../../src/helpers";
44
import { readFile, writeFile, ensureDir, copy } from "fs-extra";
55
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
6+
import { AllCommands } from "../../../src/common/commands";
67

78
jest.setTimeout(20_000);
89

910
/**
1011
* Integration tests for queries
1112
*/
1213
describe("SourceMap", () => {
13-
const commandManager = createVSCodeCommandManager();
14+
const commandManager = createVSCodeCommandManager<AllCommands>();
1415

1516
it("should jump to QL code", async () => {
1617
const root = workspace.workspaceFolders![0].uri.fsPath;

extensions/ql-vscode/test/vscode-tests/cli-integration/variant-analysis/variant-analysis-submission-integration.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { mockedQuickPickItem } from "../../utils/mocking.helpers";
1313
import { setRemoteControllerRepo } from "../../../../src/config";
1414
import { getActivatedExtension } from "../../global.helper";
1515
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
16+
import { AllCommands } from "../../../../src/common/commands";
1617

1718
jest.setTimeout(30_000);
1819

@@ -30,7 +31,7 @@ async function showQlDocument(name: string): Promise<TextDocument> {
3031
}
3132

3233
describe("Variant Analysis Submission Integration", () => {
33-
const commandManager = createVSCodeCommandManager();
34+
const commandManager = createVSCodeCommandManager<AllCommands>();
3435
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
3536
let executeCommandSpy: jest.SpiedFunction<typeof commands.executeCommand>;
3637
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;

0 commit comments

Comments
 (0)