Remove browsing selection ceilings
This commit is contained in:
1 parent
c028637556
commit
bc42c55555
14 files changed
+81
-53
No files matched your search
@@ -157,16 +157,17 @@ describe('AccountBrowsingSimulationService', () => {
|
||||
});
|
||||
|
||||
it('selects the configured number of distinct things in one session', async () => {
|
||||
enable({ postWeight: 100, commentWeight: 0, selectionsPerSession: 3 });
|
||||
const fixture = service({ posts: [post('one'), post('two'), post('three'), post('four')] });
|
||||
const posts = Array.from({ length: 18 }, (_, index) => post(`item-${index}`));
|
||||
enable({ postWeight: 100, commentWeight: 0, selectionsPerSession: 15 });
|
||||
const fixture = service({ posts });
|
||||
|
||||
const result = await fixture.instance.runNow();
|
||||
|
||||
expect(result).toMatchObject({ kind: 'simulated' });
|
||||
if (result.kind !== 'simulated') throw new Error('Expected a simulated session');
|
||||
expect(result.decisions).toHaveLength(3);
|
||||
expect(new Set(result.decisions.map((decision) => decision.thingFullname)).size).toBe(3);
|
||||
expect(repository.listRecentSelections(ACCOUNT)).toHaveLength(3);
|
||||
expect(result.decisions).toHaveLength(15);
|
||||
expect(new Set(result.decisions.map((decision) => decision.thingFullname)).size).toBe(15);
|
||||
expect(repository.listRecentSelections(ACCOUNT)).toHaveLength(15);
|
||||
});
|
||||
|
||||
it('caps a scheduled multi-selection session at the remaining daily target', async () => {
|
||||
@@ -335,7 +336,7 @@ describe('browsing migration', () => {
|
||||
runMigrations(db);
|
||||
const version = db.pragma('user_version', { simple: true }) as number;
|
||||
db.exec('DROP TABLE account_browsing_decisions; DROP TABLE account_browsing_settings;');
|
||||
db.pragma(`user_version = ${version - 4}`);
|
||||
db.pragma(`user_version = ${version - 5}`);
|
||||
|
||||
runMigrations(db);
|
||||
insertAccount(db, ACCOUNT, 'owner');
|
||||
@@ -343,6 +344,9 @@ describe('browsing migration', () => {
|
||||
expect(new AccountBrowsingSimulationRepository(db).getSettings(ACCOUNT)).toMatchObject({
|
||||
enabled: false, dailyTargetMin: 3, dailyTargetMax: 6, selectionsPerSession: 1, nextDueAt: null,
|
||||
});
|
||||
expect(new AccountBrowsingSimulationRepository(db).saveSettings(ACCOUNT, {
|
||||
dailyTargetMin: 20, dailyTargetMax: 40, selectionsPerSession: 25,
|
||||
})).toMatchObject({ dailyTargetMin: 20, dailyTargetMax: 40, selectionsPerSession: 25 });
|
||||
expect(db.prepare(`PRAGMA table_info(account_growth_settings)`).all())
|
||||
.toEqual(expect.arrayContaining([expect.objectContaining({ name: 'daily_limit' })]));
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user