Skip to content

Commit feb686a

Browse files
committed
chore: update failing tests
1 parent ce40ded commit feb686a

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

__tests__/workers/newNotificationV2Mail.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,12 @@ it('should not send email notification if the user prefers not to receive them',
693693
const userId = '1';
694694
const repo = con.getRepository(User);
695695
const user = await repo.findOneBy({ id: userId });
696-
await repo.save({ ...user, notificationEmail: false });
696+
await repo.save({
697+
...user,
698+
notificationFlags: {
699+
[NotificationType.CommentUpvoteMilestone]: { email: 'muted' },
700+
},
701+
});
697702
const post = await con.getRepository(ArticlePost).save(postsFixture[0]);
698703
const comment = await con.getRepository(Comment).save({
699704
id: 'c1',
@@ -729,7 +734,12 @@ it('should not send follow email notification if the user prefers not to receive
729734
const userId = '1';
730735
const repo = con.getRepository(User);
731736
const user = await repo.findOneBy({ id: userId });
732-
await repo.save({ ...user, followingEmail: false });
737+
await repo.save({
738+
...user,
739+
notificationFlags: {
740+
[NotificationType.UserPostAdded]: { email: 'muted' },
741+
},
742+
});
733743
const post = await con.getRepository(ArticlePost).save(postsFixture[0]);
734744
const ctx: NotificationUserContext & NotificationPostContext = {
735745
userIds: ['1'],
@@ -757,7 +767,12 @@ it('should not send award email notification if the user prefers not to receive
757767
const repo = con.getRepository(User);
758768
const receiver = await repo.findOneBy({ id: userId });
759769
const sender = await repo.findOneBy({ id: '2' });
760-
await repo.save({ ...receiver, awardEmail: false });
770+
await repo.save({
771+
...receiver,
772+
notificationFlags: {
773+
[NotificationType.UserReceivedAward]: { email: 'muted' },
774+
},
775+
});
761776

762777
await saveFixtures(con, Product, [
763778
{

__tests__/workers/newNotificationV2Push.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,14 @@ it('should not send follow push notification if the user prefers not to receive
126126
const userId = '1';
127127
const repo = con.getRepository(User);
128128
const user = await repo.findOneBy({ id: userId });
129-
await repo.save({ ...user, followNotifications: false });
129+
await repo.save({
130+
...user,
131+
notificationFlags: {
132+
[NotificationType.UserPostAdded]: {
133+
inApp: 'muted',
134+
},
135+
},
136+
});
130137
await saveFixtures(con, Source, sourcesFixture);
131138
const post = await con.getRepository(ArticlePost).save(postsFixture[0]);
132139
const source = await con.getRepository(Source).findOneBy({
@@ -159,7 +166,14 @@ it('should not send award push notification if the user prefers not to receive t
159166
const repo = con.getRepository(User);
160167
const receiver = await repo.findOneBy({ id: userId });
161168
const sender = await repo.findOneBy({ id: '2' });
162-
await repo.save({ ...receiver, awardNotifications: false });
169+
await repo.save({
170+
...receiver,
171+
notificationFlags: {
172+
[NotificationType.UserReceivedAward]: {
173+
inApp: 'muted',
174+
},
175+
},
176+
});
163177

164178
await saveFixtures(con, Product, [
165179
{

0 commit comments

Comments
 (0)