]>
Commit | Line | Data |
---|---|---|
3cf68b86 C |
1 | import { ChildProcessWithoutNullStreams } from 'child_process' |
2 | import { basename } from 'path' | |
5bdfa604 | 3 | import { setValue } from '@wdio/shared-store-service' |
1ec4835d C |
4 | import { createScreenshotsDirectory } from './files' |
5 | import { runCommand, runServer } from './server' | |
3cf68b86 | 6 | |
5bdfa604 | 7 | let appInstance: number |
3cf68b86 C |
8 | let app: ChildProcessWithoutNullStreams |
9 | ||
5bdfa604 C |
10 | let emailPort: number |
11 | ||
3cf68b86 C |
12 | async 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 | ||
19 | function afterLocalSuite () { | |
20 | app.kill() | |
21 | app = undefined | |
22 | } | |
23 | ||
5bdfa604 | 24 | async function beforeLocalSession (config: { baseUrl: string }, capabilities: { browserName: string }) { |
e65ef81c | 25 | createScreenshotsDirectory() |
1ec4835d | 26 | |
5bdfa604 C |
27 | appInstance = capabilities['browserName'] === 'chrome' |
28 | ? 1 | |
29 | : 2 | |
30 | ||
31 | emailPort = 1025 + appInstance | |
32 | ||
3cf68b86 | 33 | config.baseUrl = 'http://localhost:900' + appInstance |
5bdfa604 | 34 | |
5b94394a | 35 | await setValue(config.baseUrl + '-emailPort', emailPort) |
3cf68b86 C |
36 | } |
37 | ||
38 | async function onBrowserStackPrepare () { | |
5bdfa604 | 39 | const appInstance = 1 |
3cf68b86 C |
40 | |
41 | await runCommand('npm run clean:server:test -- ' + appInstance) | |
42 | app = runServer(appInstance) | |
43 | } | |
44 | ||
45 | function onBrowserStackComplete () { | |
46 | app.kill() | |
47 | app = undefined | |
48 | } | |
49 | ||
50 | export { | |
51 | beforeLocalSession, | |
52 | afterLocalSuite, | |
53 | beforeLocalSuite, | |
54 | onBrowserStackPrepare, | |
55 | onBrowserStackComplete | |
56 | } | |
57 | ||
58 | // --------------------------------------------------------------------------- | |
59 | ||
60 | function 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 | |
a9bfa85d C |
71 | }, |
72 | p2p: { | |
b65de1be C |
73 | webapp: { |
74 | enabled: false | |
75 | }, | |
76 | embed: { | |
77 | enabled: false | |
78 | } | |
3cf68b86 C |
79 | } |
80 | } | |
81 | } | |
82 | } | |
83 | ||
814e9e07 C |
84 | if (filename === 'signup.e2e-spec.ts') { |
85 | return { | |
86 | signup: { | |
5bdfa604 C |
87 | limit: -1 |
88 | }, | |
89 | smtp: { | |
90 | hostname: '127.0.0.1', | |
91 | port: emailPort | |
814e9e07 C |
92 | } |
93 | } | |
94 | } | |
95 | ||
3cf68b86 C |
96 | return {} |
97 | } |