]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/e2e/src/utils/hooks.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / e2e / src / utils / hooks.ts
... / ...
CommitLineData
1import { ChildProcessWithoutNullStreams } from 'child_process'
2import { basename } from 'path'
3import { setValue } from '@wdio/shared-store-service'
4import { createScreenshotsDirectory } from './files'
5import { runCommand, runServer } from './server'
6
7let appInstance: number
8let app: ChildProcessWithoutNullStreams
9
10let emailPort: number
11
12async function beforeLocalSuite (suite: any) {
13 const config = buildConfig(suite.file)
14
15 await runCommand('npm run clean:server:test -- ' + appInstance)
16 app = runServer(appInstance, config)
17}
18
19function afterLocalSuite () {
20 app.kill()
21 app = undefined
22}
23
24async function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) {
25 createScreenshotsDirectory()
26
27 appInstance = capabilities['browserName'] === 'chrome'
28 ? 1
29 : 2
30
31 emailPort = 1025 + appInstance
32
33 config.baseUrl = 'http://localhost:900' + appInstance
34
35 await setValue(config.baseUrl + '-emailPort', emailPort)
36}
37
38async function onBrowserStackPrepare () {
39 const appInstance = 1
40
41 await runCommand('npm run clean:server:test -- ' + appInstance)
42 app = runServer(appInstance)
43}
44
45function onBrowserStackComplete () {
46 app.kill()
47 app = undefined
48}
49
50export {
51 beforeLocalSession,
52 afterLocalSuite,
53 beforeLocalSuite,
54 onBrowserStackPrepare,
55 onBrowserStackComplete
56}
57
58// ---------------------------------------------------------------------------
59
60function buildConfig (suiteFile: string = undefined) {
61 const filename = basename(suiteFile)
62
63 if (filename === 'custom-server-defaults.e2e-spec.ts') {
64 return {
65 defaults: {
66 publish: {
67 download_enabled: false,
68 comments_enabled: false,
69 privacy: 4,
70 licence: 4
71 },
72 p2p: {
73 webapp: {
74 enabled: false
75 },
76 embed: {
77 enabled: false
78 }
79 }
80 }
81 }
82 }
83
84 if (filename === 'signup.e2e-spec.ts') {
85 return {
86 signup: {
87 limit: -1
88 },
89 smtp: {
90 hostname: '127.0.0.1',
91 port: emailPort
92 }
93 }
94 }
95
96 return {}
97}