Don't create QL pack if user escapes out of prompt (#3062)

This commit is contained in:
Shati Patel
2023-11-13 10:44:21 +00:00
committed by GitHub
parent bc2847a12e
commit 934ed82786
3 changed files with 14 additions and 2 deletions

View File

@@ -43,7 +43,9 @@ export function getFirstWorkspaceFolder() {
const workspaceFolders = getOnDiskWorkspaceFolders();
if (!workspaceFolders || workspaceFolders.length === 0) {
throw new Error("No workspace folders found");
throw new Error(
"No workspace folders found. Please open a folder or workspace in VS Code.",
);
}
const firstFolderFsPath = workspaceFolders[0];

View File

@@ -265,7 +265,7 @@ export class DatabaseManager extends DisposableObject {
`We've noticed you don't have a CodeQL pack available to analyze this database. Can we set up a query pack for you?`,
);
if (answer === "No") {
if (answer === "No" || answer === undefined) {
return;
}

View File

@@ -622,6 +622,16 @@ describe("local databases", () => {
expect(generateSpy).not.toBeCalled();
});
it("should return early if the user escapes out of the dialog", async () => {
showNeverAskAgainDialogSpy = jest
.spyOn(dialog, "showNeverAskAgainDialog")
.mockResolvedValue(undefined);
await (databaseManager as any).createSkeletonPacks(mockDbItem);
expect(generateSpy).not.toBeCalled();
});
it("should return early and write choice to settings if user wants to never be asked again", async () => {
showNeverAskAgainDialogSpy = jest
.spyOn(dialog, "showNeverAskAgainDialog")