-
Notifications
You must be signed in to change notification settings - Fork 120
Chore/dbt-integration-tests #1718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
saravmajestic
wants to merge
4
commits into
feat/extract-dbt-project
Choose a base branch
from
chore/dbt-integration-tests
base: feat/extract-dbt-project
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,114 +1 @@ | ||
| import "reflect-metadata"; | ||
|
|
||
| // Set up the container before tests | ||
| import "../inversify.config"; | ||
| import { MockEventEmitter } from "./common"; | ||
|
|
||
| // Mock VS Code APIs before any imports | ||
| jest.mock("vscode", () => ({ | ||
| EventEmitter: jest.fn().mockImplementation(() => new MockEventEmitter()), | ||
| workspace: { | ||
| getConfiguration: jest.fn().mockReturnValue({ | ||
| get: jest.fn(), | ||
| update: jest.fn(), | ||
| }), | ||
| workspaceFolders: [], | ||
| onDidChangeConfiguration: jest.fn(), | ||
| onDidChangeWorkspaceFolders: jest.fn().mockImplementation((callback) => ({ | ||
| dispose: jest.fn(), | ||
| })), | ||
| createFileSystemWatcher: jest.fn().mockReturnValue({ | ||
| onDidChange: jest.fn(), | ||
| onDidCreate: jest.fn(), | ||
| onDidDelete: jest.fn(), | ||
| dispose: jest.fn(), | ||
| }), | ||
| }, | ||
| commands: { | ||
| getCommands: jest.fn().mockResolvedValue([]), | ||
| registerCommand: jest.fn(), | ||
| executeCommand: jest.fn(), | ||
| }, | ||
| window: { | ||
| showInformationMessage: jest.fn(), | ||
| showErrorMessage: jest.fn(), | ||
| createTerminal: jest.fn().mockReturnValue({ | ||
| dispose: jest.fn(), | ||
| hide: jest.fn(), | ||
| show: jest.fn(), | ||
| sendText: jest.fn(), | ||
| }), | ||
| createOutputChannel: jest.fn().mockReturnValue({ | ||
| appendLine: jest.fn(), | ||
| show: jest.fn(), | ||
| clear: jest.fn(), | ||
| dispose: jest.fn(), | ||
| info: jest.fn(), | ||
| warn: jest.fn(), | ||
| error: jest.fn(), | ||
| }), | ||
| }, | ||
| languages: { | ||
| createDiagnosticCollection: jest.fn().mockReturnValue({ | ||
| set: jest.fn(), | ||
| delete: jest.fn(), | ||
| clear: jest.fn(), | ||
| dispose: jest.fn(), | ||
| }), | ||
| }, | ||
| Uri: { | ||
| file: jest.fn((f: string) => ({ fsPath: f })), | ||
| parse: jest.fn(), | ||
| }, | ||
| DiagnosticSeverity: { | ||
| Error: 0, | ||
| Warning: 1, | ||
| Information: 2, | ||
| Hint: 3, | ||
| }, | ||
| Disposable: { | ||
| from: jest.fn(), | ||
| }, | ||
| ExtensionKind: { | ||
| UI: 1, | ||
| Workspace: 2, | ||
| }, | ||
| Diagnostic: jest.fn().mockImplementation((range, message, severity) => ({ | ||
| range, | ||
| message, | ||
| severity, | ||
| })), | ||
| Range: jest | ||
| .fn() | ||
| .mockImplementation((startLine, startChar, endLine, endChar) => ({ | ||
| start: { line: startLine, character: startChar }, | ||
| end: { line: endLine, character: endChar }, | ||
| })), | ||
| Position: jest.fn().mockImplementation((line, character) => ({ | ||
| line, | ||
| character, | ||
| })), | ||
| TreeItemCollapsibleState: { | ||
| None: 0, | ||
| Collapsed: 1, | ||
| Expanded: 2, | ||
| }, | ||
| TreeItem: jest.fn().mockImplementation((label, collapsibleState) => ({ | ||
| label, | ||
| collapsibleState, | ||
| })), | ||
| CancellationTokenSource: jest.fn().mockImplementation(() => ({ | ||
| token: { | ||
| onCancellationRequested: jest.fn(), | ||
| isCancellationRequested: false, | ||
| }, | ||
| cancel: jest.fn(), | ||
| dispose: jest.fn(), | ||
| })), | ||
| CancellationToken: { | ||
| None: { | ||
| onCancellationRequested: jest.fn(), | ||
| isCancellationRequested: false, | ||
| }, | ||
| }, | ||
| })); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The
window.withProgressmock is incomplete. It fails to pass the requiredtokenargument to thetaskfunction, which will cause a crash in production code that handles cancellation.Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The mock implementation of
window.withProgressinsrc/test/mock/vscode.tscalls the providedtaskfunction without the required arguments. Production code insrc/dbt_client/dbtProject.tsexpects thistaskto receive atokenobject as its second argument and subsequently callstoken.onCancellationRequested. Because the mock passesundefinedinstead of atokenobject, any operation that uses this progress indicator (e.g.,runModel,buildModel) will crash with a "Cannot read property 'onCancellationRequested' of undefined" error. This issue is not detected by the test suite because the specific code paths are not tested.💡 Suggested Fix
Update the
withProgressmock to call thetaskfunction with the two expected arguments: a mockprogressobject and a mocktokenobject. Thetokenobject should have a mockonCancellationRequestedfunction. For example:task({ report: jest.fn() }, { onCancellationRequested: jest.fn() }).🤖 Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:
7737468