diff options
author | Andréas Livet <andreas.livet@gmail.com> | 2017-12-19 10:45:49 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:45:49 +0100 |
commit | 7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd (patch) | |
tree | 56116e7e9f8467b78ed6dfc81827288915d31c8c /server/tests | |
parent | 228077efd73485a2832bb6211c9fa923158c2112 (diff) | |
download | PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.gz PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.tar.zst PeerTube-7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd.zip |
Enh #106 : Add an autoPlayVideo user attribute (#159)
Warning : I was not able to run the tests on my machine. It uses a different approach to handle databse connexion and didn't find where to configure it...
- create a migration file to add a boolean column in user table
- add autoPlayVideo attribute everywhere it is needed (both on client and server side)
- add tests
- add a way to configure this attribute in account-settings
- use the attribute in video-watch component to actually autoplay or not the video
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/users.ts | 9 | ||||
-rw-r--r-- | server/tests/api/users.ts | 9 | ||||
-rw-r--r-- | server/tests/utils/users.ts | 4 |
3 files changed, 21 insertions, 1 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 1e3533bf3..72488e5c4 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -350,6 +350,14 @@ describe('Test users API validators', function () { | |||
350 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | 350 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) |
351 | }) | 351 | }) |
352 | 352 | ||
353 | it('Should fail with an invalid autoPlayVideo attribute', async function () { | ||
354 | const fields = { | ||
355 | autoPlayVideo: -1 | ||
356 | } | ||
357 | |||
358 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | ||
359 | }) | ||
360 | |||
353 | it('Should fail with an non authenticated user', async function () { | 361 | it('Should fail with an non authenticated user', async function () { |
354 | const fields = { | 362 | const fields = { |
355 | password: 'my super password' | 363 | password: 'my super password' |
@@ -362,6 +370,7 @@ describe('Test users API validators', function () { | |||
362 | const fields = { | 370 | const fields = { |
363 | password: 'my super password', | 371 | password: 'my super password', |
364 | displayNSFW: true, | 372 | displayNSFW: true, |
373 | autoPlayVideo: false, | ||
365 | email: 'super_email@example.com' | 374 | email: 'super_email@example.com' |
366 | } | 375 | } |
367 | 376 | ||
diff --git a/server/tests/api/users.ts b/server/tests/api/users.ts index b3163b1e1..67e4cc8c6 100644 --- a/server/tests/api/users.ts +++ b/server/tests/api/users.ts | |||
@@ -415,6 +415,15 @@ describe('Test users', function () { | |||
415 | .a('number') | 415 | .a('number') |
416 | }) | 416 | }) |
417 | 417 | ||
418 | it('Should be able to change the autoPlayVideo attribute', async function () { | ||
419 | await updateMyUser(server.url, accessTokenUser, undefined, undefined, undefined, false) | ||
420 | |||
421 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
422 | const user = res.body | ||
423 | |||
424 | expect(user.autoPlayVideo).to.be.false | ||
425 | }) | ||
426 | |||
418 | it('Should be able to change the email display attribute', async function () { | 427 | it('Should be able to change the email display attribute', async function () { |
419 | await updateMyUser(server.url, accessTokenUser, undefined, undefined, 'updated@example.com') | 428 | await updateMyUser(server.url, accessTokenUser, undefined, undefined, 'updated@example.com') |
420 | 429 | ||
diff --git a/server/tests/utils/users.ts b/server/tests/utils/users.ts index ce04b9d96..a37d84ab4 100644 --- a/server/tests/utils/users.ts +++ b/server/tests/utils/users.ts | |||
@@ -111,12 +111,14 @@ function removeUser (url: string, userId: number, accessToken: string, expectedS | |||
111 | .expect(expectedStatus) | 111 | .expect(expectedStatus) |
112 | } | 112 | } |
113 | 113 | ||
114 | function updateMyUser (url: string, accessToken: string, newPassword: string, displayNSFW?: boolean, email?: string) { | 114 | function updateMyUser (url: string, accessToken: string, newPassword: string, displayNSFW?: boolean, |
115 | email?: string, autoPlayVideo?: boolean) { | ||
115 | const path = '/api/v1/users/me' | 116 | const path = '/api/v1/users/me' |
116 | 117 | ||
117 | const toSend = {} | 118 | const toSend = {} |
118 | if (newPassword !== undefined && newPassword !== null) toSend['password'] = newPassword | 119 | if (newPassword !== undefined && newPassword !== null) toSend['password'] = newPassword |
119 | if (displayNSFW !== undefined && displayNSFW !== null) toSend['displayNSFW'] = displayNSFW | 120 | if (displayNSFW !== undefined && displayNSFW !== null) toSend['displayNSFW'] = displayNSFW |
121 | if (autoPlayVideo !== undefined && autoPlayVideo !== null) toSend['autoPlayVideo'] = autoPlayVideo | ||
120 | if (email !== undefined && email !== null) toSend['email'] = email | 122 | if (email !== undefined && email !== null) toSend['email'] = email |
121 | 123 | ||
122 | return request(url) | 124 | return request(url) |