2
1

video-change-ownership.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import * as request from 'supertest'
  2. import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
  3. function changeVideoOwnership (
  4. url: string,
  5. token: string,
  6. videoId: number | string,
  7. username,
  8. expectedStatus = HttpStatusCode.NO_CONTENT_204
  9. ) {
  10. const path = '/api/v1/videos/' + videoId + '/give-ownership'
  11. return request(url)
  12. .post(path)
  13. .set('Accept', 'application/json')
  14. .set('Authorization', 'Bearer ' + token)
  15. .send({ username })
  16. .expect(expectedStatus)
  17. }
  18. function getVideoChangeOwnershipList (url: string, token: string) {
  19. const path = '/api/v1/videos/ownership'
  20. return request(url)
  21. .get(path)
  22. .query({ sort: '-createdAt' })
  23. .set('Accept', 'application/json')
  24. .set('Authorization', 'Bearer ' + token)
  25. .expect(HttpStatusCode.OK_200)
  26. .expect('Content-Type', /json/)
  27. }
  28. function acceptChangeOwnership (
  29. url: string,
  30. token: string,
  31. ownershipId: string,
  32. channelId: number,
  33. expectedStatus = HttpStatusCode.NO_CONTENT_204
  34. ) {
  35. const path = '/api/v1/videos/ownership/' + ownershipId + '/accept'
  36. return request(url)
  37. .post(path)
  38. .set('Accept', 'application/json')
  39. .set('Authorization', 'Bearer ' + token)
  40. .send({ channelId })
  41. .expect(expectedStatus)
  42. }
  43. function refuseChangeOwnership (
  44. url: string,
  45. token: string,
  46. ownershipId: string,
  47. expectedStatus = HttpStatusCode.NO_CONTENT_204
  48. ) {
  49. const path = '/api/v1/videos/ownership/' + ownershipId + '/refuse'
  50. return request(url)
  51. .post(path)
  52. .set('Accept', 'application/json')
  53. .set('Authorization', 'Bearer ' + token)
  54. .expect(expectedStatus)
  55. }
  56. // ---------------------------------------------------------------------------
  57. export {
  58. changeVideoOwnership,
  59. getVideoChangeOwnershipList,
  60. acceptChangeOwnership,
  61. refuseChangeOwnership
  62. }