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', () => {
|
describe('getSubscribedUsers', () => {
|
||||||
test('returns users that did not unsubscribe', async () => {
|
test('returns seen users that did not unsubscribe', async () => {
|
||||||
const user1 = await userStore.insert({
|
const user1 = await userStore.insert({
|
||||||
email: 'user1@example.com',
|
email: 'user1@example.com',
|
||||||
name: 'User One',
|
name: 'User One',
|
||||||
});
|
});
|
||||||
|
// user seen
|
||||||
|
await userStore.successfullyLogin(user1);
|
||||||
const user2 = await userStore.insert({
|
const user2 = await userStore.insert({
|
||||||
email: 'user2@example.com',
|
email: 'user2@example.com',
|
||||||
name: 'User Two',
|
name: 'User Two',
|
||||||
@ -54,11 +56,10 @@ describe('getSubscribedUsers', () => {
|
|||||||
const subscribers =
|
const subscribers =
|
||||||
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
|
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
|
||||||
|
|
||||||
expect(subscribers).toHaveLength(2);
|
expect(subscribers).toHaveLength(1);
|
||||||
expect(subscribers).toEqual(
|
expect(subscribers).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ email: 'user1@example.com', name: 'User One' },
|
{ email: 'user1@example.com', name: 'User One' },
|
||||||
{ email: 'user3@example.com', name: 'User Three' },
|
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -68,6 +69,7 @@ describe('getSubscribedUsers', () => {
|
|||||||
email: 'user7@example.com',
|
email: 'user7@example.com',
|
||||||
name: 'User Seven',
|
name: 'User Seven',
|
||||||
});
|
});
|
||||||
|
await userStore.successfullyLogin(user);
|
||||||
|
|
||||||
let subscribers =
|
let subscribers =
|
||||||
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
|
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
|
||||||
|
@ -39,6 +39,7 @@ export class UserSubscriptionsReadModel implements IUserSubscriptionsReadModel {
|
|||||||
.whereNotIn('id', unsubscribedUserIdsQuery)
|
.whereNotIn('id', unsubscribedUserIdsQuery)
|
||||||
.andWhere('is_service', false)
|
.andWhere('is_service', false)
|
||||||
.andWhere('deleted_at', null)
|
.andWhere('deleted_at', null)
|
||||||
|
.andWhereNot('seen_at', null)
|
||||||
.andWhereNot('email', null);
|
.andWhereNot('email', null);
|
||||||
|
|
||||||
return users.map(mapRowToSubscriber);
|
return users.map(mapRowToSubscriber);
|
||||||
|
@ -46,6 +46,7 @@ test('Subscribe and unsubscribe', async () => {
|
|||||||
email: 'test@getunleash.io',
|
email: 'test@getunleash.io',
|
||||||
name: 'Sample Name',
|
name: 'Sample Name',
|
||||||
});
|
});
|
||||||
|
await userStore.successfullyLogin(user);
|
||||||
|
|
||||||
const subscribers = await userSubscriptionsReadModel.getSubscribedUsers(
|
const subscribers = await userSubscriptionsReadModel.getSubscribedUsers(
|
||||||
'productivity-report',
|
'productivity-report',
|
||||||
@ -79,6 +80,7 @@ test('Event log for subscription actions', async () => {
|
|||||||
email: 'test@getunleash.io',
|
email: 'test@getunleash.io',
|
||||||
name: 'Sample Name',
|
name: 'Sample Name',
|
||||||
});
|
});
|
||||||
|
await userStore.successfullyLogin(user);
|
||||||
|
|
||||||
await userSubscriptionService.unsubscribe(
|
await userSubscriptionService.unsubscribe(
|
||||||
user.id,
|
user.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user