From 43d0ea7f4b88d52097172cc0c1831edd7e492503 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Aug 2019 14:40:06 +0200 Subject: Add welcome modal --- server/tests/api/check-params/users.ts | 20 +++++++++++++++++++- server/tests/api/users/users.ts | 21 +++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 939b919ed..55094795c 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -476,6 +476,22 @@ describe('Test users API validators', function () { await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) }) + it('Should fail with an invalid noInstanceConfigWarningModal attribute', async function () { + const fields = { + noInstanceConfigWarningModal: -1 + } + + await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) + }) + + it('Should fail with an invalid noWelcomeModal attribute', async function () { + const fields = { + noWelcomeModal: -1 + } + + await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) + }) + it('Should succeed to change password with the correct params', async function () { const fields = { currentPassword: 'my super password', @@ -483,7 +499,9 @@ describe('Test users API validators', function () { nsfwPolicy: 'blur', autoPlayVideo: false, email: 'super_email@example.com', - theme: 'default' + theme: 'default', + noInstanceConfigWarningModal: true, + noWelcomeModal: true } await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 3a3fabb4c..95b1bb626 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -442,7 +442,7 @@ describe('Test users', function () { url: server.url, accessToken: accessTokenUser, currentPassword: 'super password', - newPassword: 'new password' + password: 'new password' }) user.password = 'new password' @@ -543,7 +543,7 @@ describe('Test users', function () { }) const res = await getMyUserInformation(server.url, accessTokenUser) - const user = res.body + const user: User = res.body expect(user.username).to.equal('user_1') expect(user.email).to.equal('updated@example.com') @@ -552,6 +552,8 @@ describe('Test users', function () { expect(user.id).to.be.a('number') expect(user.account.displayName).to.equal('new display name') expect(user.account.description).to.equal('my super description updated') + expect(user.noWelcomeModal).to.be.false + expect(user.noInstanceConfigWarningModal).to.be.false }) it('Should be able to update my theme', async function () { @@ -568,6 +570,21 @@ describe('Test users', function () { expect(body.theme).to.equal(theme) } }) + + it('Should be able to update my modal preferences', async function () { + await updateMyUser({ + url: server.url, + accessToken: accessTokenUser, + noInstanceConfigWarningModal: true, + noWelcomeModal: true + }) + + const res = await getMyUserInformation(server.url, accessTokenUser) + const user: User = res.body + + expect(user.noWelcomeModal).to.be.true + expect(user.noInstanceConfigWarningModal).to.be.true + }) }) describe('Updating another user', function () { -- cgit v1.2.3