aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2023-12-13 22:20:59 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2023-12-13 22:20:59 +0000
commit2b41c1cfe86cba814aba98da14d70ac1c09f422f (patch)
treeb90119b33d0d9cbcccc9193809864fe630020bf6 /test
parenta98e241a815a95a2a7dd073aec8a993719037dcc (diff)
parent55ed65331fb5e53374a0be6710896c383e34d120 (diff)
Merge branch 'notifications-thru-sw' into 'develop'
Notifications improvements. See merge request pleroma/pleroma-fe!1873
Diffstat (limited to 'test')
-rw-r--r--test/unit/specs/modules/statuses.spec.js76
-rw-r--r--test/unit/specs/services/notification_utils/notification_utils.spec.js78
2 files changed, 39 insertions, 115 deletions
diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js
index a8d0e5a3..0d83a9f8 100644
--- a/test/unit/specs/modules/statuses.spec.js
+++ b/test/unit/specs/modules/statuses.spec.js
@@ -77,24 +77,6 @@ describe('Statuses module', () => {
expect(state.timelines.public.newStatusCount).to.equal(0)
})
- it('removes statuses by tag on deletion', () => {
- const state = defaultState()
- const status = makeMockStatus({ id: '1' })
- const otherStatus = makeMockStatus({ id: '3' })
- status.uri = 'xxx'
- const deletion = makeMockStatus({ id: '2', type: 'deletion' })
- deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
- deletion.uri = 'xxx'
-
- mutations.addNewStatuses(state, { statuses: [status, otherStatus], showImmediately: true, timeline: 'public' })
- mutations.addNewStatuses(state, { statuses: [deletion], showImmediately: true, timeline: 'public' })
-
- expect(state.allStatuses).to.eql([otherStatus])
- expect(state.timelines.public.statuses).to.eql([otherStatus])
- expect(state.timelines.public.visibleStatuses).to.eql([otherStatus])
- expect(state.timelines.public.maxId).to.eql('3')
- })
-
it('does not update the maxId when the noIdUpdate flag is set', () => {
const state = defaultState()
const status = makeMockStatus({ id: '1' })
@@ -315,62 +297,4 @@ describe('Statuses module', () => {
expect(state.timelines.user.userId).to.eql(123)
})
})
-
- describe('notifications', () => {
- it('removes a notification when the notice gets removed', () => {
- const user = { id: '1' }
- const state = defaultState()
- const status = makeMockStatus({ id: '1' })
- const otherStatus = makeMockStatus({ id: '3' })
- const mentionedStatus = makeMockStatus({ id: '2' })
- mentionedStatus.attentions = [user]
- mentionedStatus.uri = 'xxx'
- otherStatus.attentions = [user]
-
- const deletion = makeMockStatus({ id: '4', type: 'deletion' })
- deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
- deletion.uri = 'xxx'
- const newNotificationSideEffects = () => {}
- mutations.addNewStatuses(state, { statuses: [status, otherStatus], user })
- mutations.addNewNotifications(
- state,
- {
- notifications: [{
- from_profile: { id: '2' },
- id: '998',
- type: 'mention',
- status: otherStatus,
- action: otherStatus,
- seen: false
- }],
- newNotificationSideEffects
- })
-
- expect(state.notifications.data.length).to.eql(1)
- mutations.addNewNotifications(
- state,
- {
- notifications: [{
- from_profile: { id: '2' },
- id: '999',
- type: 'mention',
- status: mentionedStatus,
- action: mentionedStatus,
- seen: false
- }],
- newNotificationSideEffects
- })
-
- mutations.addNewStatuses(state, { statuses: [mentionedStatus], user })
- expect(state.allStatuses.length).to.eql(3)
- expect(state.notifications.data.length).to.eql(2)
- expect(state.notifications.data[1].status).to.eql(mentionedStatus)
- expect(state.notifications.data[1].action).to.eql(mentionedStatus)
- expect(state.notifications.data[1].type).to.eql('mention')
-
- mutations.addNewStatuses(state, { statuses: [deletion], user })
- expect(state.allStatuses.length).to.eql(2)
- expect(state.notifications.data.length).to.eql(1)
- })
- })
})
diff --git a/test/unit/specs/services/notification_utils/notification_utils.spec.js b/test/unit/specs/services/notification_utils/notification_utils.spec.js
index 00628d83..60db7380 100644
--- a/test/unit/specs/services/notification_utils/notification_utils.spec.js
+++ b/test/unit/specs/services/notification_utils/notification_utils.spec.js
@@ -5,28 +5,28 @@ describe('NotificationUtils', () => {
it('should return sorted notifications with configured types', () => {
const store = {
state: {
- statuses: {
- notifications: {
- data: [
- {
- id: 1,
- action: { id: '1' },
- type: 'like'
- },
- {
- id: 2,
- action: { id: '2' },
- type: 'mention'
- },
- {
- id: 3,
- action: { id: '3' },
- type: 'repeat'
- }
- ]
- }
- },
- config: {
+ notifications: {
+ data: [
+ {
+ id: 1,
+ action: { id: '1' },
+ type: 'like'
+ },
+ {
+ id: 2,
+ action: { id: '2' },
+ type: 'mention'
+ },
+ {
+ id: 3,
+ action: { id: '3' },
+ type: 'repeat'
+ }
+ ]
+ }
+ },
+ getters: {
+ mergedConfig: {
notificationVisibility: {
likes: true,
repeats: true,
@@ -55,23 +55,23 @@ describe('NotificationUtils', () => {
it('should return only notifications not marked as seen', () => {
const store = {
state: {
- statuses: {
- notifications: {
- data: [
- {
- action: { id: '1' },
- type: 'like',
- seen: false
- },
- {
- action: { id: '2' },
- type: 'mention',
- seen: true
- }
- ]
- }
- },
- config: {
+ notifications: {
+ data: [
+ {
+ action: { id: '1' },
+ type: 'like',
+ seen: false
+ },
+ {
+ action: { id: '2' },
+ type: 'mention',
+ seen: true
+ }
+ ]
+ }
+ },
+ getters: {
+ mergedConfig: {
notificationVisibility: {
likes: true,
repeats: true,