From 7efe153b0bc23e596d5019b9fb3e3e32b6cfeccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9as=20Livet?= Date: Tue, 19 Dec 2017 10:45:49 +0100 Subject: 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 --- server/tests/api/check-params/users.ts | 9 +++++++++ server/tests/api/users.ts | 9 +++++++++ server/tests/utils/users.ts | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'server/tests') 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 () { await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) }) + it('Should fail with an invalid autoPlayVideo attribute', async function () { + const fields = { + autoPlayVideo: -1 + } + + await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) + }) + it('Should fail with an non authenticated user', async function () { const fields = { password: 'my super password' @@ -362,6 +370,7 @@ describe('Test users API validators', function () { const fields = { password: 'my super password', displayNSFW: true, + autoPlayVideo: false, email: 'super_email@example.com' } 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 () { .a('number') }) + it('Should be able to change the autoPlayVideo attribute', async function () { + await updateMyUser(server.url, accessTokenUser, undefined, undefined, undefined, false) + + const res = await getMyUserInformation(server.url, accessTokenUser) + const user = res.body + + expect(user.autoPlayVideo).to.be.false + }) + it('Should be able to change the email display attribute', async function () { await updateMyUser(server.url, accessTokenUser, undefined, undefined, 'updated@example.com') 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 .expect(expectedStatus) } -function updateMyUser (url: string, accessToken: string, newPassword: string, displayNSFW?: boolean, email?: string) { +function updateMyUser (url: string, accessToken: string, newPassword: string, displayNSFW?: boolean, + email?: string, autoPlayVideo?: boolean) { const path = '/api/v1/users/me' const toSend = {} if (newPassword !== undefined && newPassword !== null) toSend['password'] = newPassword if (displayNSFW !== undefined && displayNSFW !== null) toSend['displayNSFW'] = displayNSFW + if (autoPlayVideo !== undefined && autoPlayVideo !== null) toSend['autoPlayVideo'] = autoPlayVideo if (email !== undefined && email !== null) toSend['email'] = email return request(url) -- cgit v1.2.3