X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fclient.ts;h=6c32c81db813851dc7184c5796c907dd454db66d;hb=40a8c0a4c4f654ba720ece6219816ad9c4fb9f5e;hp=caf6fb00cdcf71f53690f26c5d2adcb6b1fd3d9f;hpb=89d241a79c262b9775c233b73cff080043ebb5e6;p=github%2FChocobozzz%2FPeerTube.git
diff --git a/server/tests/client.ts b/server/tests/client.ts
index caf6fb00c..6c32c81db 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -3,15 +3,14 @@
import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
+import { Account, HTMLServerConfig, HttpStatusCode, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
+ createMultipleServers,
doubleFollow,
- flushAndRunMultipleServers,
makeGetRequest,
makeHTMLRequest,
- ServerInfo,
+ PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
waitJobs
@@ -25,11 +24,14 @@ 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 () {
- let servers: ServerInfo[] = []
+ let servers: PeerTubeServer[] = []
let account: Account
const videoName = 'my super name for server 1'
@@ -51,7 +53,7 @@ describe('Test a client controllers', function () {
before(async function () {
this.timeout(120000)
- servers = await flushAndRunMultipleServers(2)
+ servers = await createMultipleServers(2)
await setAccessTokensToServers(servers)
@@ -114,13 +116,13 @@ describe('Test a client controllers', function () {
url: servers[0].url,
path: basePath + id,
accept: 'text/html',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const port = servers[0].port
const expectedLink = '`
expect(res.text).to.contain(expectedLink)
@@ -135,13 +137,13 @@ describe('Test a client controllers', function () {
url: servers[0].url,
path: basePath + id,
accept: 'text/html',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const port = servers[0].port
const expectedLink = '`
expect(res.text).to.contain(expectedLink)
@@ -153,7 +155,7 @@ describe('Test a client controllers', function () {
describe('Open Graph', function () {
async function accountPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(``)
@@ -163,7 +165,7 @@ describe('Test a client controllers', function () {
}
async function channelPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(``)
@@ -173,23 +175,23 @@ describe('Test a client controllers', function () {
}
async function watchVideoPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(``)
expect(text).to.contain(``)
expect(text).to.contain('')
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
}
async function watchPlaylistPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(``)
expect(text).to.contain(``)
expect(text).to.contain('')
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
}
it('Should have valid Open Graph tags on the account page', async function () {
@@ -226,7 +228,7 @@ describe('Test a client controllers', function () {
describe('Not whitelisted', function () {
async function accountPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -236,7 +238,7 @@ describe('Test a client controllers', function () {
}
async function channelPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -246,7 +248,7 @@ describe('Test a client controllers', function () {
}
async function watchVideoPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -256,7 +258,7 @@ describe('Test a client controllers', function () {
}
async function watchPlaylistPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -307,7 +309,7 @@ describe('Test a client controllers', function () {
})
async function accountPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -315,7 +317,7 @@ describe('Test a client controllers', function () {
}
async function channelPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -323,7 +325,7 @@ describe('Test a client controllers', function () {
}
async function watchVideoPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -331,7 +333,7 @@ describe('Test a client controllers', function () {
}
async function watchPlaylistPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('')
@@ -446,6 +448,50 @@ describe('Test a client controllers', function () {
}
}
})
+
+ it('Should add noindex meta tag for remote accounts', async function () {
+ const handle = 'root@' + servers[0].host
+ const paths = [ '/accounts/', '/a/', '/@' ]
+
+ for (const path of paths) {
+ {
+ const { text } = await makeHTMLRequest(servers[1].url, path + handle)
+ expect(text).to.contain('')
+ }
+
+ {
+ const { text } = await makeHTMLRequest(servers[0].url, path + handle)
+ expect(text).to.not.contain('')
+ }
+ }
+ })
+
+ it('Should add noindex meta tag for remote accounts', async function () {
+ const handle = 'root_channel@' + servers[0].host
+ const paths = [ '/video-channels/', '/c/', '/@' ]
+
+ for (const path of paths) {
+ {
+ const { text } = await makeHTMLRequest(servers[1].url, path + handle)
+ expect(text).to.contain('')
+ }
+
+ {
+ const { text } = await makeHTMLRequest(servers[0].url, path + handle)
+ expect(text).to.not.contain('')
+ }
+ }
+ })
+
+ it('Should add noindex header for some paths', async function () {
+ const paths = [ '/about/peertube' ]
+
+ for (const path of paths) {
+ const { headers } = await makeHTMLRequest(servers[0].url, path)
+
+ expect(headers['x-robots-tag']).to.equal('noindex')
+ }
+ })
})
describe('Embed HTML', function () {