19 KiB
Test Plan
This document describes the manual test plan for the QL extension for Visual Studio Code.
The plan will be executed manually to start with but the goal is to eventually automate parts of the process (based on effort vs value basis).
What this doesn't cover
We don't need to test features (and permutations of features) that are covered by automated tests.
Before releasing the VS Code extension
- Run at least one local query and MRVA using the existing version of the extension (to generate "old" query history items).
- Go through the required test cases listed below.
- Check major PRs since the previous release for specific one-off things to test. Based on that, you might want to choose to go through some of the Optional Test Cases.
Required Test Cases
Local databases
Test case 1: Download a database from GitHub
- Click "Download Database from GitHub" and enter
angular-cn/ng-nice
and select the javascript language if prompted
Test case 2: Import a database from an archive
- Obtain a javascript database for
babel/babel
- You can do
gh api "/repos/babel/babel/code-scanning/codeql/databases/javascript" -H "Accept: application/zip" > babel.zip
to fetch a database from GitHub.
- You can do
- Click "Choose Database from Archive" and select the file you just downloaded above.
Local queries
Test case 1: Running a path problem query and viewing results
- Open the javascript UnsafeJQueryPlugin query.
- Select the
angular-cn/ng-nice
database (or download it if you don't have one already) - Run a local query.
- Once the query completes:
- Check that the result messages are rendered
- Check that the paths can be opened and paths are rendered correctly
- Check that alert locations can be clicked on
Test case 2: Running a problem query and viewing results
- Open the javascript ReDoS query.
- Select the
babel/babel
database (or download it if you don't have one already) - Run a local query.
- Once the query completes:
- Check that the result messages are rendered
- Check that alert locations can be clicked on
Test case 3: Running a non-problem query and viewing results
- Open the cpp FunLinesOfCode query.
- Select the
google/brotli
database (or download it if you don't have one already) - Run a local query.
- Once the query completes:
- Check that the results table is rendered
- Check that result locations can be clicked on
Test case 4: Can use AST viewer
- Click on any code location from a previous query to open a source file from a database
- Open the AST viewing panel and click "View AST"
- Once the AST is computed:
- Check that it can be navigated
MRVA
Test Case 1: Running a path problem query and viewing results
-
Open the javascript UnsafeJQueryPlugin query.
-
Run a MRVA against the following repo list:
{ "name": "test-repo-list", "repositories": [ "angular-cn/ng-nice", "apache/hadoop", "apache/hive" ] }
-
Check that a notification message pops up and the results view is opened.
-
Check the query history. It should:
- Show that an item has been added to the query history
- The item should be marked as "in progress".
-
Once the query starts:
- Check the results view
- Check the code paths view, including the code paths drop down menu.
- Check that the repository filter box works
- Click links to files/locations on GitHub
- Check that the query history item is updated to show the number of results
-
Once the query completes:
- Check that the query history item is updated to show the query status as "complete"
Test Case 2: Running a problem query and viewing results
-
Open the javascript ReDoS query.
-
Run a MRVA against the "Top 10" repositories.
-
Check that a notification message pops up and the results view is opened.
-
Check the query history. It should:
- Show that an item has been added to the query history
- The item should be marked as "in progress".
-
Once the query completes:
- Check that the results are rendered with an alert message and a highlighted code snippet:
Test Case 3: Running a non-problem query and viewing results
-
Open the cpp FunLinesOfCode query.
-
Run a MRVA against a single repository (e.g.
google/brotli
). -
Check that a notification message pops up and the results view is opened.
-
Check the query history. It should:
- Show that an item has been added to the query history
- The item should be marked as "in progress".
-
Once the query completes:
- Check that the results show up in a table:
Test Case 4: Interacting with query history
- Click a history item (for MRVA):
- Check that exporting results works
- Check that sorting results works
- Check that copying repo lists works
- Click "Open Results Directory":
- Check that the correct directory is opened and there are results in it
- Click "View Logs":
- Check that the correct workflow is opened
Test Case 5: Canceling a variant analysis run
Run one of the above MRVAs, but cancel it from within VS Code:
- Check that the query is canceled and the query history item is updated.
- Check that the workflow run is also canceled.
- Check that any available results are visible in VS Code.
CodeQL Model Editor
Test Case 1: Opening the model editor
- Download the
sofastack/sofa-jraft
java database from GitHub. - Open the Model Editor with the "CodeQL: Open CodeQL Model Editor" command from the command palette.
- Check that the editor loads and shows methods to model.
- Check that methods are grouped per library (e.g.
rocksdbjni@7.7.3
orasm@6.0
) - Check that the "Open source" link works.
- Check that the 'View' button works and the Method Usage panel highlight the correct method and usage
- Check that the Method Modeling panel shows the correct method and modeling state
Test Case 2: Model methods
- Expand one of the libraries.
- Change the model type and check that the other dropdowns change.
- Check that the method modeling panel updates accordingly
- Save the modeled methods.
- Click "Open extension pack"
- Check that the file explorer opens a directory with a "models" directory
- Open the ".model.yml" file corresponding to the library that was changed.
- Check that the file contains entries for the methods that were modeled.
Test Case 3: Model with AI
Note that this test requires the feature flag: codeQL.model.llmGeneration
A package that the AI normally gives models for is javax.servlet-api
from the jhy/jsoup
repository.
- Click "Model with AI".
- Check that rows change to "Thinking".
- Check that results come back and rows get filled out.
Test Case 4: Model as dependency
Note that this test requires the feature flag: codeQL.model.flowGeneration
- Click "Model as dependency"
- Check that grouping are now per package (e.g.
com.alipay.sofa.rraft.option
orcom.google.protobuf
)
- Check that grouping are now per package (e.g.
- Click "Generate".
- Check that rows are filled out.
GitHub database download
Test case 1: Download a database
Open a clone of the github/codeql
repository as a folder.
-
Wait a few seconds until the CodeQL extension is fully initialized.
-
Click "Download".
-
Select the "C#" and "JavaScript" databases.
- Check that there are separate notifications for both downloads.
- Check that both databases are added when the downloads are complete.
General
Test case 1: Change to a different colour theme
Open at least one of the above MRVAs and at least one local query, then try changing to a different colour theme and check that everything looks sensible. Are there any components that are not showing up?
Optional Test Cases
Modeling Flow
- Check that a method can have multiple models:
- Add a couple of new models for one method in the model editor
- Save and check that the modeling file (use the 'open extension pack' button to open it) shows multiple methods
- Check that the Method Modeling Panel shows the correct multiple models
- Check that you can browse through different models in the Method Modeling Panel
- Check that a 'duplicated classification' error appears in both model editor and modeling panel when a duplicate modeling occurs
- Check that a 'conflicting classification' error appears when a neutral model type is paired with a model of the same kind
- Check that clicking on the error highlights the correct modeling in both the editor and the modeling panel
- Check the Method Usage Panel
- Check that the Method Usage Panel opens and jumps to the correct usage when clicking on 'View' in the model editor
- Check that the first and following usages are opening when clicking on a usage
- Check that the usage icon color turns green when saving a newly modeled method
- Check that the usage icon color turns red when saving a newly unmodeld method
- Check the Method Modeling Panel
- Check that the 'Start modeling' button opens a new model editor
- Check that it refreshes the blank state when a model editor is opened/closed
- Check that when modeling in the editor the modeling panel updates accordingly
- Check that when modeling in the modeling panel the model editor updates accordingly
Selecting MRVA repositories to run on
Test case 1: Running a query on a single repository
- When the repository exists and is public
- Has a CodeQL database for the correct language
- Has a CodeQL database for another language
- Does not have any CodeQL databases
- When the repository exists and is private
- Is accessible and has a CodeQL database
- Is not accessible
- When the repository does not exist
Test case 2: Running a query on a custom repository list
- The repository list is non-empty
- All repositories in the list have a CodeQL database
- Some but not all repositories in the list have a CodeQL database
- No repositories in the list have a CodeQL database
- The repository list is empty
Test case 3: Running a query on all repositories in an organization
- The org exists
- The org contains repositories that have CodeQL databases
- The org contains repositories of the right language but without CodeQL databases
- The org contains repositories not of the right language
- The org contains private repositories that are inaccessible
- The org does not exist
Using different types of controller repos for MRVA
Test case 1: Running a query when the controller repository is public
- Can run queries on public repositories
- Can not run queries on private repositories
Test case 2: Running a query when the controller repository is private
- Can run queries on public repositories
- Can run queries on private repositories
Test case 3: Running a query when the controller repo exists but you do not have write access
- Cannot run queries
Test case 4: Running a query when the controller repo doesn’t exist
- Cannot run queries
Test case 5: Running a query when the "config field" for the controller repo is not set
- Cannot run queries
Query History
This requires running a MRVA query and viewing the query history.
The first test case specifies actions that you can do when the query is first run and is in "pending" state. We start with this since it has quite a limited number of actions you can do.
Test case 1: When variant analysis state is "pending"
- Starts monitoring variant analysis
- Cannot open query history item
- Can delete a query history item
- Item is removed from list in UI
- Files on dist are deleted (can get to files using "open query directory")
- Can sort query history items
- By name
- By query date
- By result count
- Cannot open query directory
- Can open query that produced these results
- When the file still exists and has not moved
- When the file does not exist
- Cannot view logs
- Cannot copy repository list
- Cannot export results
- Cannot select to create a gist
- Cannot select to save as markdown
- Cannot cancel analysis
Test case 2: When the variant analysis state is not "pending"
- Query history is loaded when VSCode starts
- Handles when action workflow was canceled while VSCode was closed
- Can open query history item
- Manually by clicking on them
- Automatically when VSCode starts (if they were open when VSCode was last used)
- Can delete a query history item
- Item is removed from list in UI
- Files on dist are deleted (can get to files using "open query directory")
- Can sort query history items
- By name
- By query date
- By result count
- Can open query directory
- Can open query that produced these results
- When the file still exists and has not moved
- When the file does not exist
- Can view logs
- Can copy repository list
- Text is copied to clipboard
- Text is a valid repository list
- Can export results
- Can select to create gist
- A gist is created
- The first thing in the gist is a summary
- Contains a file for each repository with results
- A popup links you to the gist
- Can select to save as markdown
- A directory is created on disk
- Contains a summary file
- Contains a file for each repository with results
- A popup allows you to open the directory
Test case 3: When variant analysis state is "in_progress"
- Starts monitoring variant analysis
- Ready results are downloaded
- Can cancel analysis
- Causes the actions run to be canceled
Test case 4: When variant analysis state is in final state ("succeeded"/"failed"/"canceled")
- Stops monitoring variant analysis
- All results are downloaded if state is succeeded
- Otherwise, ready results are downloaded, if any are available
- Cannot cancel analysis
MRVA results view
This requires running a MRVA query and seeing the results view.
Test case 1: When variant analysis state is "pending"
- Can open a results view
- Results view opens automatically
- When starting variant analysis run
- When VSCode opens (if view was open when VSCode was closed)
- Results view is empty
Test case 2: When variant analysis state is not "pending"
- Can open a results view
- Results view opens automatically
- When starting variant analysis run
- When VSCode opens (if view was open when VSCode was closed)
- Can copy repository list
- Text is copied to clipboard
- Text is a valid repository list
- Can export results
- Only includes repos that you have selected (also see section from query history)
- Can cancel analysis
- Can open query file
- When the file still exists and has not moved
- When the file does not exist
- Can open query text
- Can sort repos
- Alphabetically
- By number of results
- By popularity
- Can filter repos
- Shows correct statistics
- Total number of results
- Total number of repositories
- Duration
- Can see live results
- Results appear in extension as soon as each query is completed
- Can view interpreted results (i.e. for a "problem" query)
- Can view non-path results
- Can view code paths for "path-problem" queries
- Can view raw results (i.e. for a non "problem" query)
- Renders a table
- Can see skipped repositories
- Can see repos with no db in a tab
- Shown warning that explains the tab
- Can see repos with no access in a tab
- Shown warning that explains the tab
- Only shows tab when there are skipped repos
- Can see repos with no db in a tab
- Result downloads
- All results are downloaded automatically
- Download status is indicated by a spinner (Not currently any indication of progress beyond "downloading" and "not downloading")
- Only 3 items are downloaded at a time
- Results for completed queries are still downloaded when
- Some but not all queries failed
- The variant analysis was canceled after some queries completed
Test case 3: When variant analysis state is in "succeeded" state
- Can view logs
- All results are downloaded
Test case 4: When variant analysis is in "failed" or "canceled" state
- Can view logs
- Results for finished queries are still downloaded.
MRVA repositories panel
- Add a list
- Add a database at the top level
- Add a database to a list
- Add a the same database at a top-level and in a list
- Delete a list
- Delete a database from the top level
- Delete a database from a list
- Add an owner
- Remove an owner
- Rename a list
- Open on GitHub
- Select a list (via "Select" button and via context menu action)
- Run MRVA against a user-defined list
- Run MRVA against a top-N list
- Run MRVA against an owner
- Run MRVA against a database
- Copy repo list
- Open config file
- Make changes via config file (ensure JSON schema is helping out)
- Close and re-open VS Code (ensure lists are there)
- Collapse/expand tree nodes
- Create a new list, right click and select "Add repositories with GitHub Code Search". Enter the language 'python' and the query "UserMixin". This should show a rate limiting notification after a while but eventually populate the list with roughly 770 items.
Error cases that trigger an error notification:
- Try to add a list with a name that already exists
- Try to add a top-level database that already exists
- 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):
- Edit the db config file directly and save invalid JSON
- Edit the db config file directly and save valid JSON but invalid config (e.g. add an unknown property)
- Edit the db config file directly and save two lists with the same name
Cases where there the welcome view is shown:
- No controller repo is set in the user's settings JSON.