Skip to content

Commit

Permalink
debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-adams committed Oct 16, 2024
1 parent 752c5b2 commit 3ce1e75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions packages/server/__tests__/lib/grants-collaboration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ describe('Grants Collaboration', () => {
let grant1NoteStaff;

beforeEach(async () => {
subscribeUser(adminUser);
subscribeUser(staffUser);
await subscribeUser(adminUser);
await subscribeUser(staffUser);

periodStart = DateTime.now().minus({ days: 1 }).toJSDate();

Expand Down Expand Up @@ -323,7 +323,7 @@ describe('Grants Collaboration', () => {
.insert({ grant_id: grant2.grant_id, user_id: staffUser.id }, 'id');

await knex('grant_notes_revisions')
.insert({ grant_note_id: grant2NoteStaff.id, text: 'Staff note' }, 'id');
.insert({ grant_note_id: grant2NoteStaff.id, text: 'Another Staff note' }, 'id');

periodEnd = new Date();
});
Expand Down Expand Up @@ -365,17 +365,17 @@ describe('Grants Collaboration', () => {
periodStart = new Date();

// Admin edits note
await knex('grant_notes_revisions')
.insert({ grant_note_id: grant1NoteAdmin.id, text: 'Edit for Admin note' }, 'id');
const [adminRevised] = await knex('grant_notes_revisions')
.insert({ grant_note_id: grant1NoteAdmin.id, text: 'Edit for Admin note' }, 'created_at');

const recipients1 = await getGrantActivityEmailRecipients(knex, periodStart, new Date());
const recipients1 = await getGrantActivityEmailRecipients(knex, periodStart, new Date(adminRevised.created_at.getTime() + 1));
expect(_.map(recipients1, 'userId')).to.have.members([staffUser.id]);

// Staff edits note
await knex('grant_notes_revisions')
.insert({ grant_note_id: grant1NoteStaff.id, text: 'Edit for Staff note' }, 'id');
const [staffRevised] = await knex('grant_notes_revisions')
.insert({ grant_note_id: grant1NoteStaff.id, text: 'Edit for Staff note' }, 'created_at');

const recipients2 = await getGrantActivityEmailRecipients(knex, periodStart, new Date());
const recipients2 = await getGrantActivityEmailRecipients(knex, periodStart, new Date(staffRevised.created_at.getTime() + 1));
expect(_.map(recipients2, 'userId')).to.have.members([staffUser.id, adminUser.id]);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/lib/grantsCollaboration/grantActivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ async function getGrantActivityEmailRecipients(knex, periodStart, periodEnd) {
.on(`recipient_followers.user_id`, '=', `recipient_subscriptions.user_id`)
.on(`recipient_subscriptions.notification_type`, '=', knex.raw('?', [emailConstants.notificationType.grantActivity]));
})
.where('activity.activity_at', '>', periodStart)
.andWhere('activity.activity_at', '<', periodEnd)
.where('activity.activity_at', '>=', periodStart)
.andWhere('activity.activity_at', '<=', periodEnd)
.andWhere('recipient_subscriptions.status', emailConstants.emailSubscriptionStatus.subscribed)
// only consider actions taken by users in the same organization as the recipient:
.andWhereRaw('recipient_users.tenant_id = activity_users.tenant_id')
Expand Down

0 comments on commit 3ce1e75

Please sign in to comment.