From 6dcdf1d342b27d626b3d8d8a6f71a1dee78f88a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 23 Nov 2021 18:45:30 -0500 Subject: [PATCH] breaking: remove setTopicSort/setCategorySort --- src/socket.io/user.js | 18 ------------ test/user.js | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/src/socket.io/user.js b/src/socket.io/user.js index a9f105ef48..66a7c54820 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -136,24 +136,6 @@ SocketUser.saveSettings = async function (socket, data) { return settings; }; -SocketUser.setTopicSort = async function (socket, sort) { - sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/settings'); - await api.users.updateSetting(socket, { - uid: socket.uid, - setting: 'topicPostSort', - value: sort, - }); -}; - -SocketUser.setCategorySort = async function (socket, sort) { - sockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/settings'); - await api.users.updateSetting(socket, { - uid: socket.uid, - setting: 'categoryTopicSort', - value: sort, - }); -}; - SocketUser.getUnreadCount = async function (socket) { if (!socket.uid) { return 0; diff --git a/test/user.js b/test/user.js index 372d334bf6..fb588e3fbd 100644 --- a/test/user.js +++ b/test/user.js @@ -1927,6 +1927,72 @@ describe('User', () => { done(); }); }); + + it('should get unread count 0 for guest', async () => { + const count = await socketUser.getUnreadCount({ uid: 0 }); + assert.strictEqual(count, 0); + }); + + it('should get unread count for user', async () => { + const count = await socketUser.getUnreadCount({ uid: testUid }); + assert.strictEqual(count, 2); + }); + + it('should get unread chat count 0 for guest', async () => { + const count = await socketUser.getUnreadChatCount({ uid: 0 }); + assert.strictEqual(count, 0); + }); + + it('should get unread chat count for user', async () => { + const count = await socketUser.getUnreadChatCount({ uid: testUid }); + assert.strictEqual(count, 0); + }); + + it('should get unread counts 0 for guest', async () => { + const counts = await socketUser.getUnreadCounts({ uid: 0 }); + assert.deepStrictEqual(counts, {}); + }); + + it('should get unread counts for user', async () => { + const counts = await socketUser.getUnreadCounts({ uid: testUid }); + assert.deepStrictEqual(counts, { + unreadChatCount: 0, + unreadCounts: { + '': 2, + new: 2, + unreplied: 2, + watched: 0, + }, + unreadNewTopicCount: 2, + unreadNotificationCount: 0, + unreadTopicCount: 2, + unreadUnrepliedTopicCount: 2, + unreadWatchedTopicCount: 0, + }); + }); + + it('should get user data by uid', async () => { + const userData = await socketUser.getUserByUID({ uid: testUid }, testUid); + assert.strictEqual(userData.uid, testUid); + }); + + it('should get user data by username', async () => { + const userData = await socketUser.getUserByUsername({ uid: testUid }, 'John Smith'); + assert.strictEqual(userData.uid, testUid); + }); + + it('should get user data by email', async () => { + const userData = await socketUser.getUserByEmail({ uid: testUid }, 'john@example.com'); + assert.strictEqual(userData.uid, testUid); + }); + + it('should check/consent gdpr status', async () => { + const consent = await socketUser.gdpr.check({ uid: testUid }, { uid: testUid }); + assert(!consent); + await socketUser.gdpr.consent({ uid: testUid }); + const consentAfter = await socketUser.gdpr.check({ uid: testUid }, { uid: testUid }); + assert(consentAfter); + }); }); describe('approval queue', () => {