]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/activitypub/client.ts
Add austrian sign language
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / client.ts
index c3e4b7f74a26f866d261bbb243a8d1e6c3b878f8..90c89138c1ff414a3023ab5e31eda0fd6f8ec5b8 100644 (file)
@@ -1,7 +1,8 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
+import { processViewersStats } from '@server/tests/shared'
+import { HttpStatusCode, VideoPlaylistPrivacy, WatchActionObject } from '@shared/models'
 import {
   cleanupTests,
   createMultipleServers,
@@ -10,10 +11,7 @@ import {
   PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel
-} from '@shared/extra-utils'
-import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
-
-const expect = chai.expect
+} from '@shared/server-commands'
 
 describe('Test activitypub', function () {
   let servers: PeerTubeServer[] = []
@@ -115,6 +113,23 @@ describe('Test activitypub', function () {
     expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid)
   })
 
+  it('Should return the watch action', async function () {
+    this.timeout(50000)
+
+    await servers[0].views.simulateViewer({ id: video.uuid, currentTimes: [ 0, 2 ] })
+    await processViewersStats(servers)
+
+    const res = await makeActivityPubGetRequest(servers[0].url, '/videos/local-viewer/1', HttpStatusCode.OK_200)
+
+    const object: WatchActionObject = res.body
+    expect(object.type).to.equal('WatchAction')
+    expect(object.duration).to.equal('PT2S')
+    expect(object.actionStatus).to.equal('CompletedActionStatus')
+    expect(object.watchSections).to.have.lengthOf(1)
+    expect(object.watchSections[0].startTimestamp).to.equal(0)
+    expect(object.watchSections[0].endTimestamp).to.equal(2)
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })