Enable automatic browsing upvotes
This commit is contained in:
1 parent
27012399ec
commit
7bf1aa9d24
26 files changed
+339
-57
No files matched your search
@@ -67,6 +67,7 @@ describe('growth route', () => {
|
||||
let browsingRepo: AccountBrowsingSimulationRepository;
|
||||
let app: express.Express;
|
||||
let pushed: Array<{ level: string; message: string }>;
|
||||
let runNow: ReturnType<typeof vi.fn>;
|
||||
|
||||
beforeEach(() => {
|
||||
db = new Database(':memory:');
|
||||
@@ -81,6 +82,7 @@ describe('growth route', () => {
|
||||
repo = new AccountGrowthRepository(db);
|
||||
browsingRepo = new AccountBrowsingSimulationRepository(db);
|
||||
pushed = [];
|
||||
runNow = vi.fn().mockResolvedValue({ kind: 'scheduled', nextDueAt: 2_000 });
|
||||
|
||||
const ctx = {
|
||||
broadcaster: { push: (level: string, message: string) => pushed.push({ level, message }) },
|
||||
@@ -90,6 +92,12 @@ describe('growth route', () => {
|
||||
redditAccounts: {
|
||||
list: () => [{ accountId: ACCOUNT, redditUsername: 'grower' }],
|
||||
},
|
||||
accountRuntimes: {
|
||||
get: () => ({
|
||||
snapshot: () => ({ state: 'running' }),
|
||||
resources: { browsingService: { runNow } },
|
||||
}),
|
||||
},
|
||||
},
|
||||
} as unknown as WebContext;
|
||||
|
||||
@@ -281,6 +289,19 @@ describe('growth route', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/growth/:accountId/browsing/run', () => {
|
||||
it('runs one immediate simulation through the active account runtime', async () => {
|
||||
const { status, json } = await call(app, 'POST', `/api/growth/${ENCODED}/browsing/run`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
GrowthAccountResponseSchema.parse(json);
|
||||
expect(runNow).toHaveBeenCalledOnce();
|
||||
expect(pushed).toContainEqual({
|
||||
level: 'info', message: 'Browsing simulation run manually for u/grower; no Reddit vote was submitted',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('pause and resume', () => {
|
||||
it('pauses with a default reason and resumes', async () => {
|
||||
const paused = await call(app, 'POST', `/api/growth/${ENCODED}/pause`, {});
|
||||
|
||||
Reference in new issue
Block a user