From b22e5fceb47848112963f763cbb30b725a382fbc Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 27 May 2023 18:07:57 +0400 Subject: [PATCH] Test video attribute "importedFrom" --- server/tests/api/check-params/videos.ts | 12 ++++++++++++ server/tests/shared/videos.ts | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 2a83143e2..3e8000c88 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -202,6 +202,7 @@ describe('Test videos API validator', function () { tags: [ 'tag1', 'tag2' ], privacy: VideoPrivacy.PUBLIC, channelId, + importedFrom: 'https://youtu.be/fe8agy1pb44', originallyPublishedAt: new Date().toISOString() } }) @@ -336,6 +337,12 @@ describe('Test videos API validator', function () { await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) }) + it('Should fail with a bad URL where the video is imported from', async function () { + const fields = { ...baseCorrectParams, importedFrom: 'to' } + const attaches = baseCorrectAttaches + await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) + }) + it('Should fail with a bad originally published at attribute', async function () { const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } const attaches = baseCorrectAttaches @@ -590,6 +597,11 @@ describe('Test videos API validator', function () { await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) + it('Should fail with a bad URL where the video is imported from', async function () { + const fields = { ...baseCorrectParams, importedFrom: 'to' } + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) + }) + it('Should fail with a bad originally published at param', async function () { const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts index f8ec65752..b892289eb 100644 --- a/server/tests/shared/videos.ts +++ b/server/tests/shared/videos.ts @@ -25,6 +25,7 @@ async function completeVideoCheck ( description: string publishedAt?: string support: string + importedFrom?: string originallyPublishedAt?: string account: { name: string @@ -86,6 +87,12 @@ async function completeVideoCheck ( expect(video.publishedAt).to.equal(attributes.publishedAt) } + if (attributes.importedFrom) { + expect(video.importedFrom).to.equal(attributes.importedFrom) + } else { + expect(video.importedFrom).to.be.null + } + if (attributes.originallyPublishedAt) { expect(video.originallyPublishedAt).to.equal(attributes.originallyPublishedAt) } else {