aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/e2e/protractor.conf.js36
-rw-r--r--client/e2e/src/po/login.po.ts4
-rw-r--r--client/e2e/src/po/video-watch.po.ts12
-rw-r--r--client/e2e/src/videos.e2e-spec.ts6
-rw-r--r--client/package.json4
-rw-r--r--client/src/app/core/auth/auth.service.ts20
-rw-r--r--client/src/app/shared/misc/utils.ts10
-rw-r--r--client/src/assets/player/peertube-player.ts16
-rw-r--r--client/src/standalone/videos/embed.ts3
-rw-r--r--client/yarn.lock8
-rw-r--r--config/test.yaml1
11 files changed, 94 insertions, 26 deletions
diff --git a/client/e2e/protractor.conf.js b/client/e2e/protractor.conf.js
index 82daa435e..7b5f8de43 100644
--- a/client/e2e/protractor.conf.js
+++ b/client/e2e/protractor.conf.js
@@ -10,14 +10,42 @@ exports.config = {
10 ], 10 ],
11 11
12 seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub', 12 seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub',
13 capabilities: { 13 commonCapabilities: {
14 'browserstack.user': process.env.BROWSERSTACK_USER, 14 'browserstack.user': process.env.BROWSERSTACK_USER,
15 'browserstack.key': process.env.BROWSERSTACK_KEY, 15 'browserstack.key': process.env.BROWSERSTACK_KEY,
16 'browserName': 'chrome',
17 'browserstack.local': true, 16 'browserstack.local': true,
18 'project': 'PeerTube' 17 'project': 'PeerTube'
19 }, 18 },
20 19
20 multiCapabilities: [
21 {
22 browserName: 'Chrome',
23 version: '66'
24 },
25 {
26 browserName: 'Chrome',
27 version: '66',
28 os: 'android',
29
30 },
31 {
32 browserName: 'Safari',
33 version: '11.1'
34 },
35 {
36 browserName: 'Firefox',
37 version: '52' // ESR
38 },
39 {
40 browserName: 'Firefox',
41 version: '60'
42 },
43 {
44 browserName: 'Edge',
45 version: '17'
46 }
47 ],
48
21 maxSessions: 1, 49 maxSessions: 1,
22 baseUrl: 'http://localhost:4200/', 50 baseUrl: 'http://localhost:4200/',
23 framework: 'jasmine', 51 framework: 'jasmine',
@@ -34,3 +62,7 @@ exports.config = {
34 jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}})) 62 jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}))
35 } 63 }
36} 64}
65
66exports.config.multiCapabilities.forEach(function (caps) {
67 for (var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i]
68})
diff --git a/client/e2e/src/po/login.po.ts b/client/e2e/src/po/login.po.ts
index ada52cb24..5a36fd611 100644
--- a/client/e2e/src/po/login.po.ts
+++ b/client/e2e/src/po/login.po.ts
@@ -4,8 +4,8 @@ export class LoginPage {
4 async loginAsRootUser () { 4 async loginAsRootUser () {
5 await browser.get('/login') 5 await browser.get('/login')
6 6
7 element(by.css('input#username')).sendKeys('root') 7 await element(by.css('input#username')).sendKeys('root')
8 element(by.css('input#password')).sendKeys('test1') 8 await element(by.css('input#password')).sendKeys('test1')
9 9
10 await element(by.css('form input[type=submit]')).click() 10 await element(by.css('form input[type=submit]')).click()
11 11
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 266c9850c..b5df1cbc5 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -24,15 +24,19 @@ export class VideoWatchPage {
24 .then(seconds => parseInt(seconds, 10)) 24 .then(seconds => parseInt(seconds, 10))
25 } 25 }
26 26
27 async pauseVideo () { 27 async pauseVideo (pauseAfterMs: number) {
28 const el = element(by.css('video')) 28 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
29
30 const el = element(by.css('div.video-js'))
29 await browser.wait(browser.ExpectedConditions.elementToBeClickable(el)) 31 await browser.wait(browser.ExpectedConditions.elementToBeClickable(el))
30 32
33 await browser.sleep(pauseAfterMs)
34
31 return el.click() 35 return el.click()
32 } 36 }
33 37
34 async clickOnFirstVideoOfList () { 38 async clickOnVideo (videoName: string) {
35 const video = element(by.css('.videos .video-miniature:first-child .video-thumbnail')) 39 const video = element(by.css('.videos .video-miniature .video-thumbnail[title="' + videoName + '"]'))
36 40
37 await video.click() 41 await video.click()
38 42
diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts
index 4205fd7a4..82cea72b1 100644
--- a/client/e2e/src/videos.e2e-spec.ts
+++ b/client/e2e/src/videos.e2e-spec.ts
@@ -34,15 +34,13 @@ describe('Videos workflow', () => {
34 }) 34 })
35 35
36 it('Should go on video watch page', async () => { 36 it('Should go on video watch page', async () => {
37 await videoWatchPage.clickOnFirstVideoOfList() 37 await videoWatchPage.clickOnVideo(videoName)
38 38
39 return videoWatchPage.waitWatchVideoName(videoName) 39 return videoWatchPage.waitWatchVideoName(videoName)
40 }) 40 })
41 41
42 it('Should play the video', async () => { 42 it('Should play the video', async () => {
43 await browser.sleep(4000) 43 await videoWatchPage.pauseVideo(2500)
44
45 await videoWatchPage.pauseVideo()
46 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 44 expect(videoWatchPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
47 }) 45 })
48}) 46})
diff --git a/client/package.json b/client/package.json
index 393a4b134..7a69d1a43 100644
--- a/client/package.json
+++ b/client/package.json
@@ -23,7 +23,8 @@
23 }, 23 },
24 "license": "GPLv3", 24 "license": "GPLv3",
25 "resolutions": { 25 "resolutions": {
26 "videojs-dock/video.js": "^6" 26 "videojs-dock/video.js": "^6",
27 "webtorrent/create-torrent/junk": "^1"
27 }, 28 },
28 "devDependencies": { 29 "devDependencies": {
29 "@angular-devkit/build-angular": "~0.6.1", 30 "@angular-devkit/build-angular": "~0.6.1",
@@ -102,6 +103,7 @@
102 "webpack-bundle-analyzer": "^2.9.1", 103 "webpack-bundle-analyzer": "^2.9.1",
103 "webpack-cli": "^2.0.14", 104 "webpack-cli": "^2.0.14",
104 "webtorrent": "^0.98.0", 105 "webtorrent": "^0.98.0",
106 "whatwg-fetch": "^2.0.4",
105 "zone.js": "~0.8.5" 107 "zone.js": "~0.8.5"
106 }, 108 },
107 "dependencies": { 109 "dependencies": {
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 4b388d7be..4213da20c 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -11,6 +11,7 @@ import { environment } from '../../../environments/environment'
11import { RestExtractor } from '../../shared/rest' 11import { RestExtractor } from '../../shared/rest'
12import { AuthStatus } from './auth-status.model' 12import { AuthStatus } from './auth-status.model'
13import { AuthUser } from './auth-user.model' 13import { AuthUser } from './auth-user.model'
14import { objectToUrlEncoded } from '@app/shared/misc/utils'
14 15
15interface UserLoginWithUsername extends UserLogin { 16interface UserLoginWithUsername extends UserLogin {
16 access_token: string 17 access_token: string
@@ -113,17 +114,18 @@ export class AuthService {
113 114
114 login (username: string, password: string) { 115 login (username: string, password: string) {
115 // Form url encoded 116 // Form url encoded
116 const body = new URLSearchParams() 117 const body = {
117 body.set('client_id', this.clientId) 118 client_id: this.clientId,
118 body.set('client_secret', this.clientSecret) 119 client_secret: this.clientSecret,
119 body.set('response_type', 'code') 120 response_type: 'code',
120 body.set('grant_type', 'password') 121 grant_type: 'password',
121 body.set('scope', 'upload') 122 scope: 'upload',
122 body.set('username', username) 123 username,
123 body.set('password', password) 124 password
125 }
124 126
125 const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') 127 const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
126 return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body.toString(), { headers }) 128 return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, objectToUrlEncoded(body), { headers })
127 .pipe( 129 .pipe(
128 map(res => Object.assign(res, { username })), 130 map(res => Object.assign(res, { username })),
129 mergeMap(res => this.mergeUserInformation(res)), 131 mergeMap(res => this.mergeUserInformation(res)),
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index b9aa223cf..79c93c1b3 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -55,6 +55,15 @@ function immutableAssign <A, B> (target: A, source: B) {
55 return Object.assign({}, target, source) 55 return Object.assign({}, target, source)
56} 56}
57 57
58function objectToUrlEncoded (obj: any) {
59 const str: string[] = []
60 for (const key of Object.keys(obj)) {
61 str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]))
62 }
63
64 return str.join('&')
65}
66
58// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34 67// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
59function objectToFormData (obj: any, form?: FormData, namespace?: string) { 68function objectToFormData (obj: any, form?: FormData, namespace?: string) {
60 let fd = form || new FormData() 69 let fd = form || new FormData()
@@ -100,6 +109,7 @@ function isInMobileView () {
100} 109}
101 110
102export { 111export {
112 objectToUrlEncoded,
103 getParameterByName, 113 getParameterByName,
104 populateAsyncUserVideoChannels, 114 populateAsyncUserVideoChannels,
105 getAbsoluteAPIUrl, 115 getAbsoluteAPIUrl,
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts
index f419d58fc..2e77a973f 100644
--- a/client/src/assets/player/peertube-player.ts
+++ b/client/src/assets/player/peertube-player.ts
@@ -1,5 +1,21 @@
1import { VideoFile } from '../../../../shared/models/videos' 1import { VideoFile } from '../../../../shared/models/videos'
2 2
3import 'core-js/es6/symbol';
4import 'core-js/es6/object';
5import 'core-js/es6/function';
6import 'core-js/es6/parse-int';
7import 'core-js/es6/parse-float';
8import 'core-js/es6/number';
9import 'core-js/es6/math';
10import 'core-js/es6/string';
11import 'core-js/es6/date';
12import 'core-js/es6/array';
13import 'core-js/es6/regexp';
14import 'core-js/es6/map';
15import 'core-js/es6/weak-map';
16import 'core-js/es6/set';
17import 'core-js/es7/object';
18
3import 'videojs-hotkeys' 19import 'videojs-hotkeys'
4import 'videojs-dock' 20import 'videojs-dock'
5import './peertube-link-button' 21import './peertube-link-button'
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index aa418d2d4..c88219242 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -1,5 +1,8 @@
1import './embed.scss' 1import './embed.scss'
2 2
3// For google bot that uses Chrome 41 and does not understand fetch
4import 'whatwg-fetch'
5
3import * as videojs from 'video.js' 6import * as videojs from 'video.js'
4 7
5import { VideoDetails } from '../../../../shared' 8import { VideoDetails } from '../../../../shared'
diff --git a/client/yarn.lock b/client/yarn.lock
index 3be3bde58..6d905e9b3 100644
--- a/client/yarn.lock
+++ b/client/yarn.lock
@@ -5214,9 +5214,9 @@ jszip@^3.1.3:
5214 pako "~1.0.2" 5214 pako "~1.0.2"
5215 readable-stream "~2.0.6" 5215 readable-stream "~2.0.6"
5216 5216
5217junk@^2.1.0: 5217junk@^1, junk@^2.1.0:
5218 version "2.1.0" 5218 version "1.0.3"
5219 resolved "https://registry.yarnpkg.com/junk/-/junk-2.1.0.tgz#f431b4b7f072dc500a5f10ce7f4ec71930e70134" 5219 resolved "https://registry.yarnpkg.com/junk/-/junk-1.0.3.tgz#87be63488649cbdca6f53ab39bec9ccd2347f592"
5220 5220
5221k-bucket@^4.0.0: 5221k-bucket@^4.0.0:
5222 version "4.0.0" 5222 version "4.0.0"
@@ -10206,7 +10206,7 @@ webtorrent@^0.98.0:
10206 xtend "^4.0.1" 10206 xtend "^4.0.1"
10207 zero-fill "^2.2.3" 10207 zero-fill "^2.2.3"
10208 10208
10209whatwg-fetch@>=0.10.0: 10209whatwg-fetch@>=0.10.0, whatwg-fetch@^2.0.4:
10210 version "2.0.4" 10210 version "2.0.4"
10211 resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" 10211 resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
10212 10212
diff --git a/config/test.yaml b/config/test.yaml
index 020987920..a4ee9a7b2 100644
--- a/config/test.yaml
+++ b/config/test.yaml
@@ -1,4 +1,5 @@
1listen: 1listen:
2 listen: '0.0.0.0'
2 port: 9000 3 port: 9000
3 4
4webserver: 5webserver: