From d897210c2db1ca2acc1e7b28a13127647ab2222c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 10:23:21 +0200 Subject: Introduce services command --- shared/extra-utils/server/servers.ts | 4 +++- shared/extra-utils/videos/index.ts | 2 +- shared/extra-utils/videos/services-command.ts | 28 +++++++++++++++++++++++++++ shared/extra-utils/videos/services.ts | 24 ----------------------- 4 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 shared/extra-utils/videos/services-command.ts delete mode 100644 shared/extra-utils/videos/services.ts (limited to 'shared/extra-utils') diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index eca0689aa..cb2a8814b 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -18,7 +18,7 @@ import { makeGetRequest } from '../requests/requests' import { SearchCommand } from '../search' import { SocketIOCommand } from '../socket' import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users' -import { LiveCommand } from '../videos' +import { LiveCommand, ServicesCommand } from '../videos' import { ConfigCommand } from './config-command' import { ContactFormCommand } from './contact-form-command' import { DebugCommand } from './debug-command' @@ -101,6 +101,7 @@ interface ServerInfo { blocklistCommand?: BlocklistCommand subscriptionsCommand?: SubscriptionsCommand liveCommand?: LiveCommand + servicesCommand?: ServicesCommand } function parallelTests () { @@ -327,6 +328,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] server.blocklistCommand = new BlocklistCommand(server) server.subscriptionsCommand = new SubscriptionsCommand(server) server.liveCommand = new LiveCommand(server) + server.servicesCommand = new ServicesCommand(server) res(server) }) diff --git a/shared/extra-utils/videos/index.ts b/shared/extra-utils/videos/index.ts index c9c884285..fe5dc6655 100644 --- a/shared/extra-utils/videos/index.ts +++ b/shared/extra-utils/videos/index.ts @@ -1,6 +1,6 @@ export * from './live-command' export * from './live' -export * from './services' +export * from './services-command' export * from './video-blacklist' export * from './video-captions' export * from './video-change-ownership' diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts new file mode 100644 index 000000000..3b618ef66 --- /dev/null +++ b/shared/extra-utils/videos/services-command.ts @@ -0,0 +1,28 @@ +import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' +import { AbstractCommand, OverrideCommandOptions } from '../shared' + +export class ServicesCommand extends AbstractCommand { + + getOEmbed (options: OverrideCommandOptions & { + oembedUrl: string + format?: string + maxHeight?: number + maxWidth?: number + }) { + const path = '/services/oembed' + const query = { + url: options.oembedUrl, + format: options.format, + maxheight: options.maxHeight, + maxwidth: options.maxWidth + } + + return this.getRequest({ + ...options, + + path, + query, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + } +} diff --git a/shared/extra-utils/videos/services.ts b/shared/extra-utils/videos/services.ts deleted file mode 100644 index e13a788bd..000000000 --- a/shared/extra-utils/videos/services.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as request from 'supertest' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' - -function getOEmbed (url: string, oembedUrl: string, format?: string, maxHeight?: number, maxWidth?: number) { - const path = '/services/oembed' - const query = { - url: oembedUrl, - format, - maxheight: maxHeight, - maxwidth: maxWidth - } - - return request(url) - .get(path) - .query(query) - .set('Accept', 'application/json') - .expect(HttpStatusCode.OK_200) -} - -// --------------------------------------------------------------------------- - -export { - getOEmbed -} -- cgit v1.2.3