Skip to content

Commit c309bdc

Browse files
authored
Unveil new variant analysis repositories panel (#2082)
1 parent f9851a3 commit c309bdc

File tree

6 files changed

+59
-46
lines changed

6 files changed

+59
-46
lines changed

extensions/ql-vscode/docs/test-plan.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ choose to go through some of the Optional Test Cases.
2525
1. Open the [UnsafeJQueryPlugin query](https://github.com/github/codeql/blob/main/javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql).
2626
2. Run a MRVA against the following repo list:
2727
```
28-
"test-repo-list": [
29-
"angular-cn/ng-nice",
30-
"apache/hadoop",
31-
"apache/hive"
32-
]
28+
{
29+
"name": "test-repo-list",
30+
"repositories": [
31+
"angular-cn/ng-nice",
32+
"apache/hadoop",
33+
"apache/hive"
34+
]
35+
}
3336
```
3437
3. Check that a notification message pops up and the results view is opened.
3538
4. Check the query history. It should:
@@ -278,3 +281,40 @@ This requires running a MRVA query and seeing the results view.
278281
#### Test case 4: When variant analysis is in "failed" or "canceled" state
279282
1. Can view logs
280283
1. Results for finished queries are still downloaded.
284+
285+
### MRVA repositories panel
286+
287+
1. Add a list
288+
1. Add a database at the top level
289+
1. Add a database to a list
290+
1. Add a the same database at a top-level and in a list
291+
1. Delete a list
292+
1. Delete a database from the top level
293+
1. Delete a database from a list
294+
1. Add an owner
295+
1. Remove an owner
296+
1. Rename a list
297+
1. Open on GitHub
298+
1. Select a list (via "Select" button and via context menu action)
299+
1. Run MRVA against a user-defined list
300+
1. Run MRVA against a top-N list
301+
1. Run MRVA against an owner
302+
1. Run MRVA against a database
303+
1. Copy repo list
304+
1. Open config file
305+
1. Make changes via config file (ensure JSON schema is helping out)
306+
1. Close and re-open VS Code (ensure lists are there)
307+
1. Collapse/expand tree nodes
308+
309+
Error cases that trigger an error notification:
310+
1. Try to add a list with a name that already exists
311+
1. Try to add a top-level database that already exists
312+
1. Try to add a database in a list that already exists in the list
313+
314+
Error cases that show an error in the panel (and only the edit button should be visible):
315+
1. Edit the db config file directly and save invalid JSON
316+
1. Edit the db config file directly and save valid JSON but invalid config (e.g. add an unknown property)
317+
1. Edit the db config file directly and save two lists with the same name
318+
319+
Cases where there the welcome view is shown:
320+
1. No controller repo is set in the user's settings JSON.

extensions/ql-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@
12821282
{
12831283
"id": "codeQLVariantAnalysisRepositories",
12841284
"name": "Variant Analysis Repositories",
1285-
"when": "config.codeQL.canary && config.codeQL.variantAnalysis.repositoriesPanel"
1285+
"when": "config.codeQL.canary"
12861286
},
12871287
{
12881288
"id": "codeQLQueryHistory",

extensions/ql-vscode/src/config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,16 +579,8 @@ export function isVariantAnalysisLiveResultsEnabled(): boolean {
579579
return true;
580580
}
581581

582-
/**
583-
* A flag indicating whether to use the new "variant analysis repositories" panel.
584-
*/
585-
const VARIANT_ANALYSIS_REPOS_PANEL = new Setting(
586-
"repositoriesPanel",
587-
VARIANT_ANALYSIS_SETTING,
588-
);
589-
590582
export function isVariantAnalysisReposPanelEnabled(): boolean {
591-
return !!VARIANT_ANALYSIS_REPOS_PANEL.getValue<boolean>();
583+
return true;
592584
}
593585

594586
// Settings for mocking the GitHub API.

extensions/ql-vscode/test/vscode-tests/cli-integration/remote-queries/variant-analysis-manager.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ describe("Variant Analysis Manager", () => {
112112

113113
describe("runVariantAnalysis", () => {
114114
const progress = jest.fn();
115-
let showQuickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
116115
let mockGetRepositoryFromNwo: jest.SpiedFunction<
117116
typeof ghApiClient.getRepositoryFromNwo
118117
>;
@@ -133,12 +132,8 @@ describe("Variant Analysis Manager", () => {
133132
}
134133

135134
beforeEach(async () => {
136-
// Should not have asked for a language
137-
showQuickPickSpy = jest
135+
jest
138136
.spyOn(window, "showQuickPick")
139-
.mockResolvedValueOnce({
140-
repositories: ["github/vscode-codeql"],
141-
} as unknown as QuickPickItem)
142137
.mockResolvedValueOnce("javascript" as unknown as QuickPickItem);
143138

144139
cancellationTokenSource = new CancellationTokenSource();
@@ -197,8 +192,6 @@ describe("Variant Analysis Manager", () => {
197192
}),
198193
);
199194

200-
expect(showQuickPickSpy).toBeCalledTimes(1);
201-
202195
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
203196
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
204197
});
@@ -991,6 +984,12 @@ describe("Variant Analysis Manager", () => {
991984
});
992985
});
993986
describe("variantAnalysisReposPanel false", () => {
987+
beforeEach(() => {
988+
jest
989+
.spyOn(config, "isVariantAnalysisReposPanelEnabled")
990+
.mockReturnValue(false);
991+
});
992+
994993
it("should be valid JSON when put in object", async () => {
995994
await variantAnalysisManager.copyRepoListToClipboard(
996995
variantAnalysis.id,

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ async function showQlDocument(name: string): Promise<TextDocument> {
3535

3636
describe("Variant Analysis Submission Integration", () => {
3737
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
38-
let inputBoxSpy: jest.SpiedFunction<typeof window.showInputBox>;
3938
let executeCommandSpy: jest.SpiedFunction<typeof commands.executeCommand>;
4039
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;
4140

@@ -56,9 +55,6 @@ describe("Variant Analysis Submission Integration", () => {
5655
quickPickSpy = jest
5756
.spyOn(window, "showQuickPick")
5857
.mockResolvedValue(undefined);
59-
inputBoxSpy = jest
60-
.spyOn(window, "showInputBox")
61-
.mockResolvedValue(undefined);
6258
executeCommandSpy = jest.spyOn(commands, "executeCommand");
6359
showErrorMessageSpy = jest
6460
.spyOn(window, "showErrorMessage")
@@ -79,12 +75,6 @@ describe("Variant Analysis Submission Integration", () => {
7975
it("opens the variant analysis view", async () => {
8076
await showQlDocument("query.ql");
8177

82-
// Select a repository list
83-
quickPickSpy.mockResolvedValueOnce({
84-
useCustomRepo: true,
85-
} as unknown as QuickPickItem);
86-
// Enter a GitHub repository
87-
inputBoxSpy.mockResolvedValueOnce("github/codeql");
8878
// Select target language for your query
8979
quickPickSpy.mockResolvedValueOnce(
9080
"javascript" as unknown as QuickPickItem,
@@ -107,13 +97,6 @@ describe("Variant Analysis Submission Integration", () => {
10797
it("shows the error message", async () => {
10898
await showQlDocument("query.ql");
10999

110-
// Select a repository list
111-
quickPickSpy.mockResolvedValueOnce({
112-
useCustomRepo: true,
113-
} as unknown as QuickPickItem);
114-
// Enter a GitHub repository
115-
inputBoxSpy.mockResolvedValueOnce("github/codeql");
116-
117100
await commands.executeCommand("codeQL.runVariantAnalysis");
118101

119102
expect(showErrorMessageSpy).toHaveBeenCalledWith(
@@ -133,12 +116,6 @@ describe("Variant Analysis Submission Integration", () => {
133116
it("shows the error message", async () => {
134117
await showQlDocument("query.ql");
135118

136-
// Select a repository list
137-
quickPickSpy.mockResolvedValueOnce({
138-
useCustomRepo: true,
139-
} as unknown as QuickPickItem);
140-
// Enter a GitHub repository
141-
inputBoxSpy.mockResolvedValueOnce("github/codeql");
142119
// Select target language for your query
143120
quickPickSpy.mockResolvedValueOnce(
144121
"javascript" as unknown as QuickPickItem,

extensions/ql-vscode/test/vscode-tests/no-workspace/remote-queries/repository-selection.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ describe("repository selection", () => {
143143
getRemoteRepositoryListsPathSpy = jest
144144
.spyOn(config, "getRemoteRepositoryListsPath")
145145
.mockReturnValue(undefined);
146+
147+
jest
148+
.spyOn(config, "isVariantAnalysisReposPanelEnabled")
149+
.mockReturnValue(false);
146150
});
151+
147152
describe("repo lists from settings", () => {
148153
it("should allow selection from repo lists from your pre-defined config", async () => {
149154
// Fake return values

0 commit comments

Comments
 (0)