aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/e2e/src')
-rw-r--r--client/e2e/src/po/video-watch.po.ts29
-rw-r--r--client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts37
-rw-r--r--client/e2e/src/suites-local/videos-list.e2e-spec.ts24
-rw-r--r--client/e2e/src/utils/hooks.ts64
-rw-r--r--client/e2e/src/utils/index.ts2
-rw-r--r--client/e2e/src/utils/server.ts63
6 files changed, 216 insertions, 3 deletions
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 41425f4d7..1406c971a 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -21,6 +21,24 @@ export class VideoWatchPage {
21 return this.getVideoNameElement().then(e => e.getText()) 21 return this.getVideoNameElement().then(e => e.getText())
22 } 22 }
23 23
24 getPrivacy () {
25 return $('.attribute-privacy .attribute-value').getText()
26 }
27
28 getLicence () {
29 return $('.attribute-licence .attribute-value').getText()
30 }
31
32 async isDownloadEnabled () {
33 await this.clickOnMoreDropdownIcon()
34
35 return $('.dropdown-item .icon-download').isExisting()
36 }
37
38 areCommentsEnabled () {
39 return $('my-video-comment-add').isExisting()
40 }
41
24 async goOnAssociatedEmbed () { 42 async goOnAssociatedEmbed () {
25 let url = await browser.getUrl() 43 let url = await browser.getUrl()
26 url = url.replace('/w/', '/videos/embed/') 44 url = url.replace('/w/', '/videos/embed/')
@@ -38,10 +56,8 @@ export class VideoWatchPage {
38 } 56 }
39 57
40 async clickOnUpdate () { 58 async clickOnUpdate () {
41 const dropdown = $('my-video-actions-dropdown .action-button') 59 await this.clickOnMoreDropdownIcon()
42 await dropdown.click()
43 60
44 await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
45 const items = await $$('.dropdown-menu.show .dropdown-item') 61 const items = await $$('.dropdown-menu.show .dropdown-item')
46 62
47 for (const item of items) { 63 for (const item of items) {
@@ -86,6 +102,13 @@ export class VideoWatchPage {
86 }, { timeout: maxTime }) 102 }, { timeout: maxTime })
87 } 103 }
88 104
105 async clickOnMoreDropdownIcon () {
106 const dropdown = $('my-video-actions-dropdown .action-button')
107 await dropdown.click()
108
109 await $('.dropdown-menu.show .dropdown-item').waitForDisplayed()
110 }
111
89 private async getVideoNameElement () { 112 private async getVideoNameElement () {
90 // We have 2 video info name block, pick the first that is not empty 113 // We have 2 video info name block, pick the first that is not empty
91 const elem = async () => { 114 const elem = async () => {
diff --git a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
new file mode 100644
index 000000000..c2c8edcc9
--- /dev/null
+++ b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
@@ -0,0 +1,37 @@
1import { LoginPage } from '../po/login.po'
2import { VideoUploadPage } from '../po/video-upload.po'
3import { VideoWatchPage } from '../po/video-watch.po'
4import { isMobileDevice, isSafari, waitServerUp } from '../utils'
5
6describe('Custom server defaults', () => {
7 let videoUploadPage: VideoUploadPage
8 let loginPage: LoginPage
9 let videoWatchPage: VideoWatchPage
10
11 before(async () => {
12 await waitServerUp()
13 })
14
15 beforeEach(async () => {
16 loginPage = new LoginPage()
17 videoUploadPage = new VideoUploadPage()
18 videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
19
20 await browser.maximizeWindow()
21 })
22
23 it('Should upload a video with custom default values', async function () {
24 await loginPage.loginAsRootUser()
25 await videoUploadPage.navigateTo()
26 await videoUploadPage.uploadVideo()
27 await videoUploadPage.validSecondUploadStep('video')
28
29 await videoWatchPage.waitWatchVideoName('video')
30
31 expect(await videoWatchPage.getPrivacy()).toBe('Internal')
32 expect(await videoWatchPage.getLicence()).toBe('Attribution - Non Commercial')
33 expect(await videoWatchPage.isDownloadEnabled()).toBeFalsy()
34 expect(await videoWatchPage.areCommentsEnabled()).toBeFalsy()
35 })
36
37})
diff --git a/client/e2e/src/suites-local/videos-list.e2e-spec.ts b/client/e2e/src/suites-local/videos-list.e2e-spec.ts
index 1e0a88859..bca6018b9 100644
--- a/client/e2e/src/suites-local/videos-list.e2e-spec.ts
+++ b/client/e2e/src/suites-local/videos-list.e2e-spec.ts
@@ -4,6 +4,7 @@ import { MyAccountPage } from '../po/my-account'
4import { VideoListPage } from '../po/video-list.po' 4import { VideoListPage } from '../po/video-list.po'
5import { VideoSearchPage } from '../po/video-search.po' 5import { VideoSearchPage } from '../po/video-search.po'
6import { VideoUploadPage } from '../po/video-upload.po' 6import { VideoUploadPage } from '../po/video-upload.po'
7import { VideoWatchPage } from '../po/video-watch.po'
7import { NSFWPolicy } from '../types/common' 8import { NSFWPolicy } from '../types/common'
8import { isMobileDevice, isSafari, waitServerUp } from '../utils' 9import { isMobileDevice, isSafari, waitServerUp } from '../utils'
9 10
@@ -14,6 +15,7 @@ describe('Videos list', () => {
14 let loginPage: LoginPage 15 let loginPage: LoginPage
15 let myAccountPage: MyAccountPage 16 let myAccountPage: MyAccountPage
16 let videoSearchPage: VideoSearchPage 17 let videoSearchPage: VideoSearchPage
18 let videoWatchPage: VideoWatchPage
17 19
18 const seed = Math.random() 20 const seed = Math.random()
19 const nsfwVideo = seed + ' - nsfw' 21 const nsfwVideo = seed + ' - nsfw'
@@ -108,6 +110,7 @@ describe('Videos list', () => {
108 videoUploadPage = new VideoUploadPage() 110 videoUploadPage = new VideoUploadPage()
109 myAccountPage = new MyAccountPage() 111 myAccountPage = new MyAccountPage()
110 videoSearchPage = new VideoSearchPage() 112 videoSearchPage = new VideoSearchPage()
113 videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
111 114
112 await browser.maximizeWindow() 115 await browser.maximizeWindow()
113 }) 116 })
@@ -191,5 +194,26 @@ describe('Videos list', () => {
191 await checkCommonVideoListPages('display') 194 await checkCommonVideoListPages('display')
192 await checkSearchPage('display') 195 await checkSearchPage('display')
193 }) 196 })
197
198 after(async () => {
199 await loginPage.logout()
200 })
201 })
202
203 describe('Default upload values', function () {
204
205 it('Should have default video values', async function () {
206 await loginPage.loginAsRootUser()
207 await videoUploadPage.navigateTo()
208 await videoUploadPage.uploadVideo()
209 await videoUploadPage.validSecondUploadStep('video')
210
211 await videoWatchPage.waitWatchVideoName('video')
212
213 expect(await videoWatchPage.getPrivacy()).toBe('Public')
214 expect(await videoWatchPage.getLicence()).toBe('Unknown')
215 expect(await videoWatchPage.isDownloadEnabled()).toBeTruthy()
216 expect(await videoWatchPage.areCommentsEnabled()).toBeTruthy()
217 })
194 }) 218 })
195}) 219})
diff --git a/client/e2e/src/utils/hooks.ts b/client/e2e/src/utils/hooks.ts
new file mode 100644
index 000000000..e42c6a5d8
--- /dev/null
+++ b/client/e2e/src/utils/hooks.ts
@@ -0,0 +1,64 @@
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
58 }
59 }
60 }
61 }
62
63 return {}
64}
diff --git a/client/e2e/src/utils/index.ts b/client/e2e/src/utils/index.ts
index 5da1ad517..354352ee2 100644
--- a/client/e2e/src/utils/index.ts
+++ b/client/e2e/src/utils/index.ts
@@ -1,3 +1,5 @@
1export * from './common' 1export * from './common'
2export * from './elements' 2export * from './elements'
3export * from './hooks'
4export * from './server'
3export * from './urls' 5export * from './urls'
diff --git a/client/e2e/src/utils/server.ts b/client/e2e/src/utils/server.ts
new file mode 100644
index 000000000..7089a5c9c
--- /dev/null
+++ b/client/e2e/src/utils/server.ts
@@ -0,0 +1,63 @@
1import { exec, spawn } from 'child_process'
2import { join, resolve } from 'path'
3
4function runServer (appInstance: string, config: any = {}) {
5 const env = Object.create(process.env)
6 env['NODE_ENV'] = 'test'
7 env['NODE_APP_INSTANCE'] = appInstance
8
9 env['NODE_CONFIG'] = JSON.stringify({
10 rates_limit: {
11 api: {
12 max: 5000
13 },
14 login: {
15 max: 5000
16 }
17 },
18 log: {
19 level: 'warn'
20 },
21 signup: {
22 enabled: false
23 },
24 transcoding: {
25 enabled: false
26 },
27
28 ...config
29 })
30
31 const forkOptions = {
32 env,
33 cwd: getRootCWD(),
34 detached: false
35 }
36
37 const p = spawn('node', [ join('dist', 'server.js') ], forkOptions)
38 p.stderr.on('data', data => console.error(data.toString()))
39 p.stdout.on('data', data => console.error(data.toString()))
40
41 return p
42}
43
44function runCommand (command: string) {
45 return new Promise<void>((res, rej) => {
46 const p = exec(command, { cwd: getRootCWD() })
47
48 p.stderr.on('data', data => console.error(data.toString()))
49 p.on('error', err => rej(err))
50 p.on('exit', () => res())
51 })
52}
53
54export {
55 runServer,
56 runCommand
57}
58
59// ---------------------------------------------------------------------------
60
61function getRootCWD () {
62 return resolve('../..')
63}