]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/comments-command.ts
Add bin directory creation for parallel tests
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / comments-command.ts
index 7368f3ea21a9dea5ed73c88e99dfe6f9f6038e11..f0d163a0775f4114abe092cd6fb7a3b15e7569e7 100644 (file)
@@ -1,11 +1,14 @@
 import { pick } from 'lodash'
-import { HttpStatusCode } from '@shared/models'
-import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models'
+import { HttpStatusCode, ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models'
 import { unwrapBody } from '../requests'
 import { AbstractCommand, OverrideCommandOptions } from '../shared'
 
 export class CommentsCommand extends AbstractCommand {
 
+  private lastVideoId: number | string
+  private lastThreadId: number
+  private lastReplyId: number
+
   listForAdmin (options: OverrideCommandOptions & {
     start?: number
     count?: number
@@ -81,6 +84,9 @@ export class CommentsCommand extends AbstractCommand {
       defaultExpectedStatus: HttpStatusCode.OK_200
     }))
 
+    this.lastThreadId = body.comment?.id
+    this.lastVideoId = videoId
+
     return body.comment
   }
 
@@ -101,9 +107,23 @@ export class CommentsCommand extends AbstractCommand {
       defaultExpectedStatus: HttpStatusCode.OK_200
     }))
 
+    this.lastReplyId = body.comment?.id
+
     return body.comment
   }
 
+  async addReplyToLastReply (options: OverrideCommandOptions & {
+    text: string
+  }) {
+    return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastReplyId })
+  }
+
+  async addReplyToLastThread (options: OverrideCommandOptions & {
+    text: string
+  }) {
+    return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastThreadId })
+  }
+
   async findCommentId (options: OverrideCommandOptions & {
     videoId: number | string
     text: string