mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Use an object to represent a server
This commit is contained in:
@@ -6,8 +6,8 @@ import {
|
||||
AbusesCommand,
|
||||
cleanupTests,
|
||||
doubleFollow,
|
||||
flushAndRunMultipleServers,
|
||||
ServerInfo,
|
||||
createMultipleServers,
|
||||
PeerTubeServer,
|
||||
setAccessTokensToServers,
|
||||
waitJobs
|
||||
} from '@shared/extra-utils'
|
||||
@@ -16,7 +16,7 @@ import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, Use
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Test abuses', function () {
|
||||
let servers: ServerInfo[] = []
|
||||
let servers: PeerTubeServer[] = []
|
||||
let abuseServer1: AdminAbuse
|
||||
let abuseServer2: AdminAbuse
|
||||
let commands: AbusesCommand[]
|
||||
@@ -25,7 +25,7 @@ describe('Test abuses', function () {
|
||||
this.timeout(50000)
|
||||
|
||||
// Run servers
|
||||
servers = await flushAndRunMultipleServers(2)
|
||||
servers = await createMultipleServers(2)
|
||||
|
||||
// Get the access tokens
|
||||
await setAccessTokensToServers(servers)
|
||||
@@ -389,7 +389,7 @@ describe('Test abuses', function () {
|
||||
|
||||
describe('Comment abuses', function () {
|
||||
|
||||
async function getComment (server: ServerInfo, videoIdArg: number | string) {
|
||||
async function getComment (server: PeerTubeServer, videoIdArg: number | string) {
|
||||
const videoId = typeof videoIdArg === 'string'
|
||||
? await server.videos.getId({ uuid: videoIdArg })
|
||||
: videoIdArg
|
||||
@@ -591,7 +591,7 @@ describe('Test abuses', function () {
|
||||
|
||||
describe('Account abuses', function () {
|
||||
|
||||
function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
|
||||
function getAccountFromServer (server: PeerTubeServer, targetName: string, targetServer: PeerTubeServer) {
|
||||
return server.accounts.get({ accountName: targetName + '@' + targetServer.host })
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
|
||||
import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
|
||||
import { UserNotificationType } from '@shared/models'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) {
|
||||
async function checkNotifications (server: PeerTubeServer, token: string, expected: UserNotificationType[]) {
|
||||
const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true })
|
||||
expect(data).to.have.lengthOf(expected.length)
|
||||
|
||||
@@ -17,7 +17,7 @@ async function checkNotifications (server: ServerInfo, token: string, expected:
|
||||
}
|
||||
|
||||
describe('Test blocklist', function () {
|
||||
let servers: ServerInfo[]
|
||||
let servers: PeerTubeServer[]
|
||||
let videoUUID: string
|
||||
|
||||
let userToken1: string
|
||||
@@ -62,7 +62,7 @@ describe('Test blocklist', function () {
|
||||
before(async function () {
|
||||
this.timeout(60000)
|
||||
|
||||
servers = await flushAndRunMultipleServers(2)
|
||||
servers = await createMultipleServers(2)
|
||||
await setAccessTokensToServers(servers)
|
||||
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
cleanupTests,
|
||||
CommentsCommand,
|
||||
doubleFollow,
|
||||
flushAndRunMultipleServers,
|
||||
ServerInfo,
|
||||
createMultipleServers,
|
||||
PeerTubeServer,
|
||||
setAccessTokensToServers,
|
||||
waitJobs
|
||||
} from '@shared/extra-utils'
|
||||
@@ -16,7 +16,7 @@ import { UserNotificationType } from '@shared/models'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
async function checkAllVideos (server: ServerInfo, token: string) {
|
||||
async function checkAllVideos (server: PeerTubeServer, token: string) {
|
||||
{
|
||||
const { data } = await server.videos.listWithToken({ token })
|
||||
expect(data).to.have.lengthOf(5)
|
||||
@@ -28,7 +28,7 @@ async function checkAllVideos (server: ServerInfo, token: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) {
|
||||
async function checkAllComments (server: PeerTubeServer, token: string, videoUUID: string) {
|
||||
const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
|
||||
|
||||
const threads = data.filter(t => t.isDeleted === false)
|
||||
@@ -41,8 +41,8 @@ async function checkAllComments (server: ServerInfo, token: string, videoUUID: s
|
||||
}
|
||||
|
||||
async function checkCommentNotification (
|
||||
mainServer: ServerInfo,
|
||||
comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
|
||||
mainServer: PeerTubeServer,
|
||||
comment: { server: PeerTubeServer, token: string, videoUUID: string, text: string },
|
||||
check: 'presence' | 'absence'
|
||||
) {
|
||||
const command = comment.server.comments
|
||||
@@ -63,7 +63,7 @@ async function checkCommentNotification (
|
||||
}
|
||||
|
||||
describe('Test blocklist', function () {
|
||||
let servers: ServerInfo[]
|
||||
let servers: PeerTubeServer[]
|
||||
let videoUUID1: string
|
||||
let videoUUID2: string
|
||||
let videoUUID3: string
|
||||
@@ -77,7 +77,7 @@ describe('Test blocklist', function () {
|
||||
before(async function () {
|
||||
this.timeout(120000)
|
||||
|
||||
servers = await flushAndRunMultipleServers(3)
|
||||
servers = await createMultipleServers(3)
|
||||
await setAccessTokensToServers(servers)
|
||||
|
||||
command = servers[0].blocklist
|
||||
|
||||
@@ -7,11 +7,10 @@ import {
|
||||
BlacklistCommand,
|
||||
cleanupTests,
|
||||
doubleFollow,
|
||||
flushAndRunMultipleServers,
|
||||
createMultipleServers,
|
||||
ImportsCommand,
|
||||
killallServers,
|
||||
reRunServer,
|
||||
ServerInfo,
|
||||
PeerTubeServer,
|
||||
setAccessTokensToServers,
|
||||
waitJobs
|
||||
} from '@shared/extra-utils'
|
||||
@@ -20,11 +19,11 @@ import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@sh
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Test video blacklist', function () {
|
||||
let servers: ServerInfo[] = []
|
||||
let servers: PeerTubeServer[] = []
|
||||
let videoId: number
|
||||
let command: BlacklistCommand
|
||||
|
||||
async function blacklistVideosOnServer (server: ServerInfo) {
|
||||
async function blacklistVideosOnServer (server: PeerTubeServer) {
|
||||
const { data } = await server.videos.list()
|
||||
|
||||
for (const video of data) {
|
||||
@@ -36,7 +35,7 @@ describe('Test video blacklist', function () {
|
||||
this.timeout(50000)
|
||||
|
||||
// Run servers
|
||||
servers = await flushAndRunMultipleServers(2)
|
||||
servers = await createMultipleServers(2)
|
||||
|
||||
// Get the access tokens
|
||||
await setAccessTokensToServers(servers)
|
||||
@@ -344,7 +343,7 @@ describe('Test video blacklist', function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
await reRunServer(servers[0], config)
|
||||
await servers[0].run(config)
|
||||
|
||||
{
|
||||
const user = { username: 'user_without_flag', password: 'password' }
|
||||
|
||||
Reference in New Issue
Block a user