diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts
index ea64e4040..0adf6b667 100644
--- a/server/tests/api/server/services.ts
+++ b/server/tests/api/server/services.ts
@@ -6,7 +6,6 @@ import { Video, VideoPlaylistPrivacy } from '@shared/models'
import {
addVideoInPlaylist,
createVideoPlaylist,
- getOEmbed,
getVideosList,
ServerInfo,
setAccessTokensToServers,
@@ -70,7 +69,7 @@ describe('Test services', function () {
for (const basePath of [ '/videos/watch/', '/w/' ]) {
const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid
- const res = await getOEmbed(server.url, oembedUrl)
+ const res = await server.servicesCommand.getOEmbed({ oembedUrl })
const expectedHtml = ''
@@ -91,7 +90,7 @@ describe('Test services', function () {
for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) {
const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID
- const res = await getOEmbed(server.url, oembedUrl)
+ const res = await server.servicesCommand.getOEmbed({ oembedUrl })
const expectedHtml = ''
@@ -114,7 +113,7 @@ describe('Test services', function () {
const maxHeight = 50
const maxWidth = 50
- const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
+ const res = await server.servicesCommand.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
const expectedHtml = ''
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
-}