Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions __tests__/temporal/notifications/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ const setupTestEnv = async () => {
connection: testEnv.nativeConnection,
taskQueue: 'test',
activities: mockActivities,
workflowsPath: require.resolve(
'../../../src/temporal/notifications/workflows',
),
workflowsPath:
require.resolve('../../../src/temporal/notifications/workflows'),
});
};

Expand Down
5 changes: 2 additions & 3 deletions __tests__/temporal/notifications/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ beforeEach(async () => {
connection: testEnv.nativeConnection,
taskQueue: 'test',
activities: mockActivities,
workflowsPath: require.resolve(
'../../../src/temporal/notifications/workflows',
),
workflowsPath:
require.resolve('../../../src/temporal/notifications/workflows'),
});
jest.clearAllMocks();
});
Expand Down
115 changes: 46 additions & 69 deletions __tests__/workers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,8 @@ describe('squad featured updated notification', () => {
});

it('should be registered', async () => {
const worker = await import(
'../../src/workers/notifications/squadFeaturedUpdated'
);
const worker =
await import('../../src/workers/notifications/squadFeaturedUpdated');

const registeredWorker = workers.find(
(item) => item.subscription === worker.default.subscription,
Expand All @@ -251,9 +250,8 @@ describe('squad featured updated notification', () => {
});

it('should not do anything when squad is not featured', async () => {
const worker = await import(
'../../src/workers/notifications/squadFeaturedUpdated'
);
const worker =
await import('../../src/workers/notifications/squadFeaturedUpdated');
const actual =
await invokeTypedNotificationWorker<'api.v1.squad-featured-updated'>(
worker.default,
Expand All @@ -265,9 +263,8 @@ describe('squad featured updated notification', () => {
});

it('should send notification to admins', async () => {
const worker = await import(
'../../src/workers/notifications/squadFeaturedUpdated'
);
const worker =
await import('../../src/workers/notifications/squadFeaturedUpdated');
const actual =
await invokeTypedNotificationWorker<'api.v1.squad-featured-updated'>(
worker.default,
Expand All @@ -292,9 +289,8 @@ describe('squad featured updated notification', () => {
});

it('should send notification to moderators', async () => {
const worker = await import(
'../../src/workers/notifications/squadFeaturedUpdated'
);
const worker =
await import('../../src/workers/notifications/squadFeaturedUpdated');
const actual =
await invokeTypedNotificationWorker<'api.v1.squad-featured-updated'>(
worker.default,
Expand All @@ -319,9 +315,8 @@ describe('squad featured updated notification', () => {
});

it('should not send notification to regular members', async () => {
const worker = await import(
'../../src/workers/notifications/squadFeaturedUpdated'
);
const worker =
await import('../../src/workers/notifications/squadFeaturedUpdated');
const actual =
await invokeTypedNotificationWorker<'api.v1.squad-featured-updated'>(
worker.default,
Expand All @@ -346,9 +341,8 @@ describe('squad featured updated notification', () => {
});

it('should not send notification to blocked members', async () => {
const worker = await import(
'../../src/workers/notifications/squadFeaturedUpdated'
);
const worker =
await import('../../src/workers/notifications/squadFeaturedUpdated');
const actual =
await invokeTypedNotificationWorker<'api.v1.squad-featured-updated'>(
worker.default,
Expand Down Expand Up @@ -984,9 +978,8 @@ describe('post added notifications', () => {

describe('post bookmark reminder', () => {
it('should be registered', async () => {
const worker = await import(
'../../src/workers/notifications/postBookmarkReminder'
);
const worker =
await import('../../src/workers/notifications/postBookmarkReminder');

const registeredWorker = workers.find(
(item) => item.subscription === worker.default.subscription,
Expand All @@ -996,9 +989,8 @@ describe('post bookmark reminder', () => {
});

it('should add notification for the user that set the reminder', async () => {
const worker = await import(
'../../src/workers/notifications/postBookmarkReminder'
);
const worker =
await import('../../src/workers/notifications/postBookmarkReminder');
const remindAt = new Date();
await con
.getRepository(Bookmark)
Expand All @@ -1024,9 +1016,8 @@ describe('post bookmark reminder', () => {
});

it('should not add notification if the reminder has been removed', async () => {
const worker = await import(
'../../src/workers/notifications/postBookmarkReminder'
);
const worker =
await import('../../src/workers/notifications/postBookmarkReminder');
await con.getRepository(Bookmark).save({ userId: '1', postId: 'p1' });
const actual =
await invokeTypedNotificationWorker<'api.v1.post-bookmark-reminder'>(
Expand All @@ -1040,9 +1031,8 @@ describe('post bookmark reminder', () => {
});

it('should not add notification if the post is not found', async () => {
const worker = await import(
'../../src/workers/notifications/postBookmarkReminder'
);
const worker =
await import('../../src/workers/notifications/postBookmarkReminder');
const actual =
await invokeTypedNotificationWorker<'api.v1.post-bookmark-reminder'>(
worker.default,
Expand Down Expand Up @@ -1073,9 +1063,8 @@ describe('streak reset restore', () => {
});

it('should be registered', async () => {
const worker = await import(
'../../src/workers/notifications/userStreakResetNotification'
);
const worker =
await import('../../src/workers/notifications/userStreakResetNotification');

const registeredWorker = workers.find(
(item) => item.subscription === worker.default.subscription,
Expand All @@ -1085,9 +1074,8 @@ describe('streak reset restore', () => {
});

it('should add notification for the user to restore their streak', async () => {
const worker = await import(
'../../src/workers/notifications/userStreakResetNotification'
);
const worker =
await import('../../src/workers/notifications/userStreakResetNotification');
const lastViewAt = new Date();
const lastStreak = 10;
const streak = await con
Expand Down Expand Up @@ -1115,9 +1103,8 @@ describe('streak reset restore', () => {
});

it('should not add notification if the stored value has expired', async () => {
const worker = await import(
'../../src/workers/notifications/userStreakResetNotification'
);
const worker =
await import('../../src/workers/notifications/userStreakResetNotification');
const lastViewAt = new Date();
const streak = await con
.getRepository(UserStreak)
Expand All @@ -1133,9 +1120,8 @@ describe('streak reset restore', () => {
});

it('should not add notification if the user opted out of streaks', async () => {
const worker = await import(
'../../src/workers/notifications/userStreakResetNotification'
);
const worker =
await import('../../src/workers/notifications/userStreakResetNotification');
const lastViewAt = new Date();
const lastStreak = 10;
const streak = await con
Expand All @@ -1162,9 +1148,8 @@ describe('streak reset restore', () => {
});

it('should not add notification if the stored value is not a number', async () => {
const worker = await import(
'../../src/workers/notifications/userStreakResetNotification'
);
const worker =
await import('../../src/workers/notifications/userStreakResetNotification');
const lastViewAt = new Date();
const streak = await con
.getRepository(UserStreak)
Expand All @@ -1187,9 +1172,8 @@ describe('streak reset restore', () => {
});

it('should not add notification if user does not have Cores access', async () => {
const worker = await import(
'../../src/workers/notifications/userStreakResetNotification'
);
const worker =
await import('../../src/workers/notifications/userStreakResetNotification');
const lastViewAt = new Date();
const lastStreak = 10;

Expand Down Expand Up @@ -2512,9 +2496,8 @@ describe('user post added', () => {
});

it('should add notification for author', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
await con.getRepository(Post).update({ id: 'p1' }, { authorId: '1' });
await con.getRepository(ContentPreferenceUser).save([
{
Expand Down Expand Up @@ -2548,9 +2531,8 @@ describe('user post added', () => {
});

it('should add notification for scout', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
await con.getRepository(Post).update({ id: 'p1' }, { scoutId: '1' });
await con.getRepository(ContentPreferenceUser).save([
{
Expand Down Expand Up @@ -2584,9 +2566,8 @@ describe('user post added', () => {
});

it('should not add notification for user that are only following', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
await con.getRepository(Post).update({ id: 'p1' }, { scoutId: '1' });
await con.getRepository(ContentPreferenceUser).save([
{
Expand Down Expand Up @@ -2620,9 +2601,8 @@ describe('user post added', () => {
});

it('should not add notification for private post', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
const privatePost = await con.getRepository(Post).save({
...postsFixture[0],
id: 'p1-upa',
Expand Down Expand Up @@ -2658,9 +2638,8 @@ describe('user post added', () => {
});

it('should not add notification for user that muted', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
await con.getRepository(Post).update({ id: 'p1' }, { scoutId: '1' });
await con.getRepository(ContentPreferenceUser).save([
{
Expand Down Expand Up @@ -2700,9 +2679,8 @@ describe('user post added', () => {
});

it('should only query subscriptions for user post added notification type', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
await con.getRepository(Post).update({ id: 'p1' }, { scoutId: '1' });
await con.getRepository(ContentPreferenceUser).save([
{
Expand Down Expand Up @@ -2776,9 +2754,8 @@ describe('user post added', () => {
});

it('should not add notification for brief posts', async () => {
const { postAddedUserNotification: worker } = await import(
'../../src/workers/notifications/postAddedUserNotification'
);
const { postAddedUserNotification: worker } =
await import('../../src/workers/notifications/postAddedUserNotification');
const post = await con.getRepository(BriefPost).save({
...postsFixture[0],
id: 'p1-brief-upa',
Expand Down
5 changes: 2 additions & 3 deletions __tests__/workers/postDeletedSharedPostCleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ beforeEach(async () => {

describe('postDeletedSharedPostCleanup worker', () => {
it('should be registered', async () => {
const worker = await import(
'../../src/workers/postDeletedSharedPostCleanup'
);
const worker =
await import('../../src/workers/postDeletedSharedPostCleanup');

const registeredWorker = workers.find(
(item) => item.subscription === worker.default.subscription,
Expand Down
Loading
Loading