Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ |
| 2 | /** |
| 3 | * @license |
Ben Rohlfs | 94fcbbc | 2022-05-27 10:45:03 +0200 | [diff] [blame] | 4 | * Copyright 2020 Google LLC |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 6 | */ |
Ben Rohlfs | a9d2cff | 2021-01-22 21:33:58 +0100 | [diff] [blame] | 7 | import {RestApiService} from '../../services/gr-rest-api/gr-rest-api'; |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 8 | import { |
| 9 | AccountDetailInfo, |
| 10 | AccountExternalIdInfo, |
| 11 | AccountInfo, |
| 12 | ServerInfo, |
| 13 | ProjectInfo, |
| 14 | AccountCapabilityInfo, |
| 15 | SuggestedReviewerInfo, |
| 16 | GroupNameToGroupInfoMap, |
| 17 | ParsedJSON, |
| 18 | EditPreferencesInfo, |
| 19 | SshKeyInfo, |
| 20 | RepoName, |
| 21 | GpgKeyInfo, |
| 22 | PreferencesInfo, |
| 23 | EmailInfo, |
| 24 | ProjectAccessInfo, |
| 25 | CapabilityInfoMap, |
| 26 | ChangeInfo, |
| 27 | ProjectInfoWithName, |
| 28 | GroupInfo, |
| 29 | BranchInfo, |
| 30 | ConfigInfo, |
| 31 | EditInfo, |
| 32 | DashboardInfo, |
Ben Rohlfs | bfc688b | 2022-10-21 12:38:37 +0200 | [diff] [blame] | 33 | RepoAccessInfoMap, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 34 | IncludedInInfo, |
| 35 | CommentInfo, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 36 | PluginInfo, |
| 37 | DocResult, |
| 38 | ContributorAgreementInfo, |
| 39 | Password, |
| 40 | ProjectWatchInfo, |
| 41 | NameToProjectInfoMap, |
| 42 | GroupAuditEventInfo, |
| 43 | Base64FileContent, |
| 44 | TagInfo, |
| 45 | RelatedChangesInfo, |
| 46 | SubmittedTogetherInfo, |
| 47 | FilePathToDiffInfoMap, |
| 48 | BlameInfo, |
| 49 | ImagesForDiff, |
| 50 | ActionNameToActionInfoMap, |
| 51 | Hashtag, |
| 52 | FileNameToFileInfoMap, |
| 53 | TopMenuEntryInfo, |
| 54 | MergeableInfo, |
| 55 | CommitInfo, |
| 56 | GroupId, |
| 57 | GroupName, |
| 58 | UrlEncodedRepoName, |
Dhruv Srivastava | b0cebc1 | 2022-03-08 15:16:57 +0100 | [diff] [blame] | 59 | NumericChangeId, |
Ben Rohlfs | 75b390c | 2022-04-04 14:56:06 +0200 | [diff] [blame] | 60 | PreferencesInput, |
Ben Rohlfs | ba44082 | 2023-04-11 18:08:03 +0200 | [diff] [blame] | 61 | DraftInfo, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 62 | } from '../../types/common'; |
| 63 | import {DiffInfo, DiffPreferencesInfo} from '../../types/diff'; |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 64 | import {readResponsePayload} from '../../elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper'; |
| 65 | import { |
| 66 | createAccountDetailWithId, |
| 67 | createChange, |
| 68 | createCommit, |
| 69 | createConfig, |
Ben Rohlfs | 8a87546 | 2023-02-27 10:33:21 +0100 | [diff] [blame] | 70 | createMergeable, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 71 | createServerInfo, |
Milutin Kristofic | f4c04fb4 | 2021-03-10 16:41:19 +0100 | [diff] [blame] | 72 | createSubmittedTogetherInfo, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 73 | } from '../test-data-generators'; |
| 74 | import { |
| 75 | createDefaultDiffPrefs, |
| 76 | createDefaultEditPrefs, |
Chris Poucet | de94555a | 2023-08-14 11:42:06 +0200 | [diff] [blame] | 77 | createDefaultPreferences, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 78 | } from '../../constants/constants'; |
Ben Rohlfs | a00ef28 | 2021-01-22 21:45:53 +0100 | [diff] [blame] | 79 | import {ParsedChangeInfo} from '../../types/types'; |
Dhruv Srivastava | 748a76b | 2023-03-02 15:49:56 +0100 | [diff] [blame] | 80 | import {getBaseUrl} from '../../utils/url-util'; |
| 81 | import { |
| 82 | DOCS_BASE_PATH, |
| 83 | PROBE_PATH, |
| 84 | } from '../../services/gr-rest-api/gr-rest-api-impl'; |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 85 | |
| 86 | export const grRestApiMock: RestApiService = { |
| 87 | addAccountEmail(): Promise<Response> { |
| 88 | return Promise.resolve(new Response()); |
| 89 | }, |
| 90 | addAccountGPGKey(): Promise<Record<string, GpgKeyInfo>> { |
| 91 | return Promise.resolve({}); |
| 92 | }, |
| 93 | addAccountSSHKey(): Promise<SshKeyInfo> { |
| 94 | throw new Error('addAccountSSHKey() not implemented by RestApiMock.'); |
| 95 | }, |
| 96 | addToAttentionSet(): Promise<Response> { |
| 97 | return Promise.resolve(new Response()); |
| 98 | }, |
| 99 | applyFixSuggestion(): Promise<Response> { |
| 100 | return Promise.resolve(new Response()); |
| 101 | }, |
Milutin Kristofic | c450493 | 2022-08-02 14:55:35 +0200 | [diff] [blame] | 102 | applyRobotFixSuggestion(): Promise<Response> { |
| 103 | return Promise.resolve(new Response()); |
| 104 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 105 | awaitPendingDiffDrafts(): Promise<void> { |
| 106 | return Promise.resolve(); |
| 107 | }, |
| 108 | confirmEmail(): Promise<string | null> { |
| 109 | return Promise.resolve(''); |
| 110 | }, |
| 111 | createChange(): Promise<ChangeInfo | undefined> { |
| 112 | throw new Error('createChange() not implemented by RestApiMock.'); |
| 113 | }, |
| 114 | createGroup(): Promise<Response> { |
| 115 | return Promise.resolve(new Response()); |
| 116 | }, |
| 117 | createRepo(): Promise<Response> { |
| 118 | return Promise.resolve(new Response()); |
| 119 | }, |
| 120 | createRepoBranch(): Promise<Response> { |
| 121 | return Promise.resolve(new Response()); |
| 122 | }, |
| 123 | createRepoTag(): Promise<Response> { |
| 124 | return Promise.resolve(new Response()); |
| 125 | }, |
Chris Poucet | 29f8ba8 | 2023-06-26 17:11:12 +0200 | [diff] [blame] | 126 | deleteAccount(): Promise<Response> { |
| 127 | return Promise.resolve(new Response()); |
| 128 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 129 | deleteAccountEmail(): Promise<Response> { |
| 130 | return Promise.resolve(new Response()); |
| 131 | }, |
| 132 | deleteAccountGPGKey(): Promise<Response> { |
| 133 | return Promise.resolve(new Response()); |
| 134 | }, |
| 135 | deleteAccountIdentity(): Promise<unknown> { |
| 136 | return Promise.resolve(new Response()); |
| 137 | }, |
| 138 | deleteAccountSSHKey(): void {}, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 139 | deleteChangeCommitMessage(): Promise<Response> { |
| 140 | return Promise.resolve(new Response()); |
| 141 | }, |
| 142 | deleteComment(): Promise<CommentInfo> { |
| 143 | throw new Error('deleteComment() not implemented by RestApiMock.'); |
| 144 | }, |
| 145 | deleteDiffDraft(): Promise<Response> { |
| 146 | return Promise.resolve(new Response()); |
| 147 | }, |
| 148 | deleteDraftComments(): Promise<Response> { |
| 149 | return Promise.resolve(new Response()); |
| 150 | }, |
| 151 | deleteFileInChangeEdit(): Promise<Response | undefined> { |
| 152 | return Promise.resolve(new Response()); |
| 153 | }, |
| 154 | deleteGroupMember(): Promise<Response> { |
| 155 | return Promise.resolve(new Response()); |
| 156 | }, |
| 157 | deleteIncludedGroup(): Promise<Response> { |
| 158 | return Promise.resolve(new Response()); |
| 159 | }, |
| 160 | deleteRepoBranches(): Promise<Response> { |
| 161 | return Promise.resolve(new Response()); |
| 162 | }, |
| 163 | deleteRepoTags(): Promise<Response> { |
| 164 | return Promise.resolve(new Response()); |
| 165 | }, |
| 166 | deleteVote(): Promise<Response> { |
| 167 | return Promise.resolve(new Response()); |
| 168 | }, |
| 169 | deleteWatchedProjects(): Promise<Response> { |
| 170 | return Promise.resolve(new Response()); |
| 171 | }, |
| 172 | executeChangeAction(): Promise<Response | undefined> { |
| 173 | return Promise.resolve(new Response()); |
| 174 | }, |
Chris Poucet | 55cbccb | 2021-11-16 03:17:06 +0100 | [diff] [blame] | 175 | finalize(): void {}, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 176 | generateAccountHttpPassword(): Promise<Password> { |
| 177 | return Promise.resolve('asdf'); |
| 178 | }, |
| 179 | getAccount(): Promise<AccountDetailInfo | undefined> { |
| 180 | return Promise.resolve(createAccountDetailWithId(1)); |
| 181 | }, |
| 182 | getAccountAgreements(): Promise<ContributorAgreementInfo[] | undefined> { |
| 183 | return Promise.resolve([]); |
| 184 | }, |
| 185 | getAccountCapabilities(): Promise<AccountCapabilityInfo | undefined> { |
| 186 | return Promise.resolve({}); |
| 187 | }, |
| 188 | getAccountDetails(): Promise<AccountDetailInfo | undefined> { |
| 189 | return Promise.resolve(createAccountDetailWithId(1)); |
| 190 | }, |
| 191 | getAccountEmails(): Promise<EmailInfo[] | undefined> { |
| 192 | return Promise.resolve([]); |
| 193 | }, |
Kaushik Lingarkar | 2c68bf7 | 2023-06-06 15:20:01 -0700 | [diff] [blame^] | 194 | getAccountEmailsFor(): Promise<EmailInfo[] | undefined> { |
| 195 | return Promise.resolve([]); |
| 196 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 197 | getAccountGPGKeys(): Promise<Record<string, GpgKeyInfo>> { |
| 198 | return Promise.resolve({}); |
| 199 | }, |
| 200 | getAccountGroups(): Promise<GroupInfo[] | undefined> { |
| 201 | return Promise.resolve([]); |
| 202 | }, |
| 203 | getAccountSSHKeys(): Promise<SshKeyInfo[] | undefined> { |
| 204 | return Promise.resolve([]); |
| 205 | }, |
| 206 | getAccountStatus(): Promise<string | undefined> { |
| 207 | return Promise.resolve(''); |
| 208 | }, |
| 209 | getAvatarChangeUrl(): Promise<string | undefined> { |
| 210 | return Promise.resolve(''); |
| 211 | }, |
| 212 | getBlame(): Promise<BlameInfo[] | undefined> { |
| 213 | return Promise.resolve([]); |
| 214 | }, |
| 215 | getCapabilities(): Promise<CapabilityInfoMap | undefined> { |
| 216 | return Promise.resolve({}); |
| 217 | }, |
Kamil Musin | 3fb732f | 2023-08-25 15:48:09 +0200 | [diff] [blame] | 218 | getChange(): Promise<ChangeInfo | undefined> { |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 219 | throw new Error('getChange() not implemented by RestApiMock.'); |
| 220 | }, |
| 221 | getChangeActionURL(): Promise<string> { |
| 222 | return Promise.resolve(''); |
| 223 | }, |
| 224 | getChangeCherryPicks(): Promise<ChangeInfo[] | undefined> { |
| 225 | return Promise.resolve([]); |
| 226 | }, |
| 227 | getChangeCommitInfo(): Promise<CommitInfo | undefined> { |
| 228 | return Promise.resolve(createCommit()); |
| 229 | }, |
| 230 | getChangeConflicts(): Promise<ChangeInfo[] | undefined> { |
| 231 | return Promise.resolve([]); |
| 232 | }, |
Ben Rohlfs | a16c51a | 2021-11-22 12:50:55 +0100 | [diff] [blame] | 233 | getChangeDetail( |
| 234 | changeNum?: number | string |
Ben Rohlfs | 1fe7f4d | 2021-12-06 11:21:49 +0100 | [diff] [blame] | 235 | ): Promise<ParsedChangeInfo | undefined> { |
Ben Rohlfs | a16c51a | 2021-11-22 12:50:55 +0100 | [diff] [blame] | 236 | if (changeNum === undefined) return Promise.resolve(undefined); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 237 | return Promise.resolve(createChange() as ParsedChangeInfo); |
| 238 | }, |
Ben Rohlfs | cb1e256 | 2021-12-06 10:50:47 +0100 | [diff] [blame] | 239 | getChangeEdit(): Promise<EditInfo | undefined> { |
| 240 | return Promise.resolve(undefined); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 241 | }, |
| 242 | getChangeFiles(): Promise<FileNameToFileInfoMap | undefined> { |
| 243 | return Promise.resolve({}); |
| 244 | }, |
| 245 | getChangeIncludedIn(): Promise<IncludedInInfo | undefined> { |
| 246 | throw new Error('getChangeIncludedIn() not implemented by RestApiMock.'); |
| 247 | }, |
| 248 | getChangeOrEditFiles(): Promise<FileNameToFileInfoMap | undefined> { |
| 249 | return Promise.resolve({}); |
| 250 | }, |
| 251 | getChangeRevisionActions(): Promise<ActionNameToActionInfoMap | undefined> { |
| 252 | return Promise.resolve({}); |
| 253 | }, |
| 254 | getChangeSuggestedCCs(): Promise<SuggestedReviewerInfo[] | undefined> { |
| 255 | return Promise.resolve([]); |
| 256 | }, |
| 257 | getChangeSuggestedReviewers(): Promise<SuggestedReviewerInfo[] | undefined> { |
| 258 | return Promise.resolve([]); |
| 259 | }, |
| 260 | getChanges() { |
| 261 | return Promise.resolve([]); |
| 262 | }, |
Dhruv Srivastava | 41e486f | 2022-03-08 13:44:26 +0100 | [diff] [blame] | 263 | getChangesForMultipleQueries() { |
| 264 | return Promise.resolve([]); |
| 265 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 266 | getChangesSubmittedTogether(): Promise<SubmittedTogetherInfo | undefined> { |
Milutin Kristofic | f4c04fb4 | 2021-03-10 16:41:19 +0100 | [diff] [blame] | 267 | return Promise.resolve(createSubmittedTogetherInfo()); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 268 | }, |
Dhruv Srivastava | b0cebc1 | 2022-03-08 15:16:57 +0100 | [diff] [blame] | 269 | getDetailedChangesWithActions(changeNums: NumericChangeId[]) { |
| 270 | return Promise.resolve( |
| 271 | changeNums.map(changeNum => { |
| 272 | return { |
| 273 | ...createChange(), |
| 274 | actions: {}, |
| 275 | _number: changeNum, |
| 276 | subject: `Subject ${changeNum}`, |
| 277 | }; |
| 278 | }) |
| 279 | ); |
| 280 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 281 | getChangesWithSameTopic(): Promise<ChangeInfo[] | undefined> { |
| 282 | return Promise.resolve([]); |
| 283 | }, |
Milutin Kristofic | fc0f011 | 2021-03-08 14:25:06 +0100 | [diff] [blame] | 284 | getChangesWithSimilarTopic(): Promise<ChangeInfo[] | undefined> { |
| 285 | return Promise.resolve([]); |
| 286 | }, |
Frank Borden | fbe57cb | 2022-05-10 15:59:49 +0200 | [diff] [blame] | 287 | getChangesWithSimilarHashtag(): Promise<ChangeInfo[] | undefined> { |
| 288 | return Promise.resolve([]); |
| 289 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 290 | getConfig(): Promise<ServerInfo | undefined> { |
| 291 | return Promise.resolve(createServerInfo()); |
| 292 | }, |
| 293 | getDashboard(): Promise<DashboardInfo | undefined> { |
Dhruv Srivastava | b642c24 | 2021-06-11 16:33:35 +0200 | [diff] [blame] | 294 | return Promise.resolve(undefined); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 295 | }, |
| 296 | getDefaultPreferences(): Promise<PreferencesInfo | undefined> { |
| 297 | throw new Error('getDefaultPreferences() not implemented by RestApiMock.'); |
| 298 | }, |
| 299 | getDiff(): Promise<DiffInfo | undefined> { |
| 300 | throw new Error('getDiff() not implemented by RestApiMock.'); |
| 301 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 302 | getDiffComments() { |
Chris Poucet | 55cbccb | 2021-11-16 03:17:06 +0100 | [diff] [blame] | 303 | // NOTE: This method can not be typed properly due to overloads. |
| 304 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 305 | return Promise.resolve({}) as any; |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 306 | }, |
| 307 | getDiffDrafts() { |
Chris Poucet | 55cbccb | 2021-11-16 03:17:06 +0100 | [diff] [blame] | 308 | // NOTE: This method can not be typed properly due to overloads. |
| 309 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 310 | return Promise.resolve({}) as any; |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 311 | }, |
| 312 | getDiffPreferences(): Promise<DiffPreferencesInfo | undefined> { |
| 313 | return Promise.resolve(createDefaultDiffPrefs()); |
| 314 | }, |
| 315 | getDiffRobotComments() { |
Chris Poucet | 55cbccb | 2021-11-16 03:17:06 +0100 | [diff] [blame] | 316 | // NOTE: This method can not be typed properly due to overloads. |
| 317 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 318 | return Promise.resolve({}) as any; |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 319 | }, |
Dhruv Srivastava | 748a76b | 2023-03-02 15:49:56 +0100 | [diff] [blame] | 320 | getDocsBaseUrl(config?: ServerInfo): Promise<string | null> { |
| 321 | if (config?.gerrit?.doc_url) { |
| 322 | return Promise.resolve(config.gerrit.doc_url); |
| 323 | } else { |
| 324 | return this.probePath(getBaseUrl() + PROBE_PATH).then(ok => |
| 325 | Promise.resolve(ok ? getBaseUrl() + DOCS_BASE_PATH : null) |
| 326 | ); |
| 327 | } |
| 328 | return Promise.resolve(''); |
| 329 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 330 | getDocumentationSearches(): Promise<DocResult[] | undefined> { |
| 331 | return Promise.resolve([]); |
| 332 | }, |
| 333 | getEditPreferences(): Promise<EditPreferencesInfo | undefined> { |
| 334 | return Promise.resolve(createDefaultEditPrefs()); |
| 335 | }, |
| 336 | getExternalIds(): Promise<AccountExternalIdInfo[] | undefined> { |
| 337 | return Promise.resolve([]); |
| 338 | }, |
| 339 | getFileContent(): Promise<Response | Base64FileContent | undefined> { |
| 340 | return Promise.resolve(new Response()); |
| 341 | }, |
| 342 | getFromProjectLookup(): Promise<RepoName | undefined> { |
| 343 | throw new Error('getFromProjectLookup() not implemented by RestApiMock.'); |
| 344 | }, |
| 345 | getGroupAuditLog(): Promise<GroupAuditEventInfo[] | undefined> { |
| 346 | return Promise.resolve([]); |
| 347 | }, |
| 348 | getGroupConfig(id: GroupId | GroupName): Promise<GroupInfo | undefined> { |
| 349 | return Promise.resolve({ |
| 350 | id: id as GroupId, |
| 351 | }); |
| 352 | }, |
| 353 | getGroupMembers(): Promise<AccountInfo[]> { |
| 354 | return Promise.resolve([]); |
| 355 | }, |
| 356 | getGroups(): Promise<GroupNameToGroupInfoMap | undefined> { |
| 357 | return Promise.resolve({}); |
| 358 | }, |
| 359 | getImagesForDiff(): Promise<ImagesForDiff> { |
| 360 | throw new Error('getImagesForDiff() not implemented by RestApiMock.'); |
| 361 | }, |
| 362 | getIncludedGroup(): Promise<GroupInfo[] | undefined> { |
| 363 | return Promise.resolve([]); |
| 364 | }, |
| 365 | getIsAdmin(): Promise<boolean | undefined> { |
| 366 | return Promise.resolve(false); |
| 367 | }, |
| 368 | getIsGroupOwner(): Promise<boolean> { |
| 369 | return Promise.resolve(false); |
| 370 | }, |
| 371 | getLoggedIn(): Promise<boolean> { |
| 372 | return Promise.resolve(true); |
| 373 | }, |
| 374 | getMergeable(): Promise<MergeableInfo | undefined> { |
Ben Rohlfs | 8a87546 | 2023-02-27 10:33:21 +0100 | [diff] [blame] | 375 | return Promise.resolve(createMergeable()); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 376 | }, |
| 377 | getPlugins(): Promise<{[p: string]: PluginInfo} | undefined> { |
| 378 | return Promise.resolve({}); |
| 379 | }, |
Ben Rohlfs | ba44082 | 2023-04-11 18:08:03 +0200 | [diff] [blame] | 380 | getPortedComments(): Promise<{[path: string]: CommentInfo[]} | undefined> { |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 381 | return Promise.resolve({}); |
| 382 | }, |
Ben Rohlfs | ba44082 | 2023-04-11 18:08:03 +0200 | [diff] [blame] | 383 | getPortedDrafts(): Promise<{[path: string]: DraftInfo[]} | undefined> { |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 384 | return Promise.resolve({}); |
| 385 | }, |
| 386 | getPreferences(): Promise<PreferencesInfo | undefined> { |
Chris Poucet | de94555a | 2023-08-14 11:42:06 +0200 | [diff] [blame] | 387 | return Promise.resolve(createDefaultPreferences()); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 388 | }, |
| 389 | getProjectConfig(): Promise<ConfigInfo | undefined> { |
| 390 | return Promise.resolve(createConfig()); |
| 391 | }, |
| 392 | getRelatedChanges(): Promise<RelatedChangesInfo | undefined> { |
| 393 | return Promise.resolve({changes: []}); |
| 394 | }, |
| 395 | getRepo(repo: RepoName): Promise<ProjectInfo | undefined> { |
| 396 | return Promise.resolve({ |
Chris Poucet | caeea1b | 2021-08-19 22:12:56 +0000 | [diff] [blame] | 397 | id: repo as string as UrlEncodedRepoName, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 398 | name: repo, |
| 399 | }); |
| 400 | }, |
Ben Rohlfs | bfc688b | 2022-10-21 12:38:37 +0200 | [diff] [blame] | 401 | getRepoAccess(): Promise<RepoAccessInfoMap | undefined> { |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 402 | return Promise.resolve({}); |
| 403 | }, |
| 404 | getRepoAccessRights(): Promise<ProjectAccessInfo | undefined> { |
| 405 | return Promise.resolve(undefined); |
| 406 | }, |
| 407 | getRepoBranches(): Promise<BranchInfo[] | undefined> { |
| 408 | return Promise.resolve([]); |
| 409 | }, |
| 410 | getRepoDashboards(): Promise<DashboardInfo[] | undefined> { |
| 411 | return Promise.resolve([]); |
| 412 | }, |
| 413 | getRepoTags(): Promise<TagInfo[]> { |
| 414 | return Promise.resolve([]); |
| 415 | }, |
| 416 | getRepos(): Promise<ProjectInfoWithName[] | undefined> { |
| 417 | return Promise.resolve([]); |
| 418 | }, |
| 419 | getResponseObject(response: Response): Promise<ParsedJSON> { |
| 420 | return readResponsePayload(response).then(payload => payload.parsed); |
| 421 | }, |
| 422 | getReviewedFiles(): Promise<string[] | undefined> { |
| 423 | return Promise.resolve([]); |
| 424 | }, |
Milutin Kristofic | c450493 | 2022-08-02 14:55:35 +0200 | [diff] [blame] | 425 | getFixPreview(): Promise<FilePathToDiffInfoMap | undefined> { |
| 426 | return Promise.resolve({}); |
| 427 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 428 | getRobotCommentFixPreview(): Promise<FilePathToDiffInfoMap | undefined> { |
| 429 | return Promise.resolve({}); |
| 430 | }, |
| 431 | getSuggestedAccounts(): Promise<AccountInfo[] | undefined> { |
| 432 | return Promise.resolve([]); |
| 433 | }, |
| 434 | getSuggestedGroups(): Promise<GroupNameToGroupInfoMap | undefined> { |
| 435 | return Promise.resolve({}); |
| 436 | }, |
Ben Rohlfs | bfc688b | 2022-10-21 12:38:37 +0200 | [diff] [blame] | 437 | getSuggestedRepos(): Promise<NameToProjectInfoMap | undefined> { |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 438 | return Promise.resolve({}); |
| 439 | }, |
| 440 | getTopMenus(): Promise<TopMenuEntryInfo[] | undefined> { |
| 441 | return Promise.resolve([]); |
| 442 | }, |
| 443 | getVersion(): Promise<string | undefined> { |
| 444 | return Promise.resolve(''); |
| 445 | }, |
| 446 | getWatchedProjects(): Promise<ProjectWatchInfo[] | undefined> { |
| 447 | return Promise.resolve([]); |
| 448 | }, |
| 449 | hasPendingDiffDrafts(): number { |
| 450 | return 0; |
| 451 | }, |
| 452 | invalidateAccountsCache(): void {}, |
| 453 | invalidateGroupsCache(): void {}, |
| 454 | invalidateReposCache(): void {}, |
Przemyslaw Waliszewski | 5e03606 | 2021-05-31 17:10:18 +0200 | [diff] [blame] | 455 | invalidateAccountsDetailCache(): void {}, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 456 | probePath(): Promise<boolean> { |
| 457 | return Promise.resolve(true); |
| 458 | }, |
| 459 | putChangeCommitMessage(): Promise<Response> { |
| 460 | return Promise.resolve(new Response()); |
| 461 | }, |
| 462 | queryChangeFiles(): Promise<string[] | undefined> { |
| 463 | return Promise.resolve([]); |
| 464 | }, |
| 465 | removeChangeReviewer(): Promise<Response | undefined> { |
| 466 | return Promise.resolve(new Response()); |
| 467 | }, |
| 468 | removeFromAttentionSet(): Promise<Response> { |
| 469 | return Promise.resolve(new Response()); |
| 470 | }, |
| 471 | renameFileInChangeEdit(): Promise<Response | undefined> { |
| 472 | return Promise.resolve(new Response()); |
| 473 | }, |
| 474 | restoreFileInChangeEdit(): Promise<Response | undefined> { |
| 475 | return Promise.resolve(new Response()); |
| 476 | }, |
| 477 | runRepoGC(): Promise<Response> { |
| 478 | return Promise.resolve(new Response()); |
| 479 | }, |
| 480 | saveAccountAgreement(): Promise<Response> { |
| 481 | return Promise.resolve(new Response()); |
| 482 | }, |
| 483 | saveChangeEdit(): Promise<Response> { |
| 484 | return Promise.resolve(new Response()); |
| 485 | }, |
| 486 | saveChangeReview() { |
Chris Poucet | fceaf78 | 2023-08-16 15:11:04 +0200 | [diff] [blame] | 487 | return Promise.resolve({}); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 488 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 489 | saveChangeStarred(): Promise<Response> { |
| 490 | return Promise.resolve(new Response()); |
| 491 | }, |
| 492 | saveDiffDraft(): Promise<Response> { |
| 493 | return Promise.resolve(new Response()); |
| 494 | }, |
| 495 | saveDiffPreferences(): Promise<Response> { |
| 496 | return Promise.resolve(new Response()); |
| 497 | }, |
| 498 | saveEditPreferences(): Promise<Response> { |
| 499 | return Promise.resolve(new Response()); |
| 500 | }, |
| 501 | saveFileReviewed(): Promise<Response> { |
| 502 | return Promise.resolve(new Response()); |
| 503 | }, |
| 504 | saveFileUploadChangeEdit(): Promise<Response | undefined> { |
| 505 | return Promise.resolve(new Response()); |
| 506 | }, |
| 507 | saveGroupDescription(): Promise<Response> { |
| 508 | return Promise.resolve(new Response()); |
| 509 | }, |
| 510 | saveGroupMember(): Promise<AccountInfo> { |
| 511 | return Promise.resolve({}); |
| 512 | }, |
| 513 | saveGroupName(): Promise<Response> { |
| 514 | return Promise.resolve(new Response()); |
| 515 | }, |
| 516 | saveGroupOptions(): Promise<Response> { |
| 517 | return Promise.resolve(new Response()); |
| 518 | }, |
| 519 | saveGroupOwner(): Promise<Response> { |
| 520 | return Promise.resolve(new Response()); |
| 521 | }, |
| 522 | saveIncludedGroup(): Promise<GroupInfo | undefined> { |
| 523 | throw new Error('saveIncludedGroup() not implemented by RestApiMock.'); |
| 524 | }, |
Ben Rohlfs | 75b390c | 2022-04-04 14:56:06 +0200 | [diff] [blame] | 525 | savePreferences(input: PreferencesInput): Promise<PreferencesInfo> { |
| 526 | const info = input as PreferencesInfo; |
| 527 | return Promise.resolve({...info}); |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 528 | }, |
| 529 | saveRepoConfig(): Promise<Response> { |
| 530 | return Promise.resolve(new Response()); |
| 531 | }, |
| 532 | saveWatchedProjects(): Promise<ProjectWatchInfo[]> { |
| 533 | return Promise.resolve([]); |
| 534 | }, |
| 535 | send() { |
| 536 | return Promise.resolve(new Response()); |
| 537 | }, |
| 538 | setAccountDisplayName(): Promise<void> { |
| 539 | return Promise.resolve(); |
| 540 | }, |
| 541 | setAccountName(): Promise<void> { |
| 542 | return Promise.resolve(); |
| 543 | }, |
| 544 | setAccountStatus(): Promise<void> { |
| 545 | return Promise.resolve(); |
| 546 | }, |
| 547 | setAccountUsername(): Promise<void> { |
| 548 | return Promise.resolve(); |
| 549 | }, |
Ben Rohlfs | 3a6ff7e | 2021-01-18 14:08:39 +0100 | [diff] [blame] | 550 | setChangeHashtag(): Promise<Hashtag[]> { |
| 551 | return Promise.resolve([]); |
| 552 | }, |
| 553 | setChangeTopic(): Promise<string> { |
| 554 | return Promise.resolve(''); |
| 555 | }, |
| 556 | setDescription(): Promise<Response> { |
| 557 | return Promise.resolve(new Response()); |
| 558 | }, |
| 559 | setInProjectLookup(): void {}, |
| 560 | setPreferredAccountEmail(): Promise<void> { |
| 561 | return Promise.resolve(); |
| 562 | }, |
| 563 | setRepoAccessRights(): Promise<Response> { |
| 564 | return Promise.resolve(new Response()); |
| 565 | }, |
| 566 | setRepoAccessRightsForReview(): Promise<ChangeInfo> { |
| 567 | throw new Error('setRepoAccessRightsForReview() not implemented by mock.'); |
| 568 | }, |
| 569 | setRepoHead(): Promise<Response> { |
| 570 | return Promise.resolve(new Response()); |
| 571 | }, |
| 572 | }; |