Add per-subreddit R4R conversation modes
This commit is contained in:
1 parent
23d4c3a320
commit
0f76bcf59a
14 files changed
+343
-24
No files matched your search
@@ -229,6 +229,40 @@ describe('settings and access', () => {
|
||||
expect(updateRequests).toBe(1);
|
||||
});
|
||||
|
||||
it('configures autonomous r4r per subreddit and requires explicit confirmation', async () => {
|
||||
installConfigApi();
|
||||
let requestBody: { subreddits: Array<{ conversation: { mode: string; maxAutomatedTurns: number } }> } | undefined;
|
||||
server.use(http.put('/api/config', async ({ request }) => {
|
||||
requestBody = await request.json() as typeof requestBody;
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
config: { rateLimit: config.rateLimit, browser: config.browser, reddit: config.reddit },
|
||||
subreddits: requestBody?.subreddits ?? config.subreddits,
|
||||
});
|
||||
}));
|
||||
const user = userEvent.setup();
|
||||
renderSettings('/settings?section=behaviour');
|
||||
|
||||
const behaviour = await screen.findByRole('combobox', { name: 'Subreddit 1 conversation behaviour' });
|
||||
expect(behaviour).toHaveValue('legacy');
|
||||
expect(screen.queryByRole('spinbutton', { name: 'Subreddit 1 maximum automated turns' })).not.toBeInTheDocument();
|
||||
|
||||
await user.selectOptions(behaviour, 'r4r');
|
||||
const maxTurns = screen.getByRole('spinbutton', { name: 'Subreddit 1 maximum automated turns' });
|
||||
await user.clear(maxTurns);
|
||||
await user.type(maxTurns, '7');
|
||||
await user.click(screen.getByRole('button', { name: 'Save settings' }));
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: 'Confirm risky settings' });
|
||||
expect(dialog).toHaveTextContent('Autonomous R4R will send conversational replies without approval');
|
||||
expect(requestBody).toBeUndefined();
|
||||
await user.click(within(dialog).getByRole('button', { name: 'Apply risky settings' }));
|
||||
|
||||
await waitFor(() => expect(requestBody?.subreddits[0].conversation).toEqual({
|
||||
mode: 'r4r', maxAutomatedTurns: 7,
|
||||
}));
|
||||
});
|
||||
|
||||
it('validates advanced application JSON before saving', async () => {
|
||||
installConfigApi();
|
||||
let updateRequests = 0;
|
||||
|
||||
Reference in new issue
Block a user