From 6c5065a011b099618681a37bd77eaa7bd3db752e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 09:43:59 +0200 Subject: Introduce server commands --- server/tests/api/search/search-index.ts | 24 ++++++----------- server/tests/api/search/search-videos.ts | 46 +++++++++++++++----------------- 2 files changed, 30 insertions(+), 40 deletions(-) (limited to 'server/tests/api/search') diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index e4c5f5796..306f84c3a 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -2,16 +2,8 @@ import 'mocha' import * as chai from 'chai' -import { - cleanupTests, - flushAndRunServer, - immutableAssign, - SearchCommand, - ServerInfo, - setAccessTokensToServers, - uploadVideo -} from '@shared/extra-utils' -import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' +import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' +import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' const expect = chai.expect @@ -174,32 +166,32 @@ describe('Test videos search', function () { } { - const search = immutableAssign(baseSearch, { startDate: '2018-10-01T10:54:46.396Z' }) + const search = { ...baseSearch, startDate: '2018-10-01T10:54:46.396Z' } await check(search, false) } { - const search = immutableAssign(baseSearch, { tagsAllOf: [ 'toto', 'framasoft' ] }) + const search = { ...baseSearch, tagsAllOf: [ 'toto', 'framasoft' ] } await check(search, false) } { - const search = immutableAssign(baseSearch, { durationMin: 2000 }) + const search = { ...baseSearch, durationMin: 2000 } await check(search, false) } { - const search = immutableAssign(baseSearch, { nsfw: 'true' }) + const search = { ...baseSearch, nsfw: 'true' as BooleanBothQuery } await check(search, false) } { - const search = immutableAssign(baseSearch, { nsfw: 'false' }) + const search = { ...baseSearch, nsfw: 'false' as BooleanBothQuery } await check(search, true) } { - const search = immutableAssign(baseSearch, { nsfw: 'both' }) + const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery } await check(search, true) } }) diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 513538917..66f5f3182 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -5,7 +5,6 @@ import * as chai from 'chai' import { cleanupTests, flushAndRunServer, - immutableAssign, SearchCommand, ServerInfo, setAccessTokensToServers, @@ -44,11 +43,11 @@ describe('Test videos search', function () { } await uploadVideo(server.url, server.accessToken, attributes1) - const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) + const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' } await uploadVideo(server.url, server.accessToken, attributes2) { - const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined }) + const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } const res = await uploadVideo(server.url, server.accessToken, attributes3) const videoId = res.body.video.id videoUUID = res.body.video.uuid @@ -68,26 +67,23 @@ describe('Test videos search', function () { }) } - const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) + const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } await uploadVideo(server.url, server.accessToken, attributes4) await wait(1000) startDate = new Date().toISOString() - const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) + const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined } await uploadVideo(server.url, server.accessToken, attributes5) - const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }) + const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } await uploadVideo(server.url, server.accessToken, attributes6) - const attributes7 = immutableAssign(attributes1, { - name: attributes1.name + ' - 7', - originallyPublishedAt: '2019-02-12T09:58:08.286Z' - }) + const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } await uploadVideo(server.url, server.accessToken, attributes7) - const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) + const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } await uploadVideo(server.url, server.accessToken, attributes8) } @@ -101,7 +97,7 @@ describe('Test videos search', function () { } await uploadVideo(server.url, server.accessToken, attributes) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes, { name: attributes.name + ' duplicate' })) + await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' }) } { @@ -122,10 +118,10 @@ describe('Test videos search', function () { category: 1 } await uploadVideo(server.url, server.accessToken, attributes1) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) + await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] })) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] })) + await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] }) + await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] }) } { @@ -134,7 +130,7 @@ describe('Test videos search', function () { category: 1 } await uploadVideo(server.url, server.accessToken, attributes1) - await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) + await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) } command = server.searchCommand @@ -414,7 +410,7 @@ describe('Test videos search', function () { } { - const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(1) @@ -422,7 +418,7 @@ describe('Test videos search', function () { } { - const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(1) @@ -430,34 +426,36 @@ describe('Test videos search', function () { } { - const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(0) } { - const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) + const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(0) } { - const query = immutableAssign(baseQuery, { + const query = { + ...baseQuery, originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' - }) + } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(0) } { - const query = immutableAssign(baseQuery, { + const query = { + ...baseQuery, originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' - }) + } const body = await command.advancedVideoSearch({ search: query }) expect(body.total).to.equal(1) -- cgit v1.2.3