aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-09-02 08:57:59 +0200
committerChocobozzz <me@florianbigard.com>2021-09-02 09:07:42 +0200
commit12d6b873cd4c5eb8c4fd298885e0c7fa6deb3756 (patch)
tree1abc21b305242e1d5bacefc99c2352b34396a5ab
parent6527eb0ccf823b5eac547c90066d3bd693094b2c (diff)
downloadPeerTube-12d6b873cd4c5eb8c4fd298885e0c7fa6deb3756.tar.gz
PeerTube-12d6b873cd4c5eb8c4fd298885e0c7fa6deb3756.tar.zst
PeerTube-12d6b873cd4c5eb8c4fd298885e0c7fa6deb3756.zip
Improve e2e workflow and add doc
-rw-r--r--README.md4
-rw-r--r--client/e2e/src/po/player.po.ts19
-rw-r--r--client/e2e/src/po/video-watch.po.ts9
-rw-r--r--client/e2e/src/urls.ts10
-rw-r--r--client/e2e/src/videos.e2e-spec.ts9
-rw-r--r--client/e2e/wdio.main.conf.ts4
-rw-r--r--package.json2
-rwxr-xr-xscripts/e2e/browserstack.sh (renamed from scripts/e2e/index.sh)7
-rwxr-xr-xscripts/test.sh7
-rw-r--r--support/doc/development/tests.md72
10 files changed, 106 insertions, 37 deletions
diff --git a/README.md b/README.md
index 61dc7c9f9..e484dbb9e 100644
--- a/README.md
+++ b/README.md
@@ -31,8 +31,8 @@ Be part of a network of multiple small federated, interoperable video hosting pr
31 31
32 <br /> 32 <br />
33 33
34 <a href="https://automate.browserstack.com/public-build/VHUxYy9zYnZqWnkxTTcyNEpPRVdzY2VzN1VhY3hBQUIrYTk2NGFtMnMvTT0tLWxuMk1vVnBzeDJ4cFpFY1JEK2xjSUE9PQ==--cf445693d1fc03efd86a3a5030d079a0de3ece7a"> 34 <a href="https://automate.browserstack.com/public-build/ZEZqamJQUXFQd1l3cFp3QmxLSVVwdjBGZjNGc3J2M09INFpka296em9VYz0tLUowWVdoemxkY1hBOU9aZzNlY1htZ3c9PQ==--68e0184ce76481d36559d681d9cddc68235ff536">
35 <img src="https://automate.browserstack.com/badge.svg?badge_key=VHUxYy9zYnZqWnkxTTcyNEpPRVdzY2VzN1VhY3hBQUIrYTk2NGFtMnMvTT0tLWxuMk1vVnBzeDJ4cFpFY1JEK2xjSUE9PQ==--cf445693d1fc03efd86a3a5030d079a0de3ece7a"/> 35 <img src="https://automate.browserstack.com/badge.svg?badge_key=ZEZqamJQUXFQd1l3cFp3QmxLSVVwdjBGZjNGc3J2M09INFpka296em9VYz0tLUowWVdoemxkY1hBOU9aZzNlY1htZ3c9PQ==--68e0184ce76481d36559d681d9cddc68235ff536"/>
36 </a> 36 </a>
37 37
38 <a href="https://weblate.framasoft.org/projects/peertube/angular/"> 38 <a href="https://weblate.framasoft.org/projects/peertube/angular/">
diff --git a/client/e2e/src/po/player.po.ts b/client/e2e/src/po/player.po.ts
index 9d6e21009..372e8ab20 100644
--- a/client/e2e/src/po/player.po.ts
+++ b/client/e2e/src/po/player.po.ts
@@ -5,13 +5,12 @@ export class PlayerPage {
5 getWatchVideoPlayerCurrentTime () { 5 getWatchVideoPlayerCurrentTime () {
6 const elem = $('video') 6 const elem = $('video')
7 7
8 if (isIOS()) { 8 const p = isIOS()
9 return elem.getAttribute('currentTime') 9 ? elem.getAttribute('currentTime')
10 .then(t => parseInt(t, 10)) 10 : elem.getProperty('currentTime')
11 .then(t => Math.round(t))
12 }
13 11
14 return elem.getProperty('currentTime') 12 return p.then(t => parseInt(t + '', 10))
13 .then(t => Math.ceil(t))
15 } 14 }
16 15
17 waitUntilPlaylistInfo (text: string, maxTime: number) { 16 waitUntilPlaylistInfo (text: string, maxTime: number) {
@@ -26,7 +25,7 @@ export class PlayerPage {
26 }) 25 })
27 } 26 }
28 27
29 async playAndPauseVideo (isAutoplay: boolean) { 28 async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
30 const videojsElem = () => $('div.video-js') 29 const videojsElem = () => $('div.video-js')
31 30
32 await videojsElem().waitForExist() 31 await videojsElem().waitForExist()
@@ -43,10 +42,8 @@ export class PlayerPage {
43 await browserSleep(2000) 42 await browserSleep(2000)
44 43
45 await browser.waitUntil(async () => { 44 await browser.waitUntil(async () => {
46 return !await $('.vjs-loading-spinner').isDisplayedInViewport() 45 return (await this.getWatchVideoPlayerCurrentTime()) >= 2
47 }, { timeout: 20 * 1000 }) 46 })
48
49 await browserSleep(4000)
50 47
51 await videojsElem().click() 48 await videojsElem().click()
52 } 49 }
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 01061d5d4..c07f4b25f 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -1,3 +1,4 @@
1import { FIXTURE_URLS } from '../urls'
1import { browserSleep, go } from '../utils' 2import { browserSleep, go } from '../utils'
2 3
3export class VideoWatchPage { 4export class VideoWatchPage {
@@ -50,15 +51,11 @@ export class VideoWatchPage {
50 } 51 }
51 52
52 goOnP2PMediaLoaderEmbed () { 53 goOnP2PMediaLoaderEmbed () {
53 return go( 54 return go(FIXTURE_URLS.HLS_EMBED)
54 'https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50'
55 )
56 } 55 }
57 56
58 goOnP2PMediaLoaderPlaylistEmbed () { 57 goOnP2PMediaLoaderPlaylistEmbed () {
59 return go( 58 return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
60 'https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a'
61 )
62 } 59 }
63 60
64 async clickOnVideo (videoName: string) { 61 async clickOnVideo (videoName: string) {
diff --git a/client/e2e/src/urls.ts b/client/e2e/src/urls.ts
new file mode 100644
index 000000000..664c65931
--- /dev/null
+++ b/client/e2e/src/urls.ts
@@ -0,0 +1,10 @@
1const FIXTURE_URLS = {
2 WEBTORRENT_VIDEO: 'https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e',
3
4 HLS_EMBED: 'https://peertube2.cpy.re/videos/embed/969bf103-7818-43b5-94a0-de159e13de50',
5 HLS_PLAYLIST_EMBED: 'https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a'
6}
7
8export {
9 FIXTURE_URLS
10}
diff --git a/client/e2e/src/videos.e2e-spec.ts b/client/e2e/src/videos.e2e-spec.ts
index 7f7c814e1..e09e8c675 100644
--- a/client/e2e/src/videos.e2e-spec.ts
+++ b/client/e2e/src/videos.e2e-spec.ts
@@ -4,6 +4,7 @@ import { PlayerPage } from './po/player.po'
4import { VideoUpdatePage } from './po/video-update.po' 4import { VideoUpdatePage } from './po/video-update.po'
5import { VideoUploadPage } from './po/video-upload.po' 5import { VideoUploadPage } from './po/video-upload.po'
6import { VideoWatchPage } from './po/video-watch.po' 6import { VideoWatchPage } from './po/video-watch.po'
7import { FIXTURE_URLS } from './urls'
7import { browserSleep, go, isIOS, isMobileDevice, isSafari } from './utils' 8import { browserSleep, go, isIOS, isMobileDevice, isSafari } from './utils'
8 9
9function isUploadUnsupported () { 10function isUploadUnsupported () {
@@ -91,7 +92,7 @@ describe('Videos workflow', () => {
91 let videoNameToExcept = videoName 92 let videoNameToExcept = videoName
92 93
93 if (isMobileDevice() || isSafari()) { 94 if (isMobileDevice() || isSafari()) {
94 await go('https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e') 95 await go(FIXTURE_URLS.WEBTORRENT_VIDEO)
95 videoNameToExcept = 'E2E tests' 96 videoNameToExcept = 'E2E tests'
96 } else { 97 } else {
97 await videoWatchPage.clickOnVideo(videoName) 98 await videoWatchPage.clickOnVideo(videoName)
@@ -103,21 +104,21 @@ describe('Videos workflow', () => {
103 it('Should play the video', async () => { 104 it('Should play the video', async () => {
104 videoWatchUrl = await browser.getUrl() 105 videoWatchUrl = await browser.getUrl()
105 106
106 await playerPage.playAndPauseVideo(true) 107 await playerPage.playAndPauseVideo(true, 2)
107 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 108 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
108 }) 109 })
109 110
110 it('Should watch the associated embed video', async () => { 111 it('Should watch the associated embed video', async () => {
111 await videoWatchPage.goOnAssociatedEmbed() 112 await videoWatchPage.goOnAssociatedEmbed()
112 113
113 await playerPage.playAndPauseVideo(false) 114 await playerPage.playAndPauseVideo(false, 2)
114 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 115 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
115 }) 116 })
116 117
117 it('Should watch the p2p media loader embed video', async () => { 118 it('Should watch the p2p media loader embed video', async () => {
118 await videoWatchPage.goOnP2PMediaLoaderEmbed() 119 await videoWatchPage.goOnP2PMediaLoaderEmbed()
119 120
120 await playerPage.playAndPauseVideo(false) 121 await playerPage.playAndPauseVideo(false, 2)
121 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2) 122 expect(await playerPage.getWatchVideoPlayerCurrentTime()).toBeGreaterThanOrEqual(2)
122 }) 123 })
123 124
diff --git a/client/e2e/wdio.main.conf.ts b/client/e2e/wdio.main.conf.ts
index e2ef99967..7f4c7f7ee 100644
--- a/client/e2e/wdio.main.conf.ts
+++ b/client/e2e/wdio.main.conf.ts
@@ -52,7 +52,7 @@ export const config = {
52 // 52 //
53 // If you only want to run your tests until a specific amount of tests have failed use 53 // If you only want to run your tests until a specific amount of tests have failed use
54 // bail (default is 0 - don't bail, run all tests). 54 // bail (default is 0 - don't bail, run all tests).
55 bail: 1, 55 bail: 0,
56 // 56 //
57 // Set a base URL in order to shorten url command calls. If your `url` parameter starts 57 // Set a base URL in order to shorten url command calls. If your `url` parameter starts
58 // with `/`, the base url gets prepended, not including the path portion of your baseUrl. 58 // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
@@ -79,7 +79,7 @@ export const config = {
79 framework: 'mocha', 79 framework: 'mocha',
80 // 80 //
81 // The number of times to retry the entire specfile when it fails as a whole 81 // The number of times to retry the entire specfile when it fails as a whole
82 // specFileRetries: 1, 82 specFileRetries: 2,
83 // 83 //
84 // Delay in seconds between the spec file retry attempts 84 // Delay in seconds between the spec file retry attempts
85 // specFileRetriesDelay: 0, 85 // specFileRetriesDelay: 0,
diff --git a/package.json b/package.json
index d6efb1db0..4f4f371d8 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,7 @@
22 }, 22 },
23 "typings": "*.d.ts", 23 "typings": "*.d.ts",
24 "scripts": { 24 "scripts": {
25 "e2e": "bash ./scripts/e2e/index.sh", 25 "e2e:browserstack": "bash ./scripts/e2e/browserstack.sh",
26 "e2e:local": "bash ./scripts/e2e/local.sh", 26 "e2e:local": "bash ./scripts/e2e/local.sh",
27 "setup:cli": "bash ./scripts/setup/cli.sh", 27 "setup:cli": "bash ./scripts/setup/cli.sh",
28 "build": "bash ./scripts/build/index.sh", 28 "build": "bash ./scripts/build/index.sh",
diff --git a/scripts/e2e/index.sh b/scripts/e2e/browserstack.sh
index 49d57f1df..69a12d14c 100755
--- a/scripts/e2e/index.sh
+++ b/scripts/e2e/browserstack.sh
@@ -4,11 +4,6 @@ set -eu
4 4
5npm run clean:server:test 5npm run clean:server:test
6 6
7(
8 cd client
9 npm run webpack -- --config webpack/webpack.video-embed.js --mode development
10)
11
12npm run concurrently -- -k -s first \ 7npm run concurrently -- -k -s first \
13 "cd client && npm run ng -- e2e --port 3333" \ 8 "cd client/e2e && ../node_modules/.bin/wdio run ./wdio.browserstack.conf.ts" \
14 "NODE_ENV=test NODE_APP_INSTANCE=1 NODE_CONFIG='{ \"log\": { \"level\": \"warn\" }, \"signup\": { \"enabled\": false } }' node dist/server" 9 "NODE_ENV=test NODE_APP_INSTANCE=1 NODE_CONFIG='{ \"log\": { \"level\": \"warn\" }, \"signup\": { \"enabled\": false } }' node dist/server"
diff --git a/scripts/test.sh b/scripts/test.sh
index 01b259fe2..2dc79c6ce 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -2,11 +2,6 @@
2 2
3set -eu 3set -eu
4 4
5npm run build:server
6npm run setup:cli
7
8npm run ci -- lint
9
10npm run ci -- client 5npm run ci -- client
11npm run ci -- cli-plugin 6npm run ci -- cli-plugin
12npm run ci -- api-1 7npm run ci -- api-1
@@ -14,3 +9,5 @@ npm run ci -- api-2
14npm run ci -- api-3 9npm run ci -- api-3
15npm run ci -- api-4 10npm run ci -- api-4
16npm run ci -- external-plugins 11npm run ci -- external-plugins
12
13npm run ci -- lint
diff --git a/support/doc/development/tests.md b/support/doc/development/tests.md
new file mode 100644
index 000000000..e311d3267
--- /dev/null
+++ b/support/doc/development/tests.md
@@ -0,0 +1,72 @@
1# Tests
2
3## Preparation
4
5Prepare PostgreSQL user so PeerTube can delete/create the test databases:
6
7```
8$ sudo -u postgres createuser you_username --createdb --superuser
9```
10
11Prepare databases:
12
13```
14$ npm run clean:server:test
15```
16
17Build PeerTube:
18
19```
20$ npm run build
21```
22
23## Server tests
24
25### Dependencies
26
27Run docker containers needed by some test files:
28
29```
30$ sudo docker run -p 9444:9000 chocobozzz/s3-ninja
31$ sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
32```
33
34### Test
35
36To run all test suites:
37
38```
39$ npm run test # See scripts/test.sh to run a particular suite
40```
41
42To run a particular test file:
43
44```
45TS_NODE_TRANSPILE_ONLY=true mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/videos/video-transcoder.ts
46```
47
48### Configuration
49
50Some env variables can be defined to disable/enable some tests:
51
52 * `DISABLE_HTTP_IMPORT_TESTS`: disable import tests (because of youtube that could rate limit your IP)
53 * `ENABLE_OBJECT_STORAGE_TESTS=true`: enable object storage tests (needs a docker container first)
54
55
56## Client E2E tests
57
58### Local tests
59
60To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`):
61
62```
63$ npm run e2e:local
64```
65
66### Browserstack tests
67
68To run tests on browser stack:
69
70```
71$ BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack
72```