Unveil new variant analysis repositories panel (#2082)
This commit is contained in:
@@ -25,11 +25,14 @@ choose to go through some of the Optional Test Cases.
|
||||
1. Open the [UnsafeJQueryPlugin query](https://github.com/github/codeql/blob/main/javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql).
|
||||
2. Run a MRVA against the following repo list:
|
||||
```
|
||||
"test-repo-list": [
|
||||
{
|
||||
"name": "test-repo-list",
|
||||
"repositories": [
|
||||
"angular-cn/ng-nice",
|
||||
"apache/hadoop",
|
||||
"apache/hive"
|
||||
]
|
||||
}
|
||||
```
|
||||
3. Check that a notification message pops up and the results view is opened.
|
||||
4. Check the query history. It should:
|
||||
@@ -278,3 +281,40 @@ This requires running a MRVA query and seeing the results view.
|
||||
#### Test case 4: When variant analysis is in "failed" or "canceled" state
|
||||
1. Can view logs
|
||||
1. Results for finished queries are still downloaded.
|
||||
|
||||
### MRVA repositories panel
|
||||
|
||||
1. Add a list
|
||||
1. Add a database at the top level
|
||||
1. Add a database to a list
|
||||
1. Add a the same database at a top-level and in a list
|
||||
1. Delete a list
|
||||
1. Delete a database from the top level
|
||||
1. Delete a database from a list
|
||||
1. Add an owner
|
||||
1. Remove an owner
|
||||
1. Rename a list
|
||||
1. Open on GitHub
|
||||
1. Select a list (via "Select" button and via context menu action)
|
||||
1. Run MRVA against a user-defined list
|
||||
1. Run MRVA against a top-N list
|
||||
1. Run MRVA against an owner
|
||||
1. Run MRVA against a database
|
||||
1. Copy repo list
|
||||
1. Open config file
|
||||
1. Make changes via config file (ensure JSON schema is helping out)
|
||||
1. Close and re-open VS Code (ensure lists are there)
|
||||
1. Collapse/expand tree nodes
|
||||
|
||||
Error cases that trigger an error notification:
|
||||
1. Try to add a list with a name that already exists
|
||||
1. Try to add a top-level database that already exists
|
||||
1. Try to add a database in a list that already exists in the list
|
||||
|
||||
Error cases that show an error in the panel (and only the edit button should be visible):
|
||||
1. Edit the db config file directly and save invalid JSON
|
||||
1. Edit the db config file directly and save valid JSON but invalid config (e.g. add an unknown property)
|
||||
1. Edit the db config file directly and save two lists with the same name
|
||||
|
||||
Cases where there the welcome view is shown:
|
||||
1. No controller repo is set in the user's settings JSON.
|
||||
@@ -1282,7 +1282,7 @@
|
||||
{
|
||||
"id": "codeQLVariantAnalysisRepositories",
|
||||
"name": "Variant Analysis Repositories",
|
||||
"when": "config.codeQL.canary && config.codeQL.variantAnalysis.repositoriesPanel"
|
||||
"when": "config.codeQL.canary"
|
||||
},
|
||||
{
|
||||
"id": "codeQLQueryHistory",
|
||||
|
||||
@@ -579,16 +579,8 @@ export function isVariantAnalysisLiveResultsEnabled(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A flag indicating whether to use the new "variant analysis repositories" panel.
|
||||
*/
|
||||
const VARIANT_ANALYSIS_REPOS_PANEL = new Setting(
|
||||
"repositoriesPanel",
|
||||
VARIANT_ANALYSIS_SETTING,
|
||||
);
|
||||
|
||||
export function isVariantAnalysisReposPanelEnabled(): boolean {
|
||||
return !!VARIANT_ANALYSIS_REPOS_PANEL.getValue<boolean>();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Settings for mocking the GitHub API.
|
||||
|
||||
@@ -112,7 +112,6 @@ describe("Variant Analysis Manager", () => {
|
||||
|
||||
describe("runVariantAnalysis", () => {
|
||||
const progress = jest.fn();
|
||||
let showQuickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
let mockGetRepositoryFromNwo: jest.SpiedFunction<
|
||||
typeof ghApiClient.getRepositoryFromNwo
|
||||
>;
|
||||
@@ -133,12 +132,8 @@ describe("Variant Analysis Manager", () => {
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
// Should not have asked for a language
|
||||
showQuickPickSpy = jest
|
||||
jest
|
||||
.spyOn(window, "showQuickPick")
|
||||
.mockResolvedValueOnce({
|
||||
repositories: ["github/vscode-codeql"],
|
||||
} as unknown as QuickPickItem)
|
||||
.mockResolvedValueOnce("javascript" as unknown as QuickPickItem);
|
||||
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
@@ -197,8 +192,6 @@ describe("Variant Analysis Manager", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(showQuickPickSpy).toBeCalledTimes(1);
|
||||
|
||||
expect(mockGetRepositoryFromNwo).toBeCalledTimes(1);
|
||||
expect(mockSubmitVariantAnalysis).toBeCalledTimes(1);
|
||||
});
|
||||
@@ -991,6 +984,12 @@ describe("Variant Analysis Manager", () => {
|
||||
});
|
||||
});
|
||||
describe("variantAnalysisReposPanel false", () => {
|
||||
beforeEach(() => {
|
||||
jest
|
||||
.spyOn(config, "isVariantAnalysisReposPanelEnabled")
|
||||
.mockReturnValue(false);
|
||||
});
|
||||
|
||||
it("should be valid JSON when put in object", async () => {
|
||||
await variantAnalysisManager.copyRepoListToClipboard(
|
||||
variantAnalysis.id,
|
||||
|
||||
@@ -35,7 +35,6 @@ async function showQlDocument(name: string): Promise<TextDocument> {
|
||||
|
||||
describe("Variant Analysis Submission Integration", () => {
|
||||
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
let inputBoxSpy: jest.SpiedFunction<typeof window.showInputBox>;
|
||||
let executeCommandSpy: jest.SpiedFunction<typeof commands.executeCommand>;
|
||||
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;
|
||||
|
||||
@@ -56,9 +55,6 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
quickPickSpy = jest
|
||||
.spyOn(window, "showQuickPick")
|
||||
.mockResolvedValue(undefined);
|
||||
inputBoxSpy = jest
|
||||
.spyOn(window, "showInputBox")
|
||||
.mockResolvedValue(undefined);
|
||||
executeCommandSpy = jest.spyOn(commands, "executeCommand");
|
||||
showErrorMessageSpy = jest
|
||||
.spyOn(window, "showErrorMessage")
|
||||
@@ -79,12 +75,6 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
it("opens the variant analysis view", async () => {
|
||||
await showQlDocument("query.ql");
|
||||
|
||||
// Select a repository list
|
||||
quickPickSpy.mockResolvedValueOnce({
|
||||
useCustomRepo: true,
|
||||
} as unknown as QuickPickItem);
|
||||
// Enter a GitHub repository
|
||||
inputBoxSpy.mockResolvedValueOnce("github/codeql");
|
||||
// Select target language for your query
|
||||
quickPickSpy.mockResolvedValueOnce(
|
||||
"javascript" as unknown as QuickPickItem,
|
||||
@@ -107,13 +97,6 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
it("shows the error message", async () => {
|
||||
await showQlDocument("query.ql");
|
||||
|
||||
// Select a repository list
|
||||
quickPickSpy.mockResolvedValueOnce({
|
||||
useCustomRepo: true,
|
||||
} as unknown as QuickPickItem);
|
||||
// Enter a GitHub repository
|
||||
inputBoxSpy.mockResolvedValueOnce("github/codeql");
|
||||
|
||||
await commands.executeCommand("codeQL.runVariantAnalysis");
|
||||
|
||||
expect(showErrorMessageSpy).toHaveBeenCalledWith(
|
||||
@@ -133,12 +116,6 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
it("shows the error message", async () => {
|
||||
await showQlDocument("query.ql");
|
||||
|
||||
// Select a repository list
|
||||
quickPickSpy.mockResolvedValueOnce({
|
||||
useCustomRepo: true,
|
||||
} as unknown as QuickPickItem);
|
||||
// Enter a GitHub repository
|
||||
inputBoxSpy.mockResolvedValueOnce("github/codeql");
|
||||
// Select target language for your query
|
||||
quickPickSpy.mockResolvedValueOnce(
|
||||
"javascript" as unknown as QuickPickItem,
|
||||
|
||||
@@ -143,7 +143,12 @@ describe("repository selection", () => {
|
||||
getRemoteRepositoryListsPathSpy = jest
|
||||
.spyOn(config, "getRemoteRepositoryListsPath")
|
||||
.mockReturnValue(undefined);
|
||||
|
||||
jest
|
||||
.spyOn(config, "isVariantAnalysisReposPanelEnabled")
|
||||
.mockReturnValue(false);
|
||||
});
|
||||
|
||||
describe("repo lists from settings", () => {
|
||||
it("should allow selection from repo lists from your pre-defined config", async () => {
|
||||
// Fake return values
|
||||
|
||||
Reference in New Issue
Block a user