Skip to content
Closed
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
46 changes: 42 additions & 4 deletions __tests__/highlights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ describe('query dailyHeadlines', () => {
expect(action).not.toBeNull();
});

it('should mark backfilled without seeding when no channel clears the minimum post count', async () => {
it('should not seed and not mark backfilled when no channel clears the minimum post count', async () => {
loggedUser = '1';

await saveDigestSource('backend_digest');
Expand All @@ -735,7 +735,7 @@ describe('query dailyHeadlines', () => {
userId: '1',
type: UserActionType.DailyHeadlinesBackfilled,
});
expect(action).not.toBeNull();
expect(action).toBeNull();
});

it('should not seed when the user was already backfilled', async () => {
Expand Down Expand Up @@ -788,7 +788,7 @@ describe('query dailyHeadlines', () => {
expect(action).not.toBeNull();
});

it('should mark backfilled without seeding when the user has no onboarding tags', async () => {
it('should not seed and not mark backfilled when the user has no onboarding tags', async () => {
loggedUser = '1';

await saveDigestSource('backend_digest');
Expand All @@ -806,7 +806,45 @@ describe('query dailyHeadlines', () => {
userId: '1',
type: UserActionType.DailyHeadlinesBackfilled,
});
expect(action).not.toBeNull();
expect(action).toBeNull();
});

it('should seed on a later call once onboarding tags exist', async () => {
loggedUser = '1';

await saveDigestSource('backend_digest');
await saveChannelDigest('backend', 'backend_digest', 'backend');
await saveChannelPosts('mh', ['backend'], 'nodejs', 3);
await saveDigestPost('bd-new', 'backend_digest', hoursAgo(2));
await refreshKeywordChannel();

const first = await client.query(DAILY_HEADLINES_BACKFILL_QUERY);
expect(first.errors).toBeFalsy();
expect(
await con.getRepository(UserAction).findOneBy({
userId: '1',
type: UserActionType.DailyHeadlinesBackfilled,
}),
).toBeNull();

await followKeyword('nodejs');

const second = await client.query(DAILY_HEADLINES_BACKFILL_QUERY);
expect(second.errors).toBeFalsy();
const follows = await con
.getRepository(ContentPreferenceSource)
.find({ where: { userId: '1', feedId: '1' } });
expect(follows).toHaveLength(1);
expect(follows[0]).toMatchObject({
referenceId: 'backend_digest',
status: ContentPreferenceStatus.Follow,
});
expect(
await con.getRepository(UserAction).findOneBy({
userId: '1',
type: UserActionType.DailyHeadlinesBackfilled,
}),
).not.toBeNull();
});
});
});
Expand Down
1 change: 0 additions & 1 deletion src/common/channelDigest/headlineFollows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export const seedHeadlineChannelsForUser = async ({
});

if (!sourceIds.length) {
await markBackfilled({ manager: con, userId });
return { seeded: false, sourceIds: [] };
}

Expand Down
Loading