blob: 26547fb3038f89c98de17351ba271e20b5d756a9 [file] [log] [blame]
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +02001/**
2 * @license
3 * Copyright (C) 2020 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18import {
19 AccountId,
20 AccountInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010021 AccountsConfigInfo,
22 ApprovalInfo,
23 AuthInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020024 BranchName,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010025 ChangeConfigInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020026 ChangeId,
27 ChangeInfo,
28 ChangeInfoId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020029 ChangeMessageId,
30 ChangeMessageInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010031 ChangeViewChangeInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020032 CommentLinkInfo,
33 CommentLinks,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010034 CommitId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020035 CommitInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020036 ConfigInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010037 DownloadInfo,
38 EditPatchSetNum,
39 GerritInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020040 EmailAddress,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020041 GitPersonInfo,
42 GitRef,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020043 InheritedBooleanInfo,
44 MaxObjectSizeLimitInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010045 MergeableInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020046 NumericChangeId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020047 PatchSetNum,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010048 PluginConfigInfo,
49 PreferencesInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020050 RepoName,
51 Reviewers,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020052 RevisionInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010053 SchemesInfoMap,
54 ServerInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020055 SubmitTypeInfo,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010056 SuggestInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020057 Timestamp,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020058 TimezoneOffset,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010059 UserConfigInfo,
Ben Rohlfs07d0f6c2020-11-04 08:46:30 +010060 AccountDetailInfo,
Milutin Kristofic40a6cde2020-11-30 23:48:28 +010061 Requirement,
62 RequirementType,
Dhruv Srivastava52e7f152020-10-15 14:41:58 +020063 UrlEncodedCommentId,
Dhruv Srivastava591b4902021-03-10 11:48:12 +010064 BasePatchSetNum,
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +010065 RelatedChangeAndCommitInfo,
66 SubmittedTogetherInfo,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020067} from '../types/common';
68import {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010069 AccountsVisibility,
70 AppTheme,
71 AuthType,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020072 ChangeStatus,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010073 DateFormat,
74 DefaultBase,
75 DefaultDisplayNameConfig,
76 DiffViewMode,
77 EmailStrategy,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020078 InheritedBooleanInfoConfiguredValue,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010079 MergeabilityComputationBehavior,
Dmitrii Filippov0695d402020-10-22 16:57:57 +020080 RevisionKind,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020081 SubmitType,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010082 TimeFormat,
Milutin Kristofic40a6cde2020-11-30 23:48:28 +010083 RequirementStatus,
Dhruv Srivastava52e7f152020-10-15 14:41:58 +020084 CommentSide,
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020085} from '../constants/constants';
86import {formatDate} from '../utils/date-util';
Ben Rohlfsa9d2cff2021-01-22 21:33:58 +010087import {GetDiffCommentsOutput} from '../services/gr-rest-api/gr-rest-api';
Dmitrii Filippov78448cd2020-10-26 17:39:11 +010088import {AppElementChangeViewParams} from '../elements/gr-app-types';
Milutin Kristofic40a6cde2020-11-30 23:48:28 +010089import {CommitInfoWithRequiredCommit} from '../elements/change/gr-change-metadata/gr-change-metadata';
90import {WebLinkInfo} from '../types/diff';
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +010091import {UIComment, UIDraft, createCommentThreads} from '../utils/comment-util';
Ben Rohlfsebe4acc2020-12-11 21:16:10 +010092import {GerritView} from '../services/router/router-model';
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +010093import {ChangeComments} from '../elements/diff/gr-comment-api/gr-comment-api';
Ben Rohlfsa00ef282021-01-22 21:45:53 +010094import {EditRevisionInfo, ParsedChangeInfo} from '../types/types';
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +020095
96export function dateToTimestamp(date: Date): Timestamp {
97 const nanosecondSuffix = '.000000000';
98 return (formatDate(date, 'YYYY-MM-DD HH:mm:ss') +
99 nanosecondSuffix) as Timestamp;
100}
101
102export function createCommentLink(match = 'test'): CommentLinkInfo {
103 return {
104 match,
105 };
106}
107
108export function createInheritedBoolean(value = false): InheritedBooleanInfo {
109 return {
110 value,
111 configured_value: value
112 ? InheritedBooleanInfoConfiguredValue.TRUE
113 : InheritedBooleanInfoConfiguredValue.FALSE,
114 };
115}
116
117export function createMaxObjectSizeLimit(): MaxObjectSizeLimitInfo {
118 return {};
119}
120
121export function createSubmitType(
122 value: Exclude<SubmitType, SubmitType.INHERIT> = SubmitType.MERGE_IF_NECESSARY
123): SubmitTypeInfo {
124 return {
125 value,
126 configured_value: SubmitType.INHERIT,
127 inherited_value: value,
128 };
129}
130
131export function createCommentLinks(): CommentLinks {
132 return {};
133}
134
135export function createConfig(): ConfigInfo {
136 return {
137 private_by_default: createInheritedBoolean(),
138 work_in_progress_by_default: createInheritedBoolean(),
139 max_object_size_limit: createMaxObjectSizeLimit(),
140 default_submit_type: createSubmitType(),
141 submit_type: SubmitType.INHERIT,
142 commentlinks: createCommentLinks(),
143 };
144}
145
146export function createAccountWithId(id = 5): AccountInfo {
147 return {
148 _account_id: id as AccountId,
149 };
150}
151
Ben Rohlfs07d0f6c2020-11-04 08:46:30 +0100152export function createAccountDetailWithId(id = 5): AccountDetailInfo {
153 return {
154 _account_id: id as AccountId,
155 registered_on: dateToTimestamp(new Date(2020, 10, 15, 14, 5, 8)),
156 };
157}
158
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200159export function createAccountWithEmail(email = 'test@'): AccountInfo {
160 return {
161 email: email as EmailAddress,
162 };
163}
164
165export function createAccountWithIdNameAndEmail(id = 5): AccountInfo {
166 return {
167 _account_id: id as AccountId,
168 email: `user-${id}@` as EmailAddress,
169 name: `User-${id}`,
170 };
171}
172
173export function createReviewers(): Reviewers {
174 return {};
175}
176
177export const TEST_PROJECT_NAME: RepoName = 'test-project' as RepoName;
178export const TEST_BRANCH_ID: BranchName = 'test-branch' as BranchName;
179export const TEST_CHANGE_ID: ChangeId = 'TestChangeId' as ChangeId;
180export const TEST_CHANGE_INFO_ID: ChangeInfoId = `${TEST_PROJECT_NAME}~${TEST_BRANCH_ID}~${TEST_CHANGE_ID}` as ChangeInfoId;
181export const TEST_SUBJECT = 'Test subject';
182export const TEST_NUMERIC_CHANGE_ID = 42 as NumericChangeId;
183
184export const TEST_CHANGE_CREATED = new Date(2020, 1, 1, 1, 2, 3);
185export const TEST_CHANGE_UPDATED = new Date(2020, 10, 6, 5, 12, 34);
186
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100187export function createGitPerson(name = 'Test name'): GitPersonInfo {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200188 return {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100189 name,
190 email: `${name}@`,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200191 date: dateToTimestamp(new Date(2019, 11, 6, 14, 5, 8)),
192 tz: 0 as TimezoneOffset,
193 };
194}
195
196export function createCommit(): CommitInfo {
197 return {
198 parents: [],
199 author: createGitPerson(),
200 committer: createGitPerson(),
201 subject: 'Test commit subject',
202 message: 'Test commit message',
203 };
204}
205
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100206export function createCommitInfoWithRequiredCommit(
207 commit = 'commit'
208): CommitInfoWithRequiredCommit {
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100209 return {
210 ...createCommit(),
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100211 commit: commit as CommitId,
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100212 };
213}
214
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100215export function createRevision(patchSetNum = 1): RevisionInfo {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200216 return {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100217 _number: patchSetNum as PatchSetNum,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200218 commit: createCommit(),
219 created: dateToTimestamp(TEST_CHANGE_CREATED),
220 kind: RevisionKind.REWORK,
221 ref: 'refs/changes/5/6/1' as GitRef,
222 uploader: createAccountWithId(),
223 };
224}
225
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100226export function createEditRevision(): EditRevisionInfo {
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200227 return {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100228 _number: EditPatchSetNum,
Dhruv Srivastava591b4902021-03-10 11:48:12 +0100229 basePatchNum: 1 as BasePatchSetNum,
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100230 commit: createCommit(),
231 };
232}
233
234export function createChangeMessage(id = 'cm_id_1'): ChangeMessageInfo {
235 return {
236 id: id as ChangeMessageId,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200237 date: dateToTimestamp(TEST_CHANGE_CREATED),
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100238 message: `This is a message with id ${id}`,
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200239 };
240}
241
242export function createRevisions(
243 count: number
244): {[revisionId: string]: RevisionInfo} {
245 const revisions: {[revisionId: string]: RevisionInfo} = {};
246 const revisionDate = TEST_CHANGE_CREATED;
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100247 const revisionIdStart = 1; // The same as getCurrentRevision
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200248 for (let i = 0; i < count; i++) {
249 const revisionId = (i + revisionIdStart).toString(16);
250 const revision: RevisionInfo = {
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100251 ...createRevision(i + 1),
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200252 created: dateToTimestamp(revisionDate),
253 ref: `refs/changes/5/6/${i + 1}` as GitRef,
254 };
255 revisions[revisionId] = revision;
256 // advance 1 day
257 revisionDate.setDate(revisionDate.getDate() + 1);
258 }
259 return revisions;
260}
261
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100262export function getCurrentRevision(count: number): CommitId {
263 const revisionIdStart = 1; // The same as createRevisions
264 return (count + revisionIdStart).toString(16) as CommitId;
265}
266
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200267export function createChangeMessages(count: number): ChangeMessageInfo[] {
268 const messageIdStart = 1000;
269 const messages: ChangeMessageInfo[] = [];
270 const messageDate = TEST_CHANGE_CREATED;
271 for (let i = 0; i < count; i++) {
272 messages.push({
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100273 ...createChangeMessage((i + messageIdStart).toString(16)),
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200274 date: dateToTimestamp(messageDate),
Dmitrii Filippov0695d402020-10-22 16:57:57 +0200275 });
276 messageDate.setDate(messageDate.getDate() + 1);
277 }
278 return messages;
279}
280
Dmitrii Filippovfc3e4f72020-10-22 16:57:57 +0200281export function createChange(): ChangeInfo {
282 return {
283 id: TEST_CHANGE_INFO_ID,
284 project: TEST_PROJECT_NAME,
285 branch: TEST_BRANCH_ID,
286 change_id: TEST_CHANGE_ID,
287 subject: TEST_SUBJECT,
288 status: ChangeStatus.NEW,
289 created: dateToTimestamp(TEST_CHANGE_CREATED),
290 updated: dateToTimestamp(TEST_CHANGE_UPDATED),
291 insertions: 0,
292 deletions: 0,
293 _number: TEST_NUMERIC_CHANGE_ID,
294 owner: createAccountWithId(),
295 // This is documented as optional, but actually always set.
296 reviewers: createReviewers(),
297 };
298}
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100299
300export function createChangeViewChange(): ChangeViewChangeInfo {
301 return {
302 ...createChange(),
303 revisions: {
304 abc: createRevision(),
305 },
306 current_revision: 'abc' as CommitId,
307 };
308}
309
310export function createParsedChange(): ParsedChangeInfo {
311 return createChangeViewChange();
312}
313
314export function createAccountsConfig(): AccountsConfigInfo {
315 return {
316 visibility: AccountsVisibility.ALL,
317 default_display_name: DefaultDisplayNameConfig.FULL_NAME,
318 };
319}
320
321export function createAuth(): AuthInfo {
322 return {
323 auth_type: AuthType.OPENID,
324 editable_account_fields: [],
325 };
326}
327
328export function createChangeConfig(): ChangeConfigInfo {
329 return {
330 large_change: 500,
331 reply_label: 'Reply',
332 reply_tooltip: 'Reply and score',
333 // The default update_delay is 5 minutes, but we don't want to accidentally
334 // start polling in tests
335 update_delay: 0,
336 mergeability_computation_behavior:
337 MergeabilityComputationBehavior.REF_UPDATED_AND_CHANGE_REINDEX,
338 enable_attention_set: false,
339 enable_assignee: false,
340 };
341}
342
343export function createDownloadSchemes(): SchemesInfoMap {
344 return {};
345}
346
347export function createDownloadInfo(): DownloadInfo {
348 return {
349 schemes: createDownloadSchemes(),
350 archives: ['tgz', 'tar'],
351 };
352}
353
354export function createGerritInfo(): GerritInfo {
355 return {
356 all_projects: 'All-Projects',
357 all_users: 'All-Users',
358 doc_search: false,
359 };
360}
361
362export function createPluginConfig(): PluginConfigInfo {
363 return {
364 has_avatars: false,
365 js_resource_paths: [],
366 html_resource_paths: [],
367 };
368}
369
370export function createSuggestInfo(): SuggestInfo {
371 return {
372 from: 0,
373 };
374}
375
376export function createUserConfig(): UserConfigInfo {
377 return {
378 anonymous_coward_name: 'Name of user not set',
379 };
380}
381
382export function createServerInfo(): ServerInfo {
383 return {
384 accounts: createAccountsConfig(),
385 auth: createAuth(),
386 change: createChangeConfig(),
387 download: createDownloadInfo(),
388 gerrit: createGerritInfo(),
389 plugin: createPluginConfig(),
390 suggest: createSuggestInfo(),
391 user: createUserConfig(),
392 };
393}
394
395export function createGetDiffCommentsOutput(): GetDiffCommentsOutput {
396 return {
397 baseComments: [],
398 comments: [],
399 };
400}
401
402export function createMergeable(): MergeableInfo {
403 return {
404 submit_type: SubmitType.MERGE_IF_NECESSARY,
405 mergeable: false,
406 };
407}
408
Ben Rohlfs3a6ff7e2021-01-18 14:08:39 +0100409// TODO: Maybe reconcile with createDefaultPreferences() in constants.ts.
Dmitrii Filippov78448cd2020-10-26 17:39:11 +0100410export function createPreferences(): PreferencesInfo {
411 return {
412 changes_per_page: 10,
413 theme: AppTheme.LIGHT,
414 date_format: DateFormat.ISO,
415 time_format: TimeFormat.HHMM_24,
416 diff_view: DiffViewMode.SIDE_BY_SIDE,
417 my: [],
418 change_table: [],
419 email_strategy: EmailStrategy.ENABLED,
420 default_base_for_merges: DefaultBase.AUTO_MERGE,
421 };
422}
423
424export function createApproval(): ApprovalInfo {
425 return createAccountWithId();
426}
427
428export function createAppElementChangeViewParams(): AppElementChangeViewParams {
429 return {
430 view: GerritView.CHANGE,
431 changeNum: TEST_NUMERIC_CHANGE_ID,
432 project: TEST_PROJECT_NAME,
433 };
434}
Milutin Kristofic40a6cde2020-11-30 23:48:28 +0100435
436export function createRequirement(): Requirement {
437 return {
438 status: RequirementStatus.OK,
439 fallbackText: '',
440 type: 'wip' as RequirementType,
441 };
442}
443
444export function createWebLinkInfo(): WebLinkInfo {
445 return {
446 name: 'gitiles',
447 url: '#',
448 image_url: 'gitiles.jpg',
449 };
450}
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200451
452export function createComment(): UIComment {
453 return {
454 patch_set: 1 as PatchSetNum,
455 id: '12345' as UrlEncodedCommentId,
456 side: CommentSide.REVISION,
457 line: 1,
458 message: 'hello world',
459 updated: '2018-02-13 22:48:48.018000000' as Timestamp,
460 unresolved: false,
Dhruv Srivastava254cb722021-03-08 21:15:37 +0100461 path: 'abc.txt',
Dhruv Srivastava52e7f152020-10-15 14:41:58 +0200462 };
463}
464
465export function createDraft(): UIDraft {
466 return {
467 ...createComment(),
468 collapsed: false,
469 __draft: true,
470 __editing: false,
471 };
472}
Dhruv Srivastava430c1dd2020-12-14 08:39:32 +0100473
474export function createChangeComments(): ChangeComments {
475 const comments = {
476 '/COMMIT_MSG': [
477 {
478 ...createComment(),
479 message: 'Done',
480 updated: '2017-02-08 16:40:49' as Timestamp,
481 id: '1' as UrlEncodedCommentId,
482 },
483 {
484 ...createComment(),
485 message: 'oh hay',
486 updated: '2017-02-09 16:40:49' as Timestamp,
487 id: '2' as UrlEncodedCommentId,
488 },
489 {
490 ...createComment(),
491 patch_set: 2 as PatchSetNum,
492 message: 'hello',
493 updated: '2017-02-10 16:40:49' as Timestamp,
494 id: '3' as UrlEncodedCommentId,
495 },
496 ],
497 'myfile.txt': [
498 {
499 ...createComment(),
500 message: 'good news!',
501 updated: '2017-02-08 16:40:49' as Timestamp,
502 id: '4' as UrlEncodedCommentId,
503 },
504 {
505 ...createComment(),
506 patch_set: 2 as PatchSetNum,
507 message: 'wat!?',
508 updated: '2017-02-09 16:40:49' as Timestamp,
509 id: '5' as UrlEncodedCommentId,
510 },
511 {
512 ...createComment(),
513 patch_set: 2 as PatchSetNum,
514 message: 'hi',
515 updated: '2017-02-10 16:40:49' as Timestamp,
516 id: '6' as UrlEncodedCommentId,
517 },
518 ],
519 'unresolved.file': [
520 {
521 ...createComment(),
522 patch_set: 2 as PatchSetNum,
523 message: 'wat!?',
524 updated: '2017-02-09 16:40:49' as Timestamp,
525 id: '7' as UrlEncodedCommentId,
526 unresolved: true,
527 },
528 {
529 ...createComment(),
530 patch_set: 2 as PatchSetNum,
531 message: 'hi',
532 updated: '2017-02-10 16:40:49' as Timestamp,
533 id: '8' as UrlEncodedCommentId,
534 in_reply_to: '7' as UrlEncodedCommentId,
535 unresolved: false,
536 },
537 {
538 ...createComment(),
539 patch_set: 2 as PatchSetNum,
540 message: 'good news!',
541 updated: '2017-02-08 16:40:49' as Timestamp,
542 id: '9' as UrlEncodedCommentId,
543 unresolved: true,
544 },
545 ],
546 };
547 const drafts = {
548 '/COMMIT_MSG': [
549 {
550 ...createDraft(),
551 message: 'hi',
552 updated: '2017-02-15 16:40:49' as Timestamp,
553 id: '10' as UrlEncodedCommentId,
554 unresolved: true,
555 },
556 {
557 ...createDraft(),
558 message: 'fyi',
559 updated: '2017-02-15 16:40:49' as Timestamp,
560 id: '11' as UrlEncodedCommentId,
561 unresolved: false,
562 },
563 ],
564 'unresolved.file': [
565 {
566 ...createDraft(),
567 message: 'hi',
568 updated: '2017-02-11 16:40:49' as Timestamp,
569 id: '12' as UrlEncodedCommentId,
570 unresolved: false,
571 },
572 ],
573 };
574 return new ChangeComments(comments, {}, drafts, {}, {});
575}
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +0100576
577export function createCommentThread(comments: UIComment[]) {
Dhruv Srivastava254cb722021-03-08 21:15:37 +0100578 if (!comments.length) {
579 throw new Error('comment is required to create a thread');
580 }
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +0100581 comments = comments.map(comment => {
582 return {...createComment(), ...comment};
583 });
584 const threads = createCommentThreads(comments);
Dhruv Srivastava254cb722021-03-08 21:15:37 +0100585 return threads[0];
Dhruv Srivastavad6737fb2020-12-16 13:54:12 +0100586}
Milutin Kristoficf4c04fb42021-03-10 16:41:19 +0100587
588export function createRelatedChangeAndCommitInfo(): RelatedChangeAndCommitInfo {
589 return {
590 project: TEST_PROJECT_NAME,
591 commit: createCommitInfoWithRequiredCommit(),
592 };
593}
594
595export function createSubmittedTogetherInfo(): SubmittedTogetherInfo {
596 return {
597 changes: [],
598 non_visible_changes: 0,
599 };
600}