Skip to content

Commit b4e7444

Browse files
committed
Fix tests
1 parent c48eda8 commit b4e7444

3 files changed

Lines changed: 33 additions & 15 deletions

File tree

src/test/github/copilotRemoteAgent.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { GitHubRemote } from '../../common/remote';
1919
import { Protocol } from '../../common/protocol';
2020
import { GitHubServerType } from '../../common/authentication';
2121
import { ReposManagerState } from '../../github/folderRepositoryManager';
22-
import { CopilotPRStatus } from '../../common/copilot';
2322
import { GitApiImpl } from '../../api/api1';
2423
import { MockPrsTreeModel } from '../mocks/mockPRsTreeModel';
2524
import { PrsTreeModel } from '../../view/prsTreeModel';

src/test/mocks/mockPRsTreeModel.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,39 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Event, Disposable } from "vscode";
6+
import { Event, Disposable, EventEmitter } from "vscode";
77
import { CopilotPRStatus } from "../../common/copilot";
8-
import { CopilotStateModel } from "../../github/copilotPrWatcher";
8+
import { CodingAgentPRAndStatus, CopilotStateModel } from "../../github/copilotPrWatcher";
99
import { FolderRepositoryManager, ItemsResponseResult } from "../../github/folderRepositoryManager";
1010
import { PullRequestChangeEvent } from "../../github/githubRepository";
1111
import { PullRequestModel } from "../../github/pullRequestModel";
1212
import { PRStatusChange, PrsTreeModel } from "../../view/prsTreeModel";
1313
import { TreeNode } from "../../view/treeNodes/treeNode";
1414

1515
export class MockPrsTreeModel implements Partial<PrsTreeModel> {
16-
public onDidChangePrStatus: Event<string[]>;
17-
public onDidChangeData: Event<void | FolderRepositoryManager | PullRequestChangeEvent[]>;
16+
onDidChangeCopilotStates: Event<void> = new EventEmitter<void>().event;
17+
onDidChangeCopilotNotifications: Event<PullRequestModel[]> = new EventEmitter<PullRequestModel[]>().event;
18+
clearCopilotCaches(): false | undefined {
19+
throw new Error("Method not implemented.");
20+
}
21+
async refreshCopilotStateChanges(clearCache?: boolean): Promise<boolean> {
22+
return false;
23+
}
24+
getCopilotPullRequests(clearCache?: boolean): Promise<CodingAgentPRAndStatus[]> {
25+
throw new Error("Method not implemented.");
26+
}
27+
public onDidChangePrStatus: Event<string[]> = new EventEmitter<string[]>().event;
28+
public onDidChangeData: Event<void | FolderRepositoryManager | PullRequestChangeEvent[]> = new EventEmitter<void>().event;
1829
public onLoaded: Event<void>;
1930
public copilotStateModel: CopilotStateModel;
2031
public updateExpandedQueries(element: TreeNode, isExpanded: boolean): void {
2132
throw new Error("Method not implemented.");
2233
}
2334
get expandedQueries(): Set<string> | undefined {
24-
throw new Error("Method not implemented.");
35+
return new Set<string>(['All Open']);
2536
}
2637
get hasLoaded(): boolean {
27-
throw new Error("Method not implemented.");
38+
return true;
2839
}
2940
set hasLoaded(value: boolean) {
3041
throw new Error("Method not implemented.");
@@ -41,8 +52,12 @@ export class MockPrsTreeModel implements Partial<PrsTreeModel> {
4152
public clearCache(silent?: boolean): void {
4253
throw new Error("Method not implemented.");
4354
}
44-
getLocalPullRequests(folderRepoManager: FolderRepositoryManager, update?: boolean): Promise<ItemsResponseResult<PullRequestModel>> {
45-
throw new Error("Method not implemented.");
55+
async getLocalPullRequests(folderRepoManager: FolderRepositoryManager, update?: boolean): Promise<ItemsResponseResult<PullRequestModel>> {
56+
return {
57+
hasMorePages: false,
58+
items: this._localPullRequests,
59+
hasUnsearchedRepositories: false
60+
};
4661
}
4762
getPullRequestsForQuery(folderRepoManager: FolderRepositoryManager, fetchNextPage: boolean, query: string): Promise<ItemsResponseResult<PullRequestModel>> {
4863
throw new Error("Method not implemented.");
@@ -51,10 +66,10 @@ export class MockPrsTreeModel implements Partial<PrsTreeModel> {
5166
throw new Error("Method not implemented.");
5267
}
5368
getCopilotNotificationsCount(owner: string, repo: string): number {
54-
throw new Error("Method not implemented.");
69+
return 0;
5570
}
5671
get copilotNotificationsCount(): number {
57-
throw new Error("Method not implemented.");
72+
return 0;
5873
}
5974
clearAllCopilotNotifications(owner?: string, repo?: string): void {
6075
throw new Error("Method not implemented.");
@@ -86,4 +101,8 @@ export class MockPrsTreeModel implements Partial<PrsTreeModel> {
86101
throw new Error("Method not implemented.");
87102
}
88103

104+
private _localPullRequests: PullRequestModel[] = [];
105+
addLocalPullRequest(pr: PullRequestModel): void {
106+
this._localPullRequests.push(pr);
107+
}
89108
}

src/test/view/prsTree.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ describe('GitHub Pull Requests view', function () {
5050
let mockThemeWatcher: MockThemeWatcher;
5151
let gitAPI: GitApiImpl;
5252
let mockNotificationsManager: MockNotificationManager;
53-
let mockPrsTreeModel: PrsTreeModel;
53+
let prsTreeModel: PrsTreeModel;
5454

5555
beforeEach(function () {
5656
sinon = createSandbox();
5757
MockCommandRegistry.install(sinon);
5858
mockThemeWatcher = new MockThemeWatcher();
59-
mockPrsTreeModel = new MockPrsTreeModel() as unknown as PrsTreeModel;
6059

6160
context = new MockExtensionContext();
6261

@@ -65,10 +64,11 @@ describe('GitHub Pull Requests view', function () {
6564
credentialStore,
6665
telemetry,
6766
);
67+
prsTreeModel = new PrsTreeModel(telemetry, reposManager, context);
6868
credentialStore = new CredentialStore(telemetry, context);
6969
gitAPI = new GitApiImpl(reposManager);
70-
copilotManager = new CopilotRemoteAgentManager(credentialStore, reposManager, telemetry, context, gitAPI, mockPrsTreeModel);
71-
provider = new PullRequestsTreeDataProvider(mockPrsTreeModel, telemetry, context, reposManager, copilotManager);
70+
copilotManager = new CopilotRemoteAgentManager(credentialStore, reposManager, telemetry, context, gitAPI, prsTreeModel);
71+
provider = new PullRequestsTreeDataProvider(prsTreeModel, telemetry, context, reposManager, copilotManager);
7272
mockNotificationsManager = new MockNotificationManager();
7373
createPrHelper = new CreatePullRequestHelper();
7474

0 commit comments

Comments
 (0)