+
+ it('Should fail with a bad schedule update (miss updateAt)', async function () {
+ const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
+ const attaches = baseCorrectAttaches
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should fail with a bad schedule update (wrong updateAt)', async function () {
+ const fields = {
+ ...baseCorrectParams,
+
+ scheduleUpdate: {
+ privacy: VideoPrivacy.PUBLIC,
+ updateAt: 'toto'
+ }
+ }
+ 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
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should fail without an input file', async function () {
+ const fields = baseCorrectParams
+ const attaches = {}
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should fail with an incorrect input file', async function () {
+ const fields = baseCorrectParams
+ let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') }
+
+ await checkUploadVideoParam(
+ server,
+ server.accessToken,
+ { ...fields, ...attaches },
+ HttpStatusCode.UNPROCESSABLE_ENTITY_422,
+ mode
+ )
+
+ attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') }
+ await checkUploadVideoParam(
+ server,
+ server.accessToken,
+ { ...fields, ...attaches },
+ HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415,
+ mode
+ )
+ })
+
+ it('Should fail with an incorrect thumbnail file', async function () {
+ const fields = baseCorrectParams
+ const attaches = {
+ thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
+ fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ }
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should fail with a big thumbnail file', async function () {
+ const fields = baseCorrectParams
+ const attaches = {
+ thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
+ fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ }
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should fail with an incorrect preview file', async function () {
+ const fields = baseCorrectParams
+ const attaches = {
+ previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'),
+ fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ }
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should fail with a big preview file', async function () {
+ const fields = baseCorrectParams
+ const attaches = {
+ previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'),
+ fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ }
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
+ })
+
+ it('Should report the appropriate error', async function () {
+ const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
+ const attaches = baseCorrectAttaches
+
+ const attributes = { ...fields, ...attaches }
+ const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode)
+
+ const error = body as unknown as PeerTubeProblemDocument
+
+ if (mode === 'legacy') {
+ expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy')
+ } else {
+ expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit')
+ }
+
+ expect(error.type).to.equal('about:blank')
+ expect(error.title).to.equal('Bad Request')
+
+ expect(error.detail).to.equal('Incorrect request parameters: language')
+ expect(error.error).to.equal('Incorrect request parameters: language')
+
+ expect(error.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
+ expect(error['invalid-params'].language).to.exist
+ })
+
+ it('Should succeed with the correct parameters', async function () {
+ this.timeout(10000)
+
+ const fields = baseCorrectParams
+
+ {
+ const attaches = baseCorrectAttaches
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
+ }
+
+ {
+ const attaches = {
+ ...baseCorrectAttaches,
+
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
+ }
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
+ }
+
+ {
+ const attaches = {
+ ...baseCorrectAttaches,
+
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
+ }
+
+ await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
+ }
+ })
+ }
+
+ describe('Resumable upload', function () {
+ runSuite('resumable')
+ })
+
+ describe('Legacy upload', function () {
+ runSuite('legacy')