Add account browsing simulation
This commit is contained in:
1 parent
e2d7dc4b82
commit
27012399ec
31 files changed
+1476
-28
No files matched your search
@@ -43,6 +43,28 @@ function stats(overrides: Record<string, unknown> = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function browsing(includeRecent = false) {
|
||||
return {
|
||||
settings: {
|
||||
enabled: false,
|
||||
dailyTargetMin: 3,
|
||||
dailyTargetMax: 6,
|
||||
postWeight: 60,
|
||||
commentWeight: 40,
|
||||
quietHours: { enabled: true, startHour: 23, endHour: 7 },
|
||||
minimumGapMs: 2_700_000,
|
||||
jitterMs: 900_000,
|
||||
allowNsfw: false,
|
||||
nextDueAt: null,
|
||||
updatedAt: 1_700_000_000_000,
|
||||
},
|
||||
todayTarget: 4,
|
||||
stats: { selected: 0, posts: 0, comments: 0, rejected: 0, skipped: 0 },
|
||||
noVotesSubmitted: true,
|
||||
...(includeRecent ? { recentDecisions: [] } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function summary(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
accountId: ACCOUNT_ID,
|
||||
@@ -51,6 +73,7 @@ function summary(overrides: Record<string, unknown> = {}) {
|
||||
stats: stats(),
|
||||
subredditCount: 2,
|
||||
activeSubredditCount: 1,
|
||||
browsing: browsing(),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -112,6 +135,7 @@ function detail(overrides: Record<string, unknown> = {}) {
|
||||
lastError: 'Comment solicits contact or promotes a profile',
|
||||
},
|
||||
],
|
||||
browsing: browsing(true),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -133,6 +157,10 @@ const server = setupServer(
|
||||
requests.push({ method: 'PATCH', url: request.url, body: await request.json() });
|
||||
return HttpResponse.json({ success: true, account: detailPayload });
|
||||
}),
|
||||
http.patch('/api/growth/:accountId/browsing', async ({ request }) => {
|
||||
requests.push({ method: 'PATCH', url: request.url, body: await request.json() });
|
||||
return HttpResponse.json({ success: true, account: detailPayload });
|
||||
}),
|
||||
http.post('/api/growth/:accountId/pause', async ({ request }) => {
|
||||
requests.push({ method: 'POST', url: request.url, body: await request.json() });
|
||||
return HttpResponse.json({ success: true, account: detailPayload });
|
||||
@@ -187,6 +215,21 @@ describe('GrowthPage', () => {
|
||||
expect(screen.getByText(/posted without review/i)).toBeVisible();
|
||||
});
|
||||
|
||||
it('shows browsing as an explicit no-vote simulation and can enable it', async () => {
|
||||
renderGrowth();
|
||||
const user = userEvent.setup();
|
||||
|
||||
expect(await screen.findByRole('heading', { name: 'Browsing simulation' })).toBeVisible();
|
||||
expect(screen.getByText('No Reddit votes were submitted.')).toBeVisible();
|
||||
expect(screen.getByText('0 / 4')).toBeVisible();
|
||||
await user.click(screen.getByLabelText('Simulate browsing selections'));
|
||||
|
||||
await waitFor(() => expect(requests).toContainEqual(expect.objectContaining({
|
||||
method: 'PATCH', body: { enabled: true },
|
||||
})));
|
||||
expect(requests[0].url).toContain('/api/growth/%40t2_grower%3Areddit.com/browsing');
|
||||
});
|
||||
|
||||
it('shows an empty state when there are no accounts', async () => {
|
||||
overviewPayload = [];
|
||||
renderGrowth();
|
||||
|
||||
Reference in new issue
Block a user