Fix and re-enable variant analysis submission integration tests
This commit is contained in:
@@ -348,7 +348,9 @@ export type MockGitHubApiServerCommands = {
|
||||
"codeQL.mockGitHubApiServer.startRecording": () => Promise<void>;
|
||||
"codeQL.mockGitHubApiServer.saveScenario": () => Promise<void>;
|
||||
"codeQL.mockGitHubApiServer.cancelRecording": () => Promise<void>;
|
||||
"codeQL.mockGitHubApiServer.loadScenario": () => Promise<void>;
|
||||
"codeQL.mockGitHubApiServer.loadScenario": (
|
||||
scenario?: string,
|
||||
) => Promise<void>;
|
||||
"codeQL.mockGitHubApiServer.unloadScenario": () => Promise<void>;
|
||||
};
|
||||
|
||||
|
||||
@@ -63,26 +63,33 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
|
||||
);
|
||||
}
|
||||
|
||||
public async loadScenario(): Promise<void> {
|
||||
public async loadScenario(scenario?: string): Promise<void> {
|
||||
const scenariosPath = await this.getScenariosPath();
|
||||
if (!scenariosPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scenarioNames = await this.server.getScenarioNames(scenariosPath);
|
||||
const scenarioQuickPickItems = scenarioNames.map((s) => ({ label: s }));
|
||||
const quickPickOptions = {
|
||||
placeHolder: "Select a scenario to load",
|
||||
};
|
||||
const selectedScenario = await window.showQuickPick<QuickPickItem>(
|
||||
scenarioQuickPickItems,
|
||||
quickPickOptions,
|
||||
);
|
||||
if (!selectedScenario) {
|
||||
return;
|
||||
let scenarioName = scenario;
|
||||
if (!scenarioName) {
|
||||
const scenarioNames = await this.server.getScenarioNames(scenariosPath);
|
||||
const scenarioQuickPickItems = scenarioNames.map((s) => ({ label: s }));
|
||||
const quickPickOptions = {
|
||||
placeHolder: "Select a scenario to load",
|
||||
};
|
||||
const selectedScenario = await window.showQuickPick<QuickPickItem>(
|
||||
scenarioQuickPickItems,
|
||||
quickPickOptions,
|
||||
);
|
||||
if (!selectedScenario) {
|
||||
return;
|
||||
}
|
||||
|
||||
scenarioName = selectedScenario.label;
|
||||
}
|
||||
|
||||
const scenarioName = selectedScenario.label;
|
||||
if (!this.server.isListening && this.app.mode === AppMode.Test) {
|
||||
await this.startServer();
|
||||
}
|
||||
|
||||
await this.server.loadScenario(scenarioName, scenariosPath);
|
||||
|
||||
@@ -94,12 +101,12 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
|
||||
true,
|
||||
);
|
||||
|
||||
await window.showInformationMessage(`Loaded scenario '${scenarioName}'`);
|
||||
void window.showInformationMessage(`Loaded scenario '${scenarioName}'`);
|
||||
}
|
||||
|
||||
public async unloadScenario(): Promise<void> {
|
||||
if (!this.server.isScenarioLoaded) {
|
||||
await window.showInformationMessage("No scenario currently loaded");
|
||||
void window.showInformationMessage("No scenario currently loaded");
|
||||
} else {
|
||||
await this.server.unloadScenario();
|
||||
await this.app.commands.execute(
|
||||
@@ -107,7 +114,11 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
|
||||
"codeQL.mockGitHubApiServer.scenarioLoaded",
|
||||
false,
|
||||
);
|
||||
await window.showInformationMessage("Unloaded scenario");
|
||||
void window.showInformationMessage("Unloaded scenario");
|
||||
}
|
||||
|
||||
if (this.server.isListening && this.app.mode === AppMode.Test) {
|
||||
await this.stopServer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +150,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
|
||||
true,
|
||||
);
|
||||
|
||||
await window.showInformationMessage(
|
||||
void window.showInformationMessage(
|
||||
'Recording scenario. To save the scenario, use the "CodeQL Mock GitHub API Server: Save Scenario" command.',
|
||||
);
|
||||
}
|
||||
@@ -221,7 +232,10 @@ export class VSCodeMockGitHubApiServer extends DisposableObject {
|
||||
return scenariosPath;
|
||||
}
|
||||
|
||||
if (this.app.mode === AppMode.Development) {
|
||||
if (
|
||||
this.app.mode === AppMode.Development ||
|
||||
this.app.mode === AppMode.Test
|
||||
) {
|
||||
const developmentScenariosPath = path.join(
|
||||
this.app.extensionPath,
|
||||
"src/common/mock-gh-api/scenarios",
|
||||
|
||||
@@ -3,18 +3,12 @@ import { resolve } from "path";
|
||||
import type { TextDocument } from "vscode";
|
||||
import { authentication, commands, window, workspace } from "vscode";
|
||||
|
||||
import { MockGitHubApiServer } from "../../../../src/common/mock-gh-api/mock-gh-api-server";
|
||||
import { mockedQuickPickItem } from "../../utils/mocking.helpers";
|
||||
import { setRemoteControllerRepo } from "../../../../src/config";
|
||||
import { getActivatedExtension } from "../../global.helper";
|
||||
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
|
||||
import type { AllCommands } from "../../../../src/common/commands";
|
||||
|
||||
const mockServer = new MockGitHubApiServer();
|
||||
beforeAll(() => mockServer.startServer("bypass"));
|
||||
afterEach(() => mockServer.unloadScenario());
|
||||
afterAll(() => mockServer.stopServer());
|
||||
|
||||
async function showQlDocument(name: string): Promise<TextDocument> {
|
||||
const folderPath = workspace.workspaceFolders![0].uri.fsPath;
|
||||
const documentPath = resolve(folderPath, name);
|
||||
@@ -24,7 +18,7 @@ async function showQlDocument(name: string): Promise<TextDocument> {
|
||||
}
|
||||
|
||||
// MSW can't intercept fetch requests made in VS Code, so we are skipping these tests for now
|
||||
describe.skip("Variant Analysis Submission Integration", () => {
|
||||
describe("Variant Analysis Submission Integration", () => {
|
||||
const commandManager = createVSCodeCommandManager<AllCommands>();
|
||||
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
let executeCommandSpy: jest.SpiedFunction<typeof commands.executeCommand>;
|
||||
@@ -54,9 +48,16 @@ describe.skip("Variant Analysis Submission Integration", () => {
|
||||
await getActivatedExtension();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await commandManager.execute("codeQL.mockGitHubApiServer.unloadScenario");
|
||||
});
|
||||
|
||||
describe("Successful scenario", () => {
|
||||
beforeEach(async () => {
|
||||
await mockServer.loadScenario("mrva-problem-query-success");
|
||||
await commandManager.execute(
|
||||
"codeQL.mockGitHubApiServer.loadScenario",
|
||||
"mrva-problem-query-success",
|
||||
);
|
||||
});
|
||||
|
||||
it("opens the variant analysis view", async () => {
|
||||
@@ -81,7 +82,10 @@ describe.skip("Variant Analysis Submission Integration", () => {
|
||||
|
||||
describe("Missing controller repo", () => {
|
||||
beforeEach(async () => {
|
||||
await mockServer.loadScenario("mrva-missing-controller-repo");
|
||||
await commandManager.execute(
|
||||
"codeQL.mockGitHubApiServer.loadScenario",
|
||||
"mrva-missing-controller-repo",
|
||||
);
|
||||
});
|
||||
|
||||
it("shows the error message", async () => {
|
||||
@@ -108,7 +112,10 @@ describe.skip("Variant Analysis Submission Integration", () => {
|
||||
|
||||
describe("Submission failure", () => {
|
||||
beforeEach(async () => {
|
||||
await mockServer.loadScenario("mrva-submission-failure");
|
||||
await commandManager.execute(
|
||||
"codeQL.mockGitHubApiServer.loadScenario",
|
||||
"mrva-submission-failure",
|
||||
);
|
||||
});
|
||||
|
||||
it("shows the error message", async () => {
|
||||
|
||||
Reference in New Issue
Block a user