]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/utils/hooks.ts
Support reinjecting token in private m3u8 playlist
[github/Chocobozzz/PeerTube.git] / client / e2e / src / utils / hooks.ts
CommitLineData
3cf68b86
C
1import { ChildProcessWithoutNullStreams } from 'child_process'
2import { basename } from 'path'
3import { runCommand, runServer } from './server'
4
5let appInstance: string
6let app: ChildProcessWithoutNullStreams
7
8async function beforeLocalSuite (suite: any) {
9 const config = buildConfig(suite.file)
10
11 await runCommand('npm run clean:server:test -- ' + appInstance)
12 app = runServer(appInstance, config)
13}
14
15function afterLocalSuite () {
16 app.kill()
17 app = undefined
18}
19
20function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) {
21 appInstance = capabilities['browserName'] === 'chrome' ? '1' : '2'
22 config.baseUrl = 'http://localhost:900' + appInstance
23}
24
25async function onBrowserStackPrepare () {
26 const appInstance = '1'
27
28 await runCommand('npm run clean:server:test -- ' + appInstance)
29 app = runServer(appInstance)
30}
31
32function onBrowserStackComplete () {
33 app.kill()
34 app = undefined
35}
36
37export {
38 beforeLocalSession,
39 afterLocalSuite,
40 beforeLocalSuite,
41 onBrowserStackPrepare,
42 onBrowserStackComplete
43}
44
45// ---------------------------------------------------------------------------
46
47function buildConfig (suiteFile: string = undefined) {
48 const filename = basename(suiteFile)
49
50 if (filename === 'custom-server-defaults.e2e-spec.ts') {
51 return {
52 defaults: {
53 publish: {
54 download_enabled: false,
55 comments_enabled: false,
56 privacy: 4,
57 licence: 4
a9bfa85d
C
58 },
59 p2p: {
b65de1be
C
60 webapp: {
61 enabled: false
62 },
63 embed: {
64 enabled: false
65 }
3cf68b86
C
66 }
67 }
68 }
69 }
70
814e9e07
C
71 if (filename === 'signup.e2e-spec.ts') {
72 return {
73 signup: {
74 enabled: true
75 }
76 }
77 }
78
3cf68b86
C
79 return {}
80}