mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
feat: productivity report only for seen users (#9204)
This commit is contained in:
parent
bd6a90ffd4
commit
ebcbd7b637
@ -32,11 +32,13 @@ afterAll(async () => {
|
||||
});
|
||||
|
||||
describe('getSubscribedUsers', () => {
|
||||
test('returns users that did not unsubscribe', async () => {
|
||||
test('returns seen users that did not unsubscribe', async () => {
|
||||
const user1 = await userStore.insert({
|
||||
email: 'user1@example.com',
|
||||
name: 'User One',
|
||||
});
|
||||
// user seen
|
||||
await userStore.successfullyLogin(user1);
|
||||
const user2 = await userStore.insert({
|
||||
email: 'user2@example.com',
|
||||
name: 'User Two',
|
||||
@ -54,11 +56,10 @@ describe('getSubscribedUsers', () => {
|
||||
const subscribers =
|
||||
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
|
||||
|
||||
expect(subscribers).toHaveLength(2);
|
||||
expect(subscribers).toHaveLength(1);
|
||||
expect(subscribers).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ email: 'user1@example.com', name: 'User One' },
|
||||
{ email: 'user3@example.com', name: 'User Three' },
|
||||
]),
|
||||
);
|
||||
});
|
||||
@ -68,6 +69,7 @@ describe('getSubscribedUsers', () => {
|
||||
email: 'user7@example.com',
|
||||
name: 'User Seven',
|
||||
});
|
||||
await userStore.successfullyLogin(user);
|
||||
|
||||
let subscribers =
|
||||
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
|
||||
|
@ -39,6 +39,7 @@ export class UserSubscriptionsReadModel implements IUserSubscriptionsReadModel {
|
||||
.whereNotIn('id', unsubscribedUserIdsQuery)
|
||||
.andWhere('is_service', false)
|
||||
.andWhere('deleted_at', null)
|
||||
.andWhereNot('seen_at', null)
|
||||
.andWhereNot('email', null);
|
||||
|
||||
return users.map(mapRowToSubscriber);
|
||||
|
@ -46,6 +46,7 @@ test('Subscribe and unsubscribe', async () => {
|
||||
email: 'test@getunleash.io',
|
||||
name: 'Sample Name',
|
||||
});
|
||||
await userStore.successfullyLogin(user);
|
||||
|
||||
const subscribers = await userSubscriptionsReadModel.getSubscribedUsers(
|
||||
'productivity-report',
|
||||
@ -79,6 +80,7 @@ test('Event log for subscription actions', async () => {
|
||||
email: 'test@getunleash.io',
|
||||
name: 'Sample Name',
|
||||
});
|
||||
await userStore.successfullyLogin(user);
|
||||
|
||||
await userSubscriptionService.unsubscribe(
|
||||
user.id,
|
||||
|
Loading…
Reference in New Issue
Block a user