X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fclient.ts;h=a8a697f99bebbf91521d65e6731f8701f314ed84;hb=073deef8862f462de5f159a57877ef415ebe4c69;hp=4f0d052c8abef28f1f5386571bb9de36f77efff8;hpb=352819ef921e45381b3fbb17072926103b320e73;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/client.ts b/server/tests/client.ts index 4f0d052c8..a8a697f99 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts @@ -3,7 +3,15 @@ import 'mocha' import * as chai from 'chai' import { omit } from 'lodash' -import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' +import { + Account, + HTMLServerConfig, + HttpStatusCode, + ServerConfig, + VideoPlaylistCreateResult, + VideoPlaylistPrivacy, + VideoPrivacy +} from '@shared/models' import { cleanupTests, createMultipleServers, @@ -14,7 +22,7 @@ import { setAccessTokensToServers, setDefaultVideoChannel, waitJobs -} from '../../shared/extra-utils' +} from '../../shared/server-commands' const expect = chai.expect @@ -24,7 +32,10 @@ function checkIndexTags (html: string, title: string, description: string, css: expect(html).to.contain('') const htmlConfig: HTMLServerConfig = omit(config, 'signup') - expect(html).to.contain(``) + const configObjectString = JSON.stringify(htmlConfig) + const configEscapedString = JSON.stringify(configObjectString) + + expect(html).to.contain(``) } describe('Test a client controllers', function () { @@ -45,6 +56,10 @@ describe('Test a client controllers', function () { const watchPlaylistBasePaths = [ '/videos/watch/playlist/', '/w/p/' ] let videoIds: (string | number)[] = [] + let privateVideoId: string + let internalVideoId: string + let unlistedVideoId: string + let playlistIds: (string | number)[] = [] before(async function () { @@ -63,7 +78,7 @@ describe('Test a client controllers', function () { attributes: { description: channelDescription } }) - // Video + // Public video { const attributes = { name: videoName, description: videoDescription } @@ -77,6 +92,12 @@ describe('Test a client controllers', function () { videoIds = [ video.id, video.uuid, video.shortUUID ] } + { + ({ uuid: privateVideoId } = await servers[0].videos.quickUpload({ name: 'private', privacy: VideoPrivacy.PRIVATE })); + ({ uuid: unlistedVideoId } = await servers[0].videos.quickUpload({ name: 'unlisted', privacy: VideoPrivacy.UNLISTED })); + ({ uuid: internalVideoId } = await servers[0].videos.quickUpload({ name: 'internal', privacy: VideoPrivacy.INTERNAL })) + } + // Playlist { @@ -463,7 +484,7 @@ describe('Test a client controllers', function () { } }) - it('Should add noindex meta tag for remote accounts', async function () { + it('Should add noindex meta tag for remote channels', async function () { const handle = 'root_channel@' + servers[0].host const paths = [ '/video-channels/', '/c/', '/@' ] @@ -479,6 +500,36 @@ describe('Test a client controllers', function () { } } }) + + it('Should not display internal/private video', async function () { + for (const basePath of watchVideoBasePaths) { + for (const id of [ privateVideoId, internalVideoId ]) { + const res = await makeGetRequest({ + url: servers[0].url, + path: basePath + id, + accept: 'text/html', + expectedStatus: HttpStatusCode.NOT_FOUND_404 + }) + + expect(res.text).to.not.contain('internal') + expect(res.text).to.not.contain('private') + } + } + }) + + it('Should add noindex meta tag for unlisted video', async function () { + for (const basePath of watchVideoBasePaths) { + const res = await makeGetRequest({ + url: servers[0].url, + path: basePath + unlistedVideoId, + accept: 'text/html', + expectedStatus: HttpStatusCode.OK_200 + }) + + expect(res.text).to.contain('unlisted') + expect(res.text).to.contain('') + } + }) }) describe('Embed HTML', function () {