blob: f0a4cbeb3035f9fb3392315b50f8d76062c7ff21 [file] [log] [blame]
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +02001/**
2 * @license
Ben Rohlfs94fcbbc2022-05-27 10:45:03 +02003 * Copyright 2020 Google LLC
4 * SPDX-License-Identifier: Apache-2.0
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +02005 */
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +02006import {
Dmitrii Filippov47561922021-07-02 11:43:10 +02007 AccountDetailInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +02008 AccountId,
9 AccountInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010010 AccountsConfigInfo,
11 ApprovalInfo,
12 AuthInfo,
Dmitrii Filippov47561922021-07-02 11:43:10 +020013 BasePatchSetNum,
Ben Rohlfs775892c2022-05-12 09:29:50 +020014 BlameInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020015 BranchName,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010016 ChangeConfigInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020017 ChangeId,
18 ChangeInfo,
19 ChangeInfoId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020020 ChangeMessageId,
21 ChangeMessageInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010022 ChangeViewChangeInfo,
Ben Rohlfs05750b92021-10-29 08:23:08 +020023 CommentInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020024 CommentLinkInfo,
25 CommentLinks,
Ben Rohlfs1e5bf1522022-04-28 16:31:07 +020026 CommentRange,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010027 CommitId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020028 CommitInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020029 ConfigInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010030 DownloadInfo,
Ben Rohlfs1fe7f4d2021-12-06 11:21:49 +010031 EditInfo,
Ben Rohlfsef043172022-05-27 16:07:27 +020032 EDIT,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020033 EmailAddress,
Dmitrii Filippov47561922021-07-02 11:43:10 +020034 FixId,
35 FixSuggestionInfo,
36 GerritInfo,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020037 GitPersonInfo,
38 GitRef,
Dmitrii Filippov47561922021-07-02 11:43:10 +020039 GroupAuditEventInfo,
40 GroupAuditEventType,
41 GroupId,
42 GroupInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020043 InheritedBooleanInfo,
Kaushik Lingarkar171003f2022-05-17 11:48:21 -070044 LabelInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020045 MaxObjectSizeLimitInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010046 MergeableInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020047 NumericChangeId,
Ben Rohlfs58267b72022-05-27 15:59:18 +020048 PARENT,
Ben Rohlfs775892c2022-05-12 09:29:50 +020049 PatchRange,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010050 PluginConfigInfo,
51 PreferencesInfo,
Dmitrii Filippov47561922021-07-02 11:43:10 +020052 RelatedChangeAndCommitInfo,
53 RelatedChangesInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020054 RepoName,
Dmitrii Filippov47561922021-07-02 11:43:10 +020055 Requirement,
56 RequirementType,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020057 Reviewers,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020058 RevisionInfo,
Ben Rohlfs775892c2022-05-12 09:29:50 +020059 RevisionPatchSetNum,
Ben Rohlfs05750b92021-10-29 08:23:08 +020060 RobotCommentInfo,
61 RobotId,
62 RobotRunId,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010063 SchemesInfoMap,
64 ServerInfo,
Dmitrii Filippov47561922021-07-02 11:43:10 +020065 SubmittedTogetherInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020066 SubmitTypeInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010067 SuggestInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020068 Timestamp,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020069 TimezoneOffset,
Dhruv Srivastava52e7f152020-10-15 14:41:58 +020070 UrlEncodedCommentId,
Dmitrii Filippov47561922021-07-02 11:43:10 +020071 UserConfigInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020072} from '../types/common';
73import {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010074 AccountsVisibility,
Ben Rohlfsead93662022-08-05 09:09:15 +020075 AccountTag,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010076 AppTheme,
77 AuthType,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020078 ChangeStatus,
Dmitrii Filippov47561922021-07-02 11:43:10 +020079 CommentSide,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010080 DateFormat,
81 DefaultBase,
82 DefaultDisplayNameConfig,
83 DiffViewMode,
84 EmailStrategy,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020085 InheritedBooleanInfoConfiguredValue,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010086 MergeabilityComputationBehavior,
Dmitrii Filippov47561922021-07-02 11:43:10 +020087 RequirementStatus,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020088 RevisionKind,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020089 SubmitType,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010090 TimeFormat,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020091} from '../constants/constants';
92import {formatDate} from '../utils/date-util';
Ben Rohlfsa9d2cff2021-01-22 21:33:58 +010093import {GetDiffCommentsOutput} from '../services/gr-rest-api/gr-rest-api';
Milutin Kristofic40a6cde2020-11-30 23:48:28 +010094import {CommitInfoWithRequiredCommit} from '../elements/change/gr-change-metadata/gr-change-metadata';
95import {WebLinkInfo} from '../types/diff';
Ben Rohlfsced29172021-11-03 11:08:42 +010096import {
Milutin Kristofic0cd7f242022-01-26 22:28:21 +010097 ChangeMessage,
Ben Rohlfs05750b92021-10-29 08:23:08 +020098 CommentThread,
Ben Rohlfsced29172021-11-03 11:08:42 +010099 createCommentThreads,
Ben Rohlfs05750b92021-10-29 08:23:08 +0200100 DraftInfo,
Ben Rohlfs607126f2021-12-07 08:21:52 +0100101 UnsavedInfo,
Ben Rohlfsced29172021-11-03 11:08:42 +0100102} from '../utils/comment-util';
Ben Rohlfsebe4acc2020-12-11 21:16:10 +0100103import {GerritView} from '../services/router/router-model';
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100104import {ChangeComments} from '../elements/diff/gr-comment-api/gr-comment-api';
Ben Rohlfsa00ef282021-01-22 21:45:53 +0100105import {EditRevisionInfo, ParsedChangeInfo} from '../types/types';
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +0200106import {
Milutin Kristoficc7ffc562021-10-12 11:54:46 +0200107 DetailedLabelInfo,
Milutin Kristofic064b6b92021-11-10 20:15:35 +0100108 QuickLabelInfo,
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +0200109 SubmitRequirementExpressionInfo,
110 SubmitRequirementResultInfo,
111 SubmitRequirementStatus,
112} from '../api/rest-api';
Milutin Kristofic5a612662022-05-04 16:10:37 +0200113import {CheckResult, RunResult} from '../models/checks/checks-model';
Ben Rohlfs54fd41d2021-09-22 09:10:50 +0200114import {Category, RunStatus} from '../api/checks';
Ben Rohlfs0d4ca9c2022-04-28 10:20:33 +0200115import {DiffInfo} from '../api/diff';
Ben Rohlfsa58c5962022-09-12 22:26:14 +0200116import {SearchViewState} from '../models/views/search';
Ben Rohlfsecc67992022-12-16 10:10:16 +0100117import {ChangeChildView, ChangeViewState} from '../models/views/change';
Ben Rohlfs425a0e92022-12-20 21:36:19 +0100118import {NormalizedFileInfo} from '../models/change/files-model';
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200119
Dhruv Srivastava2fafc5a2022-03-24 14:37:38 +0530120const TEST_DEFAULT_EXPRESSION = 'label:Verified=MAX -label:Verified=MIN';
121export const TEST_PROJECT_NAME: RepoName = 'test-project' as RepoName;
122export const TEST_BRANCH_ID: BranchName = 'test-branch' as BranchName;
123export const TEST_CHANGE_ID: ChangeId = 'TestChangeId' as ChangeId;
124export const TEST_CHANGE_INFO_ID: ChangeInfoId =
125 `${TEST_PROJECT_NAME}~${TEST_BRANCH_ID}~${TEST_CHANGE_ID}` as ChangeInfoId;
126export const TEST_SUBJECT = 'Test subject';
127export const TEST_NUMERIC_CHANGE_ID = 42 as NumericChangeId;
128
129export const TEST_CHANGE_CREATED = new Date(2020, 1, 1, 1, 2, 3);
130export const TEST_CHANGE_UPDATED = new Date(2020, 10, 6, 5, 12, 34);
131
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200132export function dateToTimestamp(date: Date): Timestamp {
133 const nanosecondSuffix = '.000000000';
134 return (formatDate(date, 'YYYY-MM-DD HH:mm:ss') +
135 nanosecondSuffix) as Timestamp;
136}
137
Kamil Musin734db9a2022-11-11 11:19:25 +0100138export function createCommentLink(
139 match = 'test',
140 link = 'http://test.com'
141): CommentLinkInfo {
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200142 return {
143 match,
Kamil Musin734db9a2022-11-11 11:19:25 +0100144 link,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200145 };
146}
147
148export function createInheritedBoolean(value = false): InheritedBooleanInfo {
149 return {
150 value,
151 configured_value: value
152 ? InheritedBooleanInfoConfiguredValue.TRUE
153 : InheritedBooleanInfoConfiguredValue.FALSE,
154 };
155}
156
157export function createMaxObjectSizeLimit(): MaxObjectSizeLimitInfo {
158 return {};
159}
160
161export function createSubmitType(
162 value: Exclude<SubmitType, SubmitType.INHERIT> = SubmitType.MERGE_IF_NECESSARY
163): SubmitTypeInfo {
164 return {
165 value,
166 configured_value: SubmitType.INHERIT,
167 inherited_value: value,
168 };
169}
170
171export function createCommentLinks(): CommentLinks {
172 return {};
173}
174
175export function createConfig(): ConfigInfo {
176 return {
177 private_by_default: createInheritedBoolean(),
178 work_in_progress_by_default: createInheritedBoolean(),
179 max_object_size_limit: createMaxObjectSizeLimit(),
180 default_submit_type: createSubmitType(),
Paladox none9f37b4f2021-10-31 00:45:18 +0000181 enable_reviewer_by_email: createInheritedBoolean(),
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200182 submit_type: SubmitType.INHERIT,
183 commentlinks: createCommentLinks(),
184 };
185}
186
187export function createAccountWithId(id = 5): AccountInfo {
188 return {
189 _account_id: id as AccountId,
Dhruv Srivastava38150de2022-09-26 11:31:01 +0200190 email: `${id}` as EmailAddress,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200191 };
192}
193
Ben Rohlfsead93662022-08-05 09:09:15 +0200194export function createServiceUserWithId(id = 5): AccountInfo {
195 return {
196 ...createAccountWithId(id),
197 tags: [AccountTag.SERVICE_USER],
198 };
199}
200
Ben Rohlfs07d0f6c2020-11-04 08:46:30 +0100201export function createAccountDetailWithId(id = 5): AccountDetailInfo {
202 return {
203 _account_id: id as AccountId,
204 registered_on: dateToTimestamp(new Date(2020, 10, 15, 14, 5, 8)),
205 };
206}
207
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200208export function createAccountWithEmail(email = 'test@'): AccountInfo {
209 return {
210 email: email as EmailAddress,
Dhruv Srivastavab4a36482022-09-20 15:51:50 +0200211 _account_id: 1 as AccountId,
212 };
213}
214
215export function createAccountWithEmailOnly(email = 'test@'): AccountInfo {
216 return {
217 email: email as EmailAddress,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200218 };
219}
220
221export function createAccountWithIdNameAndEmail(id = 5): AccountInfo {
222 return {
223 _account_id: id as AccountId,
224 email: `user-${id}@` as EmailAddress,
225 name: `User-${id}`,
226 };
227}
228
Chris Poucet7a2c9192022-03-21 18:52:45 +0100229export function createAccountDetailWithIdNameAndEmail(
230 id = 5
231): AccountDetailInfo {
232 return {
233 _account_id: id as AccountId,
234 email: `user-${id}@` as EmailAddress,
235 name: `User-${id}`,
236 registered_on: dateToTimestamp(new Date(2020, 10, 15, 14, 5, 8)),
237 };
238}
239
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200240export function createReviewers(): Reviewers {
241 return {};
242}
243
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100244export function createGitPerson(name = 'Test name'): GitPersonInfo {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200245 return {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100246 name,
Dmitrii Filippov3cd78fb2021-07-05 12:02:37 +0200247 email: `${name}@` as EmailAddress,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200248 date: dateToTimestamp(new Date(2019, 11, 6, 14, 5, 8)),
249 tz: 0 as TimezoneOffset,
250 };
251}
252
Kaushik Lingarkar171003f2022-05-17 11:48:21 -0700253export function createLabelInfo(score = 1): LabelInfo {
254 return {
255 all: [
256 {
257 value: score,
258 permitted_voting_range: {
259 min: -1,
260 max: 1,
261 },
262 _account_id: 1000 as AccountId,
263 name: 'Foo',
264 email: 'foo@example.com' as EmailAddress,
265 username: 'foo',
266 },
267 ],
268 values: {
269 '-1': 'Fail',
270 ' 0': 'No score',
271 '+1': 'Pass',
272 },
273 default_value: 0,
274 };
275}
276
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200277export function createCommit(): CommitInfo {
278 return {
279 parents: [],
280 author: createGitPerson(),
281 committer: createGitPerson(),
282 subject: 'Test commit subject',
283 message: 'Test commit message',
284 };
285}
286
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100287export function createCommitInfoWithRequiredCommit(
288 commit = 'commit'
289): CommitInfoWithRequiredCommit {
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100290 return {
291 ...createCommit(),
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100292 commit: commit as CommitId,
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100293 };
294}
295
Ben Rohlfs775892c2022-05-12 09:29:50 +0200296export function createPatchRange(
297 basePatchNum?: number,
298 patchNum?: number
299): PatchRange {
300 return {
Ben Rohlfs58267b72022-05-27 15:59:18 +0200301 basePatchNum: (basePatchNum ?? PARENT) as BasePatchSetNum,
Ben Rohlfs775892c2022-05-12 09:29:50 +0200302 patchNum: (patchNum ?? 1) as RevisionPatchSetNum,
303 };
304}
305
Paladox noneefbc8cb2021-08-07 22:31:11 +0000306export function createRevision(
Ben Rohlfscf96f092022-05-30 11:44:16 +0200307 patchSetNum: number | RevisionPatchSetNum = 1,
Paladox noneefbc8cb2021-08-07 22:31:11 +0000308 description = ''
309): RevisionInfo {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200310 return {
Ben Rohlfscf96f092022-05-30 11:44:16 +0200311 _number: patchSetNum as RevisionPatchSetNum,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200312 commit: createCommit(),
313 created: dateToTimestamp(TEST_CHANGE_CREATED),
314 kind: RevisionKind.REWORK,
315 ref: 'refs/changes/5/6/1' as GitRef,
316 uploader: createAccountWithId(),
Paladox noneefbc8cb2021-08-07 22:31:11 +0000317 description,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200318 };
319}
320
Ben Rohlfs1fe7f4d2021-12-06 11:21:49 +0100321export function createEditInfo(): EditInfo {
322 return {
323 commit: {...createCommit(), commit: 'commit-id-of-edit-ps' as CommitId},
324 base_patch_set_number: 1 as BasePatchSetNum,
325 base_revision: 'base-revision-of-edit',
326 ref: 'refs/changes/5/6/1' as GitRef,
327 fetch: {},
328 files: {},
329 };
330}
331
Paladox noneefbc8cb2021-08-07 22:31:11 +0000332export function createEditRevision(basePatchNum = 1): EditRevisionInfo {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200333 return {
Ben Rohlfsef043172022-05-27 16:07:27 +0200334 _number: EDIT,
Paladox noneefbc8cb2021-08-07 22:31:11 +0000335 basePatchNum: basePatchNum as BasePatchSetNum,
Ben Rohlfs1fe7f4d2021-12-06 11:21:49 +0100336 commit: {
337 ...createCommit(),
338 commit: 'test-commit-id-of-edit-rev' as CommitId,
339 },
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100340 };
341}
342
Dhruv Srivastava0d9e8f02021-03-10 12:39:52 +0100343export function createChangeMessageInfo(id = 'cm_id_1'): ChangeMessageInfo {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100344 return {
345 id: id as ChangeMessageId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200346 date: dateToTimestamp(TEST_CHANGE_CREATED),
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100347 message: `This is a message with id ${id}`,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200348 };
349}
350
Dhruv Srivastava0d9e8f02021-03-10 12:39:52 +0100351export function createChangeMessage(id = 'cm_id_1'): ChangeMessage {
352 return {
353 ...createChangeMessageInfo(id),
354 type: '',
355 expanded: false,
356 commentThreads: [],
357 };
358}
359
Chris Poucetcaeea1b2021-08-19 22:12:56 +0000360export function createRevisions(count: number): {
361 [revisionId: string]: RevisionInfo;
362} {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200363 const revisions: {[revisionId: string]: RevisionInfo} = {};
Ben Rohlfs67e28882021-10-26 21:50:13 +0200364 let revisionDate = TEST_CHANGE_CREATED;
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100365 const revisionIdStart = 1; // The same as getCurrentRevision
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200366 for (let i = 0; i < count; i++) {
367 const revisionId = (i + revisionIdStart).toString(16);
368 const revision: RevisionInfo = {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100369 ...createRevision(i + 1),
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200370 created: dateToTimestamp(revisionDate),
371 ref: `refs/changes/5/6/${i + 1}` as GitRef,
372 };
373 revisions[revisionId] = revision;
374 // advance 1 day
Ben Rohlfs67e28882021-10-26 21:50:13 +0200375 revisionDate = new Date(revisionDate);
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200376 revisionDate.setDate(revisionDate.getDate() + 1);
377 }
378 return revisions;
379}
380
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100381export function getCurrentRevision(count: number): CommitId {
382 const revisionIdStart = 1; // The same as createRevisions
383 return (count + revisionIdStart).toString(16) as CommitId;
384}
385
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200386export function createChangeMessages(count: number): ChangeMessageInfo[] {
387 const messageIdStart = 1000;
388 const messages: ChangeMessageInfo[] = [];
Ben Rohlfs67e28882021-10-26 21:50:13 +0200389 let messageDate = TEST_CHANGE_CREATED;
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200390 for (let i = 0; i < count; i++) {
391 messages.push({
Dhruv Srivastava0d9e8f02021-03-10 12:39:52 +0100392 ...createChangeMessageInfo((i + messageIdStart).toString(16)),
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200393 date: dateToTimestamp(messageDate),
Dhruv Srivastavad5944192022-10-25 16:39:51 +0200394 author: createAccountDetailWithId(i),
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200395 });
Ben Rohlfs67e28882021-10-26 21:50:13 +0200396 messageDate = new Date(messageDate);
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200397 messageDate.setDate(messageDate.getDate() + 1);
398 }
399 return messages;
400}
401
Ben Rohlfs425a0e92022-12-20 21:36:19 +0100402export function createFileInfo(
403 path = 'test-path/test-file.txt'
404): NormalizedFileInfo {
Ben Rohlfs0fe96492022-05-12 14:42:26 +0200405 return {
406 size: 314,
407 size_delta: 7,
Ben Rohlfs425a0e92022-12-20 21:36:19 +0100408 lines_deleted: 0,
409 lines_inserted: 0,
410 __path: path,
Ben Rohlfs0fe96492022-05-12 14:42:26 +0200411 };
412}
413
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200414export function createChange(): ChangeInfo {
415 return {
416 id: TEST_CHANGE_INFO_ID,
417 project: TEST_PROJECT_NAME,
418 branch: TEST_BRANCH_ID,
419 change_id: TEST_CHANGE_ID,
420 subject: TEST_SUBJECT,
421 status: ChangeStatus.NEW,
422 created: dateToTimestamp(TEST_CHANGE_CREATED),
423 updated: dateToTimestamp(TEST_CHANGE_UPDATED),
424 insertions: 0,
425 deletions: 0,
426 _number: TEST_NUMERIC_CHANGE_ID,
427 owner: createAccountWithId(),
428 // This is documented as optional, but actually always set.
429 reviewers: createReviewers(),
430 };
431}
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100432
433export function createChangeViewChange(): ChangeViewChangeInfo {
434 return {
435 ...createChange(),
436 revisions: {
437 abc: createRevision(),
438 },
439 current_revision: 'abc' as CommitId,
440 };
441}
442
443export function createParsedChange(): ParsedChangeInfo {
444 return createChangeViewChange();
445}
446
447export function createAccountsConfig(): AccountsConfigInfo {
448 return {
449 visibility: AccountsVisibility.ALL,
450 default_display_name: DefaultDisplayNameConfig.FULL_NAME,
451 };
452}
453
454export function createAuth(): AuthInfo {
455 return {
456 auth_type: AuthType.OPENID,
457 editable_account_fields: [],
458 };
459}
460
461export function createChangeConfig(): ChangeConfigInfo {
462 return {
463 large_change: 500,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100464 // The default update_delay is 5 minutes, but we don't want to accidentally
465 // start polling in tests
466 update_delay: 0,
467 mergeability_computation_behavior:
468 MergeabilityComputationBehavior.REF_UPDATED_AND_CHANGE_REINDEX,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100469 };
470}
471
472export function createDownloadSchemes(): SchemesInfoMap {
473 return {};
474}
475
476export function createDownloadInfo(): DownloadInfo {
477 return {
478 schemes: createDownloadSchemes(),
479 archives: ['tgz', 'tar'],
480 };
481}
482
483export function createGerritInfo(): GerritInfo {
484 return {
485 all_projects: 'All-Projects',
486 all_users: 'All-Users',
487 doc_search: false,
488 };
489}
490
491export function createPluginConfig(): PluginConfigInfo {
492 return {
493 has_avatars: false,
494 js_resource_paths: [],
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100495 };
496}
497
498export function createSuggestInfo(): SuggestInfo {
499 return {
500 from: 0,
501 };
502}
503
504export function createUserConfig(): UserConfigInfo {
505 return {
506 anonymous_coward_name: 'Name of user not set',
507 };
508}
509
510export function createServerInfo(): ServerInfo {
511 return {
512 accounts: createAccountsConfig(),
513 auth: createAuth(),
514 change: createChangeConfig(),
515 download: createDownloadInfo(),
516 gerrit: createGerritInfo(),
517 plugin: createPluginConfig(),
518 suggest: createSuggestInfo(),
519 user: createUserConfig(),
520 };
521}
522
523export function createGetDiffCommentsOutput(): GetDiffCommentsOutput {
524 return {
525 baseComments: [],
526 comments: [],
527 };
528}
529
Ben Rohlfs7b95c732022-05-09 11:55:52 +0200530export function createEmptyDiff(): DiffInfo {
531 return {
532 meta_a: {
533 name: 'empty-left.txt',
534 content_type: 'text/plain',
535 lines: 1,
536 },
537 meta_b: {
538 name: 'empty-right.txt',
539 content_type: 'text/plain',
540 lines: 1,
541 },
542 intraline_status: 'OK',
543 change_type: 'MODIFIED',
544 content: [],
545 };
546}
547
Ben Rohlfs0d4ca9c2022-04-28 10:20:33 +0200548export function createDiff(): DiffInfo {
549 return {
550 meta_a: {
551 name: 'lorem-ipsum.txt',
552 content_type: 'text/plain',
553 lines: 45,
554 },
555 meta_b: {
556 name: 'lorem-ipsum.txt',
557 content_type: 'text/plain',
558 lines: 48,
559 },
560 intraline_status: 'OK',
561 change_type: 'MODIFIED',
562 diff_header: [
563 'diff --git a/lorem-ipsum.txt b/lorem-ipsum.txt',
564 'index b2adcf4..554ae49 100644',
565 '--- a/lorem-ipsum.txt',
566 '+++ b/lorem-ipsum.txt',
567 ],
568 content: [
569 {
570 ab: [
Ben Rohlfs48904302022-11-04 10:09:02 +0100571 'Lorem ipsum dolor sit amet, suspendisse inceptos vehicula.',
Ben Rohlfs0d4ca9c2022-04-28 10:20:33 +0200572 'Mattis lectus.',
573 'Sodales duis.',
574 'Orci a faucibus.',
575 ],
576 },
577 {
578 b: [
579 'Nullam neque, ligula ac, id blandit.',
580 'Sagittis tincidunt torquent, tempor nunc amet.',
581 'At rhoncus id.',
582 ],
583 },
584 {
585 ab: [
586 'Sem nascetur, erat ut, non in.',
587 'A donec, venenatis pellentesque dis.',
588 'Mauris mauris.',
589 'Quisque nisl duis, facilisis viverra.',
590 'Justo purus, semper eget et.',
591 ],
592 },
593 {
594 a: [
595 'Est amet, vestibulum pellentesque.',
596 'Erat ligula.',
597 'Justo eros.',
598 'Fringilla quisque.',
599 ],
600 },
601 {
Ben Rohlfs985b15d2022-08-22 11:22:44 +0200602 a: [
603 'Arcu eget, rhoncus amet cursus, ipsum elementum. ',
604 'Eros suspendisse. ',
605 ],
606 b: [
Ben Rohlfs0d4ca9c2022-04-28 10:20:33 +0200607 'Arcu eget, rhoncus amet cursus, ipsum elementum.',
608 'Eros suspendisse.',
609 ],
Ben Rohlfs985b15d2022-08-22 11:22:44 +0200610 common: true,
Ben Rohlfs0d4ca9c2022-04-28 10:20:33 +0200611 },
612 {
613 a: ['Rhoncus tempor, ultricies aliquam ipsum.'],
614 b: ['Rhoncus tempor, ultricies praesent ipsum.'],
615 edit_a: [[26, 7]],
616 edit_b: [[26, 8]],
617 },
618 {
619 ab: [
620 'Sollicitudin duis.',
621 'Blandit blandit, ante nisl fusce.',
622 'Felis ac at, tellus consectetuer.',
623 'Sociis ligula sapien, egestas leo.',
624 'Cum pulvinar, sed mauris, cursus neque velit.',
625 'Augue porta lobortis.',
626 'Nibh lorem, amet fermentum turpis, vel pulvinar diam.',
627 'Id quam ipsum, id urna et, massa suspendisse.',
628 'Ac nec, nibh praesent.',
629 'Rutrum vestibulum.',
630 'Est tellus, bibendum habitasse.',
631 'Justo facilisis, vel nulla.',
632 'Donec eu, vulputate neque aliquam, nulla dui.',
633 'Risus adipiscing in.',
634 'Lacus arcu arcu.',
635 'Urna velit.',
636 'Urna a dolor.',
637 'Lectus magna augue, convallis mattis tortor, sed tellus ' +
638 'consequat.',
639 'Etiam dui, blandit wisi.',
640 'Mi nec.',
641 'Vitae eget vestibulum.',
Ben Rohlfs48904302022-11-04 10:09:02 +0100642 'Ullamcorper nunc ante, nec imperdiet felis, consectetur.',
Ben Rohlfs0d4ca9c2022-04-28 10:20:33 +0200643 'Ac eget.',
644 'Vel fringilla, interdum pellentesque placerat, proin ante.',
645 ],
646 },
647 {
648 b: [
649 'Eu congue risus.',
650 'Enim ac, quis elementum.',
651 'Non et elit.',
652 'Etiam aliquam, diam vel nunc.',
653 ],
654 },
655 {
656 ab: [
657 'Nec at.',
658 'Arcu mauris, venenatis lacus fermentum, praesent duis.',
659 'Pellentesque amet et, tellus duis.',
660 'Ipsum arcu vitae, justo elit, sed libero tellus.',
661 'Metus rutrum euismod, vivamus sodales, vel arcu nisl.',
662 ],
663 },
664 ],
665 };
666}
667
Ben Rohlfs775892c2022-05-12 09:29:50 +0200668export function createBlame(): BlameInfo {
669 return {
670 author: 'test-author',
671 id: 'test-id',
672 time: 123,
673 commit_msg: 'test-commit-message',
674 ranges: [],
675 };
676}
677
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100678export function createMergeable(): MergeableInfo {
679 return {
680 submit_type: SubmitType.MERGE_IF_NECESSARY,
681 mergeable: false,
682 };
683}
684
Ben Rohlfs3a6ff7e2021-01-18 14:08:39 +0100685// TODO: Maybe reconcile with createDefaultPreferences() in constants.ts.
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100686export function createPreferences(): PreferencesInfo {
687 return {
688 changes_per_page: 10,
paladox1b7ce942021-04-09 04:23:20 +0100689 theme: AppTheme.AUTO,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100690 date_format: DateFormat.ISO,
691 time_format: TimeFormat.HHMM_24,
692 diff_view: DiffViewMode.SIDE_BY_SIDE,
693 my: [],
694 change_table: [],
695 email_strategy: EmailStrategy.ENABLED,
696 default_base_for_merges: DefaultBase.AUTO_MERGE,
Milutin Kristofic9dfe4f62022-10-12 20:11:02 +0200697 allow_browser_notifications: true,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100698 };
699}
700
Milutin Kristofic73cc5402022-09-09 12:46:46 +0200701export function createApproval(account?: AccountInfo): ApprovalInfo {
702 return account ?? createAccountWithId();
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100703}
704
Ben Rohlfs65c2f2b2022-09-12 22:35:26 +0200705export function createChangeViewState(): ChangeViewState {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100706 return {
707 view: GerritView.CHANGE,
Ben Rohlfsecc67992022-12-16 10:10:16 +0100708 childView: ChangeChildView.OVERVIEW,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100709 changeNum: TEST_NUMERIC_CHANGE_ID,
Ben Rohlfsbfc688b2022-10-21 12:38:37 +0200710 repo: TEST_PROJECT_NAME,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100711 };
712}
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100713
Ben Rohlfsa58c5962022-09-12 22:26:14 +0200714export function createAppElementSearchViewParams(): SearchViewState {
Frank Bordend4764912021-12-09 17:10:59 +0100715 return {
716 view: GerritView.SEARCH,
717 query: TEST_NUMERIC_CHANGE_ID.toString(),
718 offset: '0',
Ben Rohlfs7aeecaa2022-10-11 15:26:45 +0000719 changes: [],
720 loading: false,
Frank Bordend4764912021-12-09 17:10:59 +0100721 };
722}
723
Ben Rohlfsecc67992022-12-16 10:10:16 +0100724export function createEditViewState(): ChangeViewState {
Paladox none18548462021-07-07 14:36:43 +0000725 return {
Ben Rohlfsecc67992022-12-16 10:10:16 +0100726 view: GerritView.CHANGE,
727 childView: ChangeChildView.EDIT,
Paladox none18548462021-07-07 14:36:43 +0000728 changeNum: TEST_NUMERIC_CHANGE_ID,
Ben Rohlfsef043172022-05-27 16:07:27 +0200729 patchNum: EDIT,
Ben Rohlfsecc67992022-12-16 10:10:16 +0100730 repo: TEST_PROJECT_NAME,
731 editView: {path: 'foo/bar.baz'},
732 };
733}
734
735export function createDiffViewState(): ChangeViewState {
736 return {
737 view: GerritView.CHANGE,
738 childView: ChangeChildView.DIFF,
739 changeNum: TEST_NUMERIC_CHANGE_ID,
Ben Rohlfsbfc688b2022-10-21 12:38:37 +0200740 repo: TEST_PROJECT_NAME,
Paladox none18548462021-07-07 14:36:43 +0000741 };
742}
743
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100744export function createRequirement(): Requirement {
745 return {
746 status: RequirementStatus.OK,
747 fallbackText: '',
748 type: 'wip' as RequirementType,
749 };
750}
751
752export function createWebLinkInfo(): WebLinkInfo {
753 return {
754 name: 'gitiles',
755 url: '#',
756 image_url: 'gitiles.jpg',
757 };
758}
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200759
Ben Rohlfs1e5bf1522022-04-28 16:31:07 +0200760export function createRange(): CommentRange {
761 return {
762 start_line: 1,
763 start_character: 0,
764 end_line: 1,
765 end_character: 1,
766 };
767}
768
Ben Rohlfs05750b92021-10-29 08:23:08 +0200769export function createComment(
770 extra: Partial<CommentInfo | DraftInfo> = {}
771): CommentInfo {
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200772 return {
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200773 patch_set: 1 as RevisionPatchSetNum,
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200774 id: '12345' as UrlEncodedCommentId,
775 side: CommentSide.REVISION,
776 line: 1,
777 message: 'hello world',
778 updated: '2018-02-13 22:48:48.018000000' as Timestamp,
779 unresolved: false,
Dhruv Srivastava254cb722021-03-08 21:15:37 +0100780 path: 'abc.txt',
Ben Rohlfs05750b92021-10-29 08:23:08 +0200781 ...extra,
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200782 };
783}
784
Ben Rohlfs05750b92021-10-29 08:23:08 +0200785export function createDraft(extra: Partial<CommentInfo> = {}): DraftInfo {
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200786 return {
787 ...createComment(),
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200788 __draft: true,
Ben Rohlfs05750b92021-10-29 08:23:08 +0200789 ...extra,
790 };
791}
792
Ben Rohlfs607126f2021-12-07 08:21:52 +0100793export function createUnsaved(extra: Partial<CommentInfo> = {}): UnsavedInfo {
794 return {
795 ...createComment(),
796 __unsaved: true,
797 id: undefined,
798 updated: undefined,
799 ...extra,
800 };
801}
802
Ben Rohlfs05750b92021-10-29 08:23:08 +0200803export function createRobotComment(
804 extra: Partial<CommentInfo> = {}
805): RobotCommentInfo {
806 return {
807 ...createComment(),
808 robot_id: 'robot-id-123' as RobotId,
809 robot_run_id: 'robot-run-id-456' as RobotRunId,
810 properties: {},
811 fix_suggestions: [],
812 ...extra,
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200813 };
814}
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100815
816export function createChangeComments(): ChangeComments {
817 const comments = {
818 '/COMMIT_MSG': [
819 {
820 ...createComment(),
821 message: 'Done',
822 updated: '2017-02-08 16:40:49' as Timestamp,
823 id: '1' as UrlEncodedCommentId,
824 },
825 {
826 ...createComment(),
827 message: 'oh hay',
828 updated: '2017-02-09 16:40:49' as Timestamp,
829 id: '2' as UrlEncodedCommentId,
830 },
831 {
832 ...createComment(),
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200833 patch_set: 2 as RevisionPatchSetNum,
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100834 message: 'hello',
835 updated: '2017-02-10 16:40:49' as Timestamp,
836 id: '3' as UrlEncodedCommentId,
837 },
838 ],
839 'myfile.txt': [
840 {
841 ...createComment(),
842 message: 'good news!',
843 updated: '2017-02-08 16:40:49' as Timestamp,
844 id: '4' as UrlEncodedCommentId,
845 },
846 {
847 ...createComment(),
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200848 patch_set: 2 as RevisionPatchSetNum,
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100849 message: 'wat!?',
850 updated: '2017-02-09 16:40:49' as Timestamp,
851 id: '5' as UrlEncodedCommentId,
852 },
853 {
854 ...createComment(),
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200855 patch_set: 2 as RevisionPatchSetNum,
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100856 message: 'hi',
857 updated: '2017-02-10 16:40:49' as Timestamp,
858 id: '6' as UrlEncodedCommentId,
859 },
860 ],
861 'unresolved.file': [
862 {
863 ...createComment(),
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200864 patch_set: 2 as RevisionPatchSetNum,
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100865 message: 'wat!?',
866 updated: '2017-02-09 16:40:49' as Timestamp,
867 id: '7' as UrlEncodedCommentId,
868 unresolved: true,
869 },
870 {
871 ...createComment(),
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200872 patch_set: 2 as RevisionPatchSetNum,
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100873 message: 'hi',
874 updated: '2017-02-10 16:40:49' as Timestamp,
875 id: '8' as UrlEncodedCommentId,
876 in_reply_to: '7' as UrlEncodedCommentId,
877 unresolved: false,
878 },
879 {
880 ...createComment(),
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200881 patch_set: 2 as RevisionPatchSetNum,
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100882 message: 'good news!',
883 updated: '2017-02-08 16:40:49' as Timestamp,
884 id: '9' as UrlEncodedCommentId,
885 unresolved: true,
886 },
887 ],
888 };
889 const drafts = {
890 '/COMMIT_MSG': [
891 {
892 ...createDraft(),
893 message: 'hi',
894 updated: '2017-02-15 16:40:49' as Timestamp,
895 id: '10' as UrlEncodedCommentId,
896 unresolved: true,
897 },
898 {
899 ...createDraft(),
900 message: 'fyi',
901 updated: '2017-02-15 16:40:49' as Timestamp,
902 id: '11' as UrlEncodedCommentId,
903 unresolved: false,
904 },
905 ],
906 'unresolved.file': [
907 {
908 ...createDraft(),
909 message: 'hi',
910 updated: '2017-02-11 16:40:49' as Timestamp,
911 id: '12' as UrlEncodedCommentId,
912 unresolved: false,
913 },
914 ],
915 };
916 return new ChangeComments(comments, {}, drafts, {}, {});
917}
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +0100918
Ben Rohlfs05750b92021-10-29 08:23:08 +0200919export function createThread(
920 ...comments: Partial<CommentInfo | DraftInfo>[]
921): CommentThread {
922 return {
923 comments: comments.map(c => createComment(c)),
924 rootId: 'test-root-id-comment-thread' as UrlEncodedCommentId,
925 path: 'test-path-comment-thread',
926 commentSide: CommentSide.REVISION,
Ben Rohlfsabaeacf2022-05-27 15:24:22 +0200927 patchNum: 1 as RevisionPatchSetNum,
Ben Rohlfs05750b92021-10-29 08:23:08 +0200928 line: 314,
929 };
930}
931
Ben Rohlfs775892c2022-05-12 09:29:50 +0200932export function createCommentThread(
933 comments: Array<Partial<CommentInfo | DraftInfo>>
934) {
Dhruv Srivastava254cb722021-03-08 21:15:37 +0100935 if (!comments.length) {
936 throw new Error('comment is required to create a thread');
937 }
Ben Rohlfs05750b92021-10-29 08:23:08 +0200938 const filledComments = comments.map(comment => {
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +0100939 return {...createComment(), ...comment};
940 });
Ben Rohlfs05750b92021-10-29 08:23:08 +0200941 const threads = createCommentThreads(filledComments);
Dhruv Srivastava254cb722021-03-08 21:15:37 +0100942 return threads[0];
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +0100943}
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100944
945export function createRelatedChangeAndCommitInfo(): RelatedChangeAndCommitInfo {
946 return {
947 project: TEST_PROJECT_NAME,
948 commit: createCommitInfoWithRequiredCommit(),
949 };
950}
951
Milutin Kristoficd26e7422021-03-16 20:19:01 +0100952export function createRelatedChangesInfo(): RelatedChangesInfo {
953 return {
954 changes: [],
955 };
956}
957
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100958export function createSubmittedTogetherInfo(): SubmittedTogetherInfo {
959 return {
960 changes: [],
961 non_visible_changes: 0,
962 };
963}
Dmitrii Filippov131bf7a2021-04-01 18:02:27 +0200964
965export function createFixSuggestionInfo(fixId = 'fix_1'): FixSuggestionInfo {
966 return {
967 fix_id: fixId as FixId,
968 description: `Fix ${fixId}`,
969 replacements: [],
970 };
971}
Milutin Kristofic1cc62b52021-06-15 08:35:02 +0200972
973export function createGroupInfo(id = 'id'): GroupInfo {
974 return {
975 id: id as GroupId,
976 };
977}
Dmitrii Filippov47561922021-07-02 11:43:10 +0200978
979export function createGroupAuditEventInfo(
980 type: GroupAuditEventType
981): GroupAuditEventInfo {
982 if (
983 type === GroupAuditEventType.ADD_USER ||
984 type === GroupAuditEventType.REMOVE_USER
985 ) {
986 return {
987 type,
988 member: createAccountWithId(10),
989 user: createAccountWithId(),
990 date: dateToTimestamp(new Date(2019, 11, 6, 14, 5, 8)),
991 };
992 } else {
993 return {
994 type,
995 member: createGroupInfo(),
996 user: createAccountWithId(),
997 date: dateToTimestamp(new Date(2019, 11, 6, 14, 5, 8)),
998 };
999 }
1000}
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +02001001
Dhruv Srivastava2fafc5a2022-03-24 14:37:38 +05301002export function createSubmitRequirementExpressionInfo(
1003 expression = TEST_DEFAULT_EXPRESSION
1004): SubmitRequirementExpressionInfo {
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +02001005 return {
Dhruv Srivastava2fafc5a2022-03-24 14:37:38 +05301006 expression,
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +02001007 fulfilled: true,
Kamil Musinea6057c2022-08-25 14:13:49 +02001008 passing_atoms: ['label:Verified=MAX'],
1009 failing_atoms: ['label:Verified=MIN'],
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +02001010 };
1011}
1012
Dhruv Srivastava2fafc5a2022-03-24 14:37:38 +05301013export function createSubmitRequirementResultInfo(
1014 expression = TEST_DEFAULT_EXPRESSION
1015): SubmitRequirementResultInfo {
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +02001016 return {
1017 name: 'Verified',
1018 status: SubmitRequirementStatus.SATISFIED,
Dhruv Srivastava2fafc5a2022-03-24 14:37:38 +05301019 submittability_expression_result:
1020 createSubmitRequirementExpressionInfo(expression),
Milutin Kristofic826f1652021-11-30 15:09:59 +01001021 is_legacy: false,
Milutin Kristofic8fc3d8f82021-08-10 20:25:21 +02001022 };
1023}
Ben Rohlfs54fd41d2021-09-22 09:10:50 +02001024
Marija Savtchouk839bca52022-01-25 17:22:49 +00001025export function createNonApplicableSubmitRequirementResultInfo(): SubmitRequirementResultInfo {
1026 return {
1027 name: 'Verified',
1028 status: SubmitRequirementStatus.NOT_APPLICABLE,
1029 applicability_expression_result: createSubmitRequirementExpressionInfo(),
Milutin Kristofic9a092902022-02-15 16:36:28 +01001030 submittability_expression_result: createSubmitRequirementExpressionInfo(),
Marija Savtchouk839bca52022-01-25 17:22:49 +00001031 is_legacy: false,
1032 };
1033}
1034
Ben Rohlfs54fd41d2021-09-22 09:10:50 +02001035export function createRunResult(): RunResult {
1036 return {
1037 attemptDetails: [],
1038 category: Category.INFO,
1039 checkName: 'test-name',
1040 internalResultId: 'test-internal-result-id',
1041 internalRunId: 'test-internal-run-id',
1042 isLatestAttempt: true,
1043 isSingleAttempt: true,
1044 pluginName: 'test-plugin-name',
1045 status: RunStatus.COMPLETED,
1046 summary: 'This is the test summary.',
1047 message: 'This is the test message.',
1048 };
1049}
Milutin Kristoficc7ffc562021-10-12 11:54:46 +02001050
Milutin Kristofic5a612662022-05-04 16:10:37 +02001051export function createCheckResult(): CheckResult {
1052 return {
1053 category: Category.ERROR,
1054 summary: 'error',
1055 internalResultId: 'test-internal-result-id',
1056 };
1057}
1058
Milutin Kristoficc7ffc562021-10-12 11:54:46 +02001059export function createDetailedLabelInfo(): DetailedLabelInfo {
1060 return {
1061 values: {
1062 ' 0': 'No score',
1063 '+1': 'Style Verified',
1064 '-1': 'Wrong Style or Formatting',
1065 },
1066 };
1067}
Milutin Kristofic064b6b92021-11-10 20:15:35 +01001068
1069export function createQuickLabelInfo(): QuickLabelInfo {
1070 return {};
1071}