video-playlists.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
  2. import 'mocha'
  3. import {
  4. addVideoInPlaylist,
  5. cleanupTests,
  6. createVideoPlaylist,
  7. deleteVideoPlaylist,
  8. flushAndRunServer,
  9. generateUserAccessToken,
  10. getAccountPlaylistsListWithToken,
  11. getVideoPlaylist,
  12. immutableAssign,
  13. makeGetRequest,
  14. removeVideoFromPlaylist,
  15. reorderVideosPlaylist,
  16. ServerInfo,
  17. setAccessTokensToServers,
  18. setDefaultVideoChannel,
  19. updateVideoPlaylist,
  20. updateVideoPlaylistElement,
  21. uploadVideoAndGetId
  22. } from '../../../../shared/extra-utils'
  23. import {
  24. checkBadCountPagination,
  25. checkBadSortPagination,
  26. checkBadStartPagination
  27. } from '../../../../shared/extra-utils/requests/check-api-params'
  28. import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
  29. import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
  30. import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
  31. describe('Test video playlists API validator', function () {
  32. let server: ServerInfo
  33. let userAccessToken: string
  34. let playlistUUID: string
  35. let privatePlaylistUUID: string
  36. let watchLaterPlaylistId: number
  37. let videoId: number
  38. let playlistElementId: number
  39. // ---------------------------------------------------------------
  40. before(async function () {
  41. this.timeout(30000)
  42. server = await flushAndRunServer(1)
  43. await setAccessTokensToServers([ server ])
  44. await setDefaultVideoChannel([ server ])
  45. userAccessToken = await generateUserAccessToken(server, 'user1')
  46. videoId = (await uploadVideoAndGetId({ server, videoName: 'video 1' })).id
  47. {
  48. const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER)
  49. watchLaterPlaylistId = res.body.data[0].id
  50. }
  51. {
  52. const res = await createVideoPlaylist({
  53. url: server.url,
  54. token: server.accessToken,
  55. playlistAttrs: {
  56. displayName: 'super playlist',
  57. privacy: VideoPlaylistPrivacy.PUBLIC,
  58. videoChannelId: server.videoChannel.id
  59. }
  60. })
  61. playlistUUID = res.body.videoPlaylist.uuid
  62. }
  63. {
  64. const res = await createVideoPlaylist({
  65. url: server.url,
  66. token: server.accessToken,
  67. playlistAttrs: {
  68. displayName: 'private',
  69. privacy: VideoPlaylistPrivacy.PRIVATE
  70. }
  71. })
  72. privatePlaylistUUID = res.body.videoPlaylist.uuid
  73. }
  74. })
  75. describe('When listing playlists', function () {
  76. const globalPath = '/api/v1/video-playlists'
  77. const accountPath = '/api/v1/accounts/root/video-playlists'
  78. const videoChannelPath = '/api/v1/video-channels/root_channel/video-playlists'
  79. it('Should fail with a bad start pagination', async function () {
  80. await checkBadStartPagination(server.url, globalPath, server.accessToken)
  81. await checkBadStartPagination(server.url, accountPath, server.accessToken)
  82. await checkBadStartPagination(server.url, videoChannelPath, server.accessToken)
  83. })
  84. it('Should fail with a bad count pagination', async function () {
  85. await checkBadCountPagination(server.url, globalPath, server.accessToken)
  86. await checkBadCountPagination(server.url, accountPath, server.accessToken)
  87. await checkBadCountPagination(server.url, videoChannelPath, server.accessToken)
  88. })
  89. it('Should fail with an incorrect sort', async function () {
  90. await checkBadSortPagination(server.url, globalPath, server.accessToken)
  91. await checkBadSortPagination(server.url, accountPath, server.accessToken)
  92. await checkBadSortPagination(server.url, videoChannelPath, server.accessToken)
  93. })
  94. it('Should fail with a bad playlist type', async function () {
  95. await makeGetRequest({ url: server.url, path: globalPath, query: { playlistType: 3 } })
  96. await makeGetRequest({ url: server.url, path: accountPath, query: { playlistType: 3 } })
  97. await makeGetRequest({ url: server.url, path: videoChannelPath, query: { playlistType: 3 } })
  98. })
  99. it('Should fail with a bad account parameter', async function () {
  100. const accountPath = '/api/v1/accounts/root2/video-playlists'
  101. await makeGetRequest({
  102. url: server.url,
  103. path: accountPath,
  104. statusCodeExpected: HttpStatusCode.NOT_FOUND_404,
  105. token: server.accessToken
  106. })
  107. })
  108. it('Should fail with a bad video channel parameter', async function () {
  109. const accountPath = '/api/v1/video-channels/bad_channel/video-playlists'
  110. await makeGetRequest({
  111. url: server.url,
  112. path: accountPath,
  113. statusCodeExpected: HttpStatusCode.NOT_FOUND_404,
  114. token: server.accessToken
  115. })
  116. })
  117. it('Should success with the correct parameters', async function () {
  118. await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken })
  119. await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken })
  120. await makeGetRequest({
  121. url: server.url,
  122. path: videoChannelPath,
  123. statusCodeExpected: HttpStatusCode.OK_200,
  124. token: server.accessToken
  125. })
  126. })
  127. })
  128. describe('When listing videos of a playlist', function () {
  129. const path = '/api/v1/video-playlists/'
  130. it('Should fail with a bad start pagination', async function () {
  131. await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken)
  132. })
  133. it('Should fail with a bad count pagination', async function () {
  134. await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken)
  135. })
  136. it('Should success with the correct parameters', async function () {
  137. await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 })
  138. })
  139. })
  140. describe('When getting a video playlist', function () {
  141. it('Should fail with a bad id or uuid', async function () {
  142. await getVideoPlaylist(server.url, 'toto', HttpStatusCode.BAD_REQUEST_400)
  143. })
  144. it('Should fail with an unknown playlist', async function () {
  145. await getVideoPlaylist(server.url, 42, HttpStatusCode.NOT_FOUND_404)
  146. })
  147. it('Should fail to get an unlisted playlist with the number id', async function () {
  148. const res = await createVideoPlaylist({
  149. url: server.url,
  150. token: server.accessToken,
  151. playlistAttrs: {
  152. displayName: 'super playlist',
  153. privacy: VideoPlaylistPrivacy.UNLISTED
  154. }
  155. })
  156. const playlist = res.body.videoPlaylist
  157. await getVideoPlaylist(server.url, playlist.id, HttpStatusCode.NOT_FOUND_404)
  158. await getVideoPlaylist(server.url, playlist.uuid, HttpStatusCode.OK_200)
  159. })
  160. it('Should succeed with the correct params', async function () {
  161. await getVideoPlaylist(server.url, playlistUUID, HttpStatusCode.OK_200)
  162. })
  163. })
  164. describe('When creating/updating a video playlist', function () {
  165. const getBase = (playlistAttrs: any = {}, wrapper: any = {}) => {
  166. return Object.assign({
  167. expectedStatus: HttpStatusCode.BAD_REQUEST_400,
  168. url: server.url,
  169. token: server.accessToken,
  170. playlistAttrs: Object.assign({
  171. displayName: 'display name',
  172. privacy: VideoPlaylistPrivacy.UNLISTED,
  173. thumbnailfile: 'thumbnail.jpg',
  174. videoChannelId: server.videoChannel.id
  175. }, playlistAttrs)
  176. }, wrapper)
  177. }
  178. const getUpdate = (params: any, playlistId: number | string) => {
  179. return immutableAssign(params, { playlistId: playlistId })
  180. }
  181. it('Should fail with an unauthenticated user', async function () {
  182. const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
  183. await createVideoPlaylist(params)
  184. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  185. })
  186. it('Should fail without displayName', async function () {
  187. const params = getBase({ displayName: undefined })
  188. await createVideoPlaylist(params)
  189. })
  190. it('Should fail with an incorrect display name', async function () {
  191. const params = getBase({ displayName: 's'.repeat(300) })
  192. await createVideoPlaylist(params)
  193. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  194. })
  195. it('Should fail with an incorrect description', async function () {
  196. const params = getBase({ description: 't' })
  197. await createVideoPlaylist(params)
  198. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  199. })
  200. it('Should fail with an incorrect privacy', async function () {
  201. const params = getBase({ privacy: 45 })
  202. await createVideoPlaylist(params)
  203. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  204. })
  205. it('Should fail with an unknown video channel id', async function () {
  206. const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  207. await createVideoPlaylist(params)
  208. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  209. })
  210. it('Should fail with an incorrect thumbnail file', async function () {
  211. const params = getBase({ thumbnailfile: 'avatar.png' })
  212. await createVideoPlaylist(params)
  213. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  214. })
  215. it('Should fail to set "public" a playlist not assigned to a channel', async function () {
  216. const params = getBase({ privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: undefined })
  217. const params2 = getBase({ privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: 'null' })
  218. const params3 = getBase({ privacy: undefined, videoChannelId: 'null' })
  219. await createVideoPlaylist(params)
  220. await createVideoPlaylist(params2)
  221. await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID))
  222. await updateVideoPlaylist(getUpdate(params2, playlistUUID))
  223. await updateVideoPlaylist(getUpdate(params3, playlistUUID))
  224. })
  225. it('Should fail with an unknown playlist to update', async function () {
  226. await updateVideoPlaylist(getUpdate(
  227. getBase({}, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }),
  228. 42
  229. ))
  230. })
  231. it('Should fail to update a playlist of another user', async function () {
  232. await updateVideoPlaylist(getUpdate(
  233. getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }),
  234. playlistUUID
  235. ))
  236. })
  237. it('Should fail to update the watch later playlist', async function () {
  238. await updateVideoPlaylist(getUpdate(
  239. getBase({}, { expectedStatus: HttpStatusCode.BAD_REQUEST_400 }),
  240. watchLaterPlaylistId
  241. ))
  242. })
  243. it('Should succeed with the correct params', async function () {
  244. {
  245. const params = getBase({}, { expectedStatus: HttpStatusCode.OK_200 })
  246. await createVideoPlaylist(params)
  247. }
  248. {
  249. const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 })
  250. await updateVideoPlaylist(getUpdate(params, playlistUUID))
  251. }
  252. })
  253. })
  254. describe('When adding an element in a playlist', function () {
  255. const getBase = (elementAttrs: any = {}, wrapper: any = {}) => {
  256. return Object.assign({
  257. expectedStatus: HttpStatusCode.BAD_REQUEST_400,
  258. url: server.url,
  259. token: server.accessToken,
  260. playlistId: playlistUUID,
  261. elementAttrs: Object.assign({
  262. videoId,
  263. startTimestamp: 2,
  264. stopTimestamp: 3
  265. }, elementAttrs)
  266. }, wrapper)
  267. }
  268. it('Should fail with an unauthenticated user', async function () {
  269. const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
  270. await addVideoInPlaylist(params)
  271. })
  272. it('Should fail with the playlist of another user', async function () {
  273. const params = getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
  274. await addVideoInPlaylist(params)
  275. })
  276. it('Should fail with an unknown or incorrect playlist id', async function () {
  277. {
  278. const params = getBase({}, { playlistId: 'toto' })
  279. await addVideoInPlaylist(params)
  280. }
  281. {
  282. const params = getBase({}, { playlistId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  283. await addVideoInPlaylist(params)
  284. }
  285. })
  286. it('Should fail with an unknown or incorrect video id', async function () {
  287. const params = getBase({ videoId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  288. await addVideoInPlaylist(params)
  289. })
  290. it('Should fail with a bad start/stop timestamp', async function () {
  291. {
  292. const params = getBase({ startTimestamp: -42 })
  293. await addVideoInPlaylist(params)
  294. }
  295. {
  296. const params = getBase({ stopTimestamp: 'toto' as any })
  297. await addVideoInPlaylist(params)
  298. }
  299. })
  300. it('Succeed with the correct params', async function () {
  301. const params = getBase({}, { expectedStatus: HttpStatusCode.OK_200 })
  302. const res = await addVideoInPlaylist(params)
  303. playlistElementId = res.body.videoPlaylistElement.id
  304. })
  305. })
  306. describe('When updating an element in a playlist', function () {
  307. const getBase = (elementAttrs: any = {}, wrapper: any = {}) => {
  308. return Object.assign({
  309. url: server.url,
  310. token: server.accessToken,
  311. elementAttrs: Object.assign({
  312. startTimestamp: 1,
  313. stopTimestamp: 2
  314. }, elementAttrs),
  315. playlistElementId,
  316. playlistId: playlistUUID,
  317. expectedStatus: HttpStatusCode.BAD_REQUEST_400
  318. }, wrapper)
  319. }
  320. it('Should fail with an unauthenticated user', async function () {
  321. const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
  322. await updateVideoPlaylistElement(params)
  323. })
  324. it('Should fail with the playlist of another user', async function () {
  325. const params = getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
  326. await updateVideoPlaylistElement(params)
  327. })
  328. it('Should fail with an unknown or incorrect playlist id', async function () {
  329. {
  330. const params = getBase({}, { playlistId: 'toto' })
  331. await updateVideoPlaylistElement(params)
  332. }
  333. {
  334. const params = getBase({}, { playlistId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  335. await updateVideoPlaylistElement(params)
  336. }
  337. })
  338. it('Should fail with an unknown or incorrect playlistElement id', async function () {
  339. {
  340. const params = getBase({}, { playlistElementId: 'toto' })
  341. await updateVideoPlaylistElement(params)
  342. }
  343. {
  344. const params = getBase({}, { playlistElementId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  345. await updateVideoPlaylistElement(params)
  346. }
  347. })
  348. it('Should fail with a bad start/stop timestamp', async function () {
  349. {
  350. const params = getBase({ startTimestamp: 'toto' as any })
  351. await updateVideoPlaylistElement(params)
  352. }
  353. {
  354. const params = getBase({ stopTimestamp: -42 })
  355. await updateVideoPlaylistElement(params)
  356. }
  357. })
  358. it('Should fail with an unknown element', async function () {
  359. const params = getBase({}, { playlistElementId: 888, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  360. await updateVideoPlaylistElement(params)
  361. })
  362. it('Succeed with the correct params', async function () {
  363. const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 })
  364. await updateVideoPlaylistElement(params)
  365. })
  366. })
  367. describe('When reordering elements of a playlist', function () {
  368. let videoId3: number
  369. let videoId4: number
  370. const getBase = (elementAttrs: any = {}, wrapper: any = {}) => {
  371. return Object.assign({
  372. url: server.url,
  373. token: server.accessToken,
  374. playlistId: playlistUUID,
  375. elementAttrs: Object.assign({
  376. startPosition: 1,
  377. insertAfterPosition: 2,
  378. reorderLength: 3
  379. }, elementAttrs),
  380. expectedStatus: HttpStatusCode.BAD_REQUEST_400
  381. }, wrapper)
  382. }
  383. before(async function () {
  384. videoId3 = (await uploadVideoAndGetId({ server, videoName: 'video 3' })).id
  385. videoId4 = (await uploadVideoAndGetId({ server, videoName: 'video 4' })).id
  386. for (const id of [ videoId3, videoId4 ]) {
  387. await addVideoInPlaylist({
  388. url: server.url,
  389. token: server.accessToken,
  390. playlistId: playlistUUID,
  391. elementAttrs: { videoId: id }
  392. })
  393. }
  394. })
  395. it('Should fail with an unauthenticated user', async function () {
  396. const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
  397. await reorderVideosPlaylist(params)
  398. })
  399. it('Should fail with the playlist of another user', async function () {
  400. const params = getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
  401. await reorderVideosPlaylist(params)
  402. })
  403. it('Should fail with an invalid playlist', async function () {
  404. {
  405. const params = getBase({}, { playlistId: 'toto' })
  406. await reorderVideosPlaylist(params)
  407. }
  408. {
  409. const params = getBase({}, { playlistId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  410. await reorderVideosPlaylist(params)
  411. }
  412. })
  413. it('Should fail with an invalid start position', async function () {
  414. {
  415. const params = getBase({ startPosition: -1 })
  416. await reorderVideosPlaylist(params)
  417. }
  418. {
  419. const params = getBase({ startPosition: 'toto' as any })
  420. await reorderVideosPlaylist(params)
  421. }
  422. {
  423. const params = getBase({ startPosition: 42 })
  424. await reorderVideosPlaylist(params)
  425. }
  426. })
  427. it('Should fail with an invalid insert after position', async function () {
  428. {
  429. const params = getBase({ insertAfterPosition: 'toto' as any })
  430. await reorderVideosPlaylist(params)
  431. }
  432. {
  433. const params = getBase({ insertAfterPosition: -2 })
  434. await reorderVideosPlaylist(params)
  435. }
  436. {
  437. const params = getBase({ insertAfterPosition: 42 })
  438. await reorderVideosPlaylist(params)
  439. }
  440. })
  441. it('Should fail with an invalid reorder length', async function () {
  442. {
  443. const params = getBase({ reorderLength: 'toto' as any })
  444. await reorderVideosPlaylist(params)
  445. }
  446. {
  447. const params = getBase({ reorderLength: -2 })
  448. await reorderVideosPlaylist(params)
  449. }
  450. {
  451. const params = getBase({ reorderLength: 42 })
  452. await reorderVideosPlaylist(params)
  453. }
  454. })
  455. it('Succeed with the correct params', async function () {
  456. const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 })
  457. await reorderVideosPlaylist(params)
  458. })
  459. })
  460. describe('When checking exists in playlist endpoint', function () {
  461. const path = '/api/v1/users/me/video-playlists/videos-exist'
  462. it('Should fail with an unauthenticated user', async function () {
  463. await makeGetRequest({
  464. url: server.url,
  465. path,
  466. query: { videoIds: [ 1, 2 ] },
  467. statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
  468. })
  469. })
  470. it('Should fail with invalid video ids', async function () {
  471. await makeGetRequest({
  472. url: server.url,
  473. token: server.accessToken,
  474. path,
  475. query: { videoIds: 'toto' }
  476. })
  477. await makeGetRequest({
  478. url: server.url,
  479. token: server.accessToken,
  480. path,
  481. query: { videoIds: [ 'toto' ] }
  482. })
  483. await makeGetRequest({
  484. url: server.url,
  485. token: server.accessToken,
  486. path,
  487. query: { videoIds: [ 1, 'toto' ] }
  488. })
  489. })
  490. it('Should succeed with the correct params', async function () {
  491. await makeGetRequest({
  492. url: server.url,
  493. token: server.accessToken,
  494. path,
  495. query: { videoIds: [ 1, 2 ] },
  496. statusCodeExpected: HttpStatusCode.OK_200
  497. })
  498. })
  499. })
  500. describe('When deleting an element in a playlist', function () {
  501. const getBase = (wrapper: any = {}) => {
  502. return Object.assign({
  503. url: server.url,
  504. token: server.accessToken,
  505. playlistElementId,
  506. playlistId: playlistUUID,
  507. expectedStatus: HttpStatusCode.BAD_REQUEST_400
  508. }, wrapper)
  509. }
  510. it('Should fail with an unauthenticated user', async function () {
  511. const params = getBase({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
  512. await removeVideoFromPlaylist(params)
  513. })
  514. it('Should fail with the playlist of another user', async function () {
  515. const params = getBase({ token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
  516. await removeVideoFromPlaylist(params)
  517. })
  518. it('Should fail with an unknown or incorrect playlist id', async function () {
  519. {
  520. const params = getBase({ playlistId: 'toto' })
  521. await removeVideoFromPlaylist(params)
  522. }
  523. {
  524. const params = getBase({ playlistId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  525. await removeVideoFromPlaylist(params)
  526. }
  527. })
  528. it('Should fail with an unknown or incorrect video id', async function () {
  529. {
  530. const params = getBase({ playlistElementId: 'toto' })
  531. await removeVideoFromPlaylist(params)
  532. }
  533. {
  534. const params = getBase({ playlistElementId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  535. await removeVideoFromPlaylist(params)
  536. }
  537. })
  538. it('Should fail with an unknown element', async function () {
  539. const params = getBase({ playlistElementId: 888, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
  540. await removeVideoFromPlaylist(params)
  541. })
  542. it('Succeed with the correct params', async function () {
  543. const params = getBase({ expectedStatus: HttpStatusCode.NO_CONTENT_204 })
  544. await removeVideoFromPlaylist(params)
  545. })
  546. })
  547. describe('When deleting a playlist', function () {
  548. it('Should fail with an unknown playlist', async function () {
  549. await deleteVideoPlaylist(server.url, server.accessToken, 42, HttpStatusCode.NOT_FOUND_404)
  550. })
  551. it('Should fail with a playlist of another user', async function () {
  552. await deleteVideoPlaylist(server.url, userAccessToken, playlistUUID, HttpStatusCode.FORBIDDEN_403)
  553. })
  554. it('Should fail with the watch later playlist', async function () {
  555. await deleteVideoPlaylist(server.url, server.accessToken, watchLaterPlaylistId, HttpStatusCode.BAD_REQUEST_400)
  556. })
  557. it('Should succeed with the correct params', async function () {
  558. await deleteVideoPlaylist(server.url, server.accessToken, playlistUUID)
  559. })
  560. })
  561. after(async function () {
  562. await cleanupTests([ server ])
  563. })
  564. })