X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fsingle-server.ts;h=a0e4a156c584cc495ad29855c6a0ab8feee0207b;hb=a37e9e74ff07b057370d1ed6c0b391a02be8a6d2;hp=da0b2011e2d815df812fb64619b5efa984415042;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index da0b2011e..a0e4a156c 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -6,8 +6,8 @@ import { checkVideoFilesWereRemoved, cleanupTests, completeVideoCheck, - flushAndRunServer, - ServerInfo, + createSingleServer, + PeerTubeServer, setAccessTokensToServers, testImage, wait @@ -19,7 +19,7 @@ const expect = chai.expect describe('Test a single server', function () { function runSuite (mode: 'legacy' | 'resumable') { - let server: ServerInfo = null + let server: PeerTubeServer = null let videoId: number | string let videoId2: string let videoUUID = '' @@ -94,41 +94,41 @@ describe('Test a single server', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) }) it('Should list video categories', async function () { - const categories = await server.videosCommand.getCategories() + const categories = await server.videos.getCategories() expect(Object.keys(categories)).to.have.length.above(10) expect(categories[11]).to.equal('News & Politics') }) it('Should list video licences', async function () { - const licences = await server.videosCommand.getLicences() + const licences = await server.videos.getLicences() expect(Object.keys(licences)).to.have.length.above(5) expect(licences[3]).to.equal('Attribution - No Derivatives') }) it('Should list video languages', async function () { - const languages = await server.videosCommand.getLanguages() + const languages = await server.videos.getLanguages() expect(Object.keys(languages)).to.have.length.above(5) expect(languages['ru']).to.equal('Russian') }) it('Should list video privacies', async function () { - const privacies = await server.videosCommand.getPrivacies() + const privacies = await server.videos.getPrivacies() expect(Object.keys(privacies)).to.have.length.at.least(3) expect(privacies[3]).to.equal('Private') }) it('Should not have videos', async function () { - const { data, total } = await server.videosCommand.list() + const { data, total } = await server.videos.list() expect(total).to.equal(0) expect(data).to.be.an('array') @@ -145,7 +145,7 @@ describe('Test a single server', function () { licence: 6, tags: [ 'tag1', 'tag2', 'tag3' ] } - const video = await server.videosCommand.upload({ attributes, mode }) + const video = await server.videos.upload({ attributes, mode }) expect(video).to.not.be.undefined expect(video.id).to.equal(1) expect(video.uuid).to.have.length.above(5) @@ -157,7 +157,7 @@ describe('Test a single server', function () { it('Should get and seed the uploaded video', async function () { this.timeout(5000) - const { data, total } = await server.videosCommand.list() + const { data, total } = await server.videos.list() expect(total).to.equal(1) expect(data).to.be.an('array') @@ -170,42 +170,43 @@ describe('Test a single server', function () { it('Should get the video by UUID', async function () { this.timeout(5000) - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) await completeVideoCheck(server, video, getCheckAttributes()) }) it('Should have the views updated', async function () { this.timeout(20000) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) await wait(1500) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) await wait(1500) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) // Wait the repeatable job await wait(8000) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.views).to.equal(3) }) it('Should remove the video', async function () { - await server.videosCommand.remove({ id: videoId }) + const video = await server.videos.get({ id: videoId }) + await server.videos.remove({ id: videoId }) - await checkVideoFilesWereRemoved(videoUUID, server) + await checkVideoFilesWereRemoved({ video, server }) }) it('Should not have videos', async function () { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(0) expect(data).to.be.an('array') @@ -232,12 +233,12 @@ describe('Test a single server', function () { fixture: video } - await server.videosCommand.upload({ attributes, mode }) + await server.videos.upload({ attributes, mode }) } }) it('Should have the correct durations', async function () { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(6) expect(data).to.be.an('array') @@ -255,7 +256,7 @@ describe('Test a single server', function () { }) it('Should have the correct thumbnails', async function () { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() // For the next test videosListBase = data @@ -267,7 +268,7 @@ describe('Test a single server', function () { }) it('Should list only the two first videos', async function () { - const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: 'name' }) + const { total, data } = await server.videos.list({ start: 0, count: 2, sort: 'name' }) expect(total).to.equal(6) expect(data.length).to.equal(2) @@ -276,7 +277,7 @@ describe('Test a single server', function () { }) it('Should list only the next three videos', async function () { - const { total, data } = await server.videosCommand.list({ start: 2, count: 3, sort: 'name' }) + const { total, data } = await server.videos.list({ start: 2, count: 3, sort: 'name' }) expect(total).to.equal(6) expect(data.length).to.equal(3) @@ -286,7 +287,7 @@ describe('Test a single server', function () { }) it('Should list the last video', async function () { - const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name' }) + const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name' }) expect(total).to.equal(6) expect(data.length).to.equal(1) @@ -294,7 +295,7 @@ describe('Test a single server', function () { }) it('Should not have the total field', async function () { - const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name', skipCount: true }) + const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name', skipCount: true }) expect(total).to.not.exist expect(data.length).to.equal(1) @@ -302,7 +303,7 @@ describe('Test a single server', function () { }) it('Should list and sort by name in descending order', async function () { - const { total, data } = await server.videosCommand.list({ sort: '-name' }) + const { total, data } = await server.videos.list({ sort: '-name' }) expect(total).to.equal(6) expect(data.length).to.equal(6) @@ -318,21 +319,21 @@ describe('Test a single server', function () { }) it('Should list and sort by trending in descending order', async function () { - const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-trending' }) + const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-trending' }) expect(total).to.equal(6) expect(data.length).to.equal(2) }) it('Should list and sort by hotness in descending order', async function () { - const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-hot' }) + const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-hot' }) expect(total).to.equal(6) expect(data.length).to.equal(2) }) it('Should list and sort by best in descending order', async function () { - const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-best' }) + const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-best' }) expect(total).to.equal(6) expect(data.length).to.equal(2) @@ -350,26 +351,13 @@ describe('Test a single server', function () { downloadEnabled: false, tags: [ 'tagup1', 'tagup2' ] } - await server.videosCommand.update({ id: videoId, attributes }) - }) - - it('Should filter by tags and category', async function () { - { - const { data, total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) - expect(total).to.equal(1) - expect(data[0].name).to.equal('my super video updated') - } - - { - const { total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) - expect(total).to.equal(0) - } + await server.videos.update({ id: videoId, attributes }) }) it('Should have the video updated', async function () { this.timeout(60000) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) await completeVideoCheck(server, video, updateCheckAttributes()) }) @@ -378,9 +366,9 @@ describe('Test a single server', function () { const attributes = { tags: [ 'supertag', 'tag1', 'tag2' ] } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes)) }) @@ -389,27 +377,27 @@ describe('Test a single server', function () { const attributes = { description: 'hello everybody' } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) await completeVideoCheck(server, video, expectedAttributes) }) it('Should like a video', async function () { - await server.videosCommand.rate({ id: videoId, rating: 'like' }) + await server.videos.rate({ id: videoId, rating: 'like' }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.likes).to.equal(1) expect(video.dislikes).to.equal(0) }) it('Should dislike the same video', async function () { - await server.videosCommand.rate({ id: videoId, rating: 'dislike' }) + await server.videos.rate({ id: videoId, rating: 'dislike' }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.likes).to.equal(0) expect(video.dislikes).to.equal(1) @@ -419,9 +407,9 @@ describe('Test a single server', function () { { const now = new Date() const attributes = { originallyPublishedAt: now.toISOString() } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) - const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) + const { data } = await server.videos.list({ sort: '-originallyPublishedAt' }) const names = data.map(v => v.name) expect(names[0]).to.equal('my super video updated') @@ -435,9 +423,9 @@ describe('Test a single server', function () { { const now = new Date() const attributes = { originallyPublishedAt: now.toISOString() } - await server.videosCommand.update({ id: videoId2, attributes }) + await server.videos.update({ id: videoId2, attributes }) - const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) + const { data } = await server.videos.list({ sort: '-originallyPublishedAt' }) const names = data.map(v => v.name) expect(names[0]).to.equal('video_short1.webm name')