From a220b84b0e29c7ce1b32166aec07870696a28ef9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 May 2022 09:10:20 +0200 Subject: Fix avatars in notifications --- server/tests/shared/notifications.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'server/tests/shared') diff --git a/server/tests/shared/notifications.ts b/server/tests/shared/notifications.ts index a62410880..09bc8da03 100644 --- a/server/tests/shared/notifications.ts +++ b/server/tests/shared/notifications.ts @@ -185,7 +185,7 @@ async function checkUserRegistered (options: CheckerBaseParams & { expect(notification).to.not.be.undefined expect(notification.type).to.equal(notificationType) - checkActor(notification.account) + checkActor(notification.account, { withAvatar: false }) expect(notification.account.name).to.equal(username) } else { expect(notification).to.satisfy(n => n.type !== notificationType || n.account.name !== username) @@ -253,7 +253,7 @@ async function checkNewInstanceFollower (options: CheckerBaseParams & { expect(notification).to.not.be.undefined expect(notification.type).to.equal(notificationType) - checkActor(notification.actorFollow.follower) + checkActor(notification.actorFollow.follower, { withAvatar: false }) expect(notification.actorFollow.follower.name).to.equal('peertube') expect(notification.actorFollow.follower.host).to.equal(followerHost) @@ -288,7 +288,8 @@ async function checkAutoInstanceFollowing (options: CheckerBaseParams & { expect(notification.type).to.equal(notificationType) const following = notification.actorFollow.following - checkActor(following) + + checkActor(following, { withAvatar: false }) expect(following.name).to.equal('peertube') expect(following.host).to.equal(followingHost) @@ -701,6 +702,9 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an const userAccessToken = await servers[0].login.getAccessToken(user) await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) + await servers[0].users.updateMyAvatar({ token: userAccessToken, fixture: 'avatar.png' }) + await servers[0].channels.updateImage({ channelName: 'user_1_channel', token: userAccessToken, fixture: 'avatar.png', type: 'avatar' }) + await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) if (serversCount > 1) { @@ -832,10 +836,18 @@ function checkVideo (video: any, videoName?: string, shortUUID?: string) { expect(video.id).to.be.a('number') } -function checkActor (actor: any) { +function checkActor (actor: any, options: { withAvatar?: boolean } = {}) { + const { withAvatar = true } = options + expect(actor.displayName).to.be.a('string') expect(actor.displayName).to.not.be.empty expect(actor.host).to.not.be.undefined + + if (withAvatar) { + expect(actor.avatars).to.be.an('array') + expect(actor.avatars).to.have.lengthOf(2) + expect(actor.avatars[0].path).to.exist.and.not.empty + } } function checkComment (comment: any, commentId: number, threadId: number) { -- cgit v1.2.3 From 5333788c08ab6152303829d4624774b5d788ff40 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 May 2022 14:54:16 +0200 Subject: Fix saving permanent live replay on quick restream --- server/tests/shared/live.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'server/tests/shared') diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 6ee4899b0..4bd4786fc 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts @@ -3,15 +3,35 @@ import { expect } from 'chai' import { pathExists, readdir } from 'fs-extra' import { join } from 'path' +import { LiveVideo } from '@shared/models' import { PeerTubeServer } from '@shared/server-commands' async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { + let live: LiveVideo + + try { + live = await server.live.get({ videoId: videoUUID }) + } catch {} + const basePath = server.servers.buildDirectory('streaming-playlists') const hlsPath = join(basePath, 'hls', videoUUID) if (savedResolutions.length === 0) { - const result = await pathExists(hlsPath) - expect(result).to.be.false + + if (live?.permanentLive) { + expect(await pathExists(hlsPath)).to.be.true + + const hlsFiles = await readdir(hlsPath) + expect(hlsFiles).to.have.lengthOf(1) // Only replays directory + + const replayDir = join(hlsPath, 'replay') + expect(await pathExists(replayDir)).to.be.true + + const replayFiles = await readdir(join(hlsPath, 'replay')) + expect(replayFiles).to.have.lengthOf(0) + } else { + expect(await pathExists(hlsPath)).to.be.false + } return } -- cgit v1.2.3