Add hybrid R4R media conversation mode
This commit is contained in:
1 parent
927636ec8b
commit
b73e305cf3
15 files changed
+357
-35
No files matched your search
@@ -231,7 +231,7 @@ describe('settings and access', () => {
|
||||
|
||||
it('configures autonomous r4r per subreddit and requires explicit confirmation', async () => {
|
||||
installConfigApi();
|
||||
let requestBody: { subreddits: Array<{ conversation: { mode: string; maxAutomatedTurns: number } }> } | undefined;
|
||||
let requestBody: { subreddits: Array<{ conversation: { mode: string; maxAutomatedTurns: number; rapportTurnsBeforeMediaAsk: number } }> } | undefined;
|
||||
server.use(http.put('/api/config', async ({ request }) => {
|
||||
requestBody = await request.json() as typeof requestBody;
|
||||
return HttpResponse.json({
|
||||
@@ -259,7 +259,47 @@ describe('settings and access', () => {
|
||||
await user.click(within(dialog).getByRole('button', { name: 'Apply risky settings' }));
|
||||
|
||||
await waitFor(() => expect(requestBody?.subreddits[0].conversation).toEqual({
|
||||
mode: 'r4r', maxAutomatedTurns: 7,
|
||||
mode: 'r4r', maxAutomatedTurns: 7, rapportTurnsBeforeMediaAsk: 3,
|
||||
}));
|
||||
});
|
||||
|
||||
it('configures rapport and total turns for the autonomous hybrid mode', async () => {
|
||||
installConfigApi();
|
||||
let requestBody: {
|
||||
subreddits: Array<{
|
||||
conversation: { mode: string; maxAutomatedTurns: number; rapportTurnsBeforeMediaAsk: 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' });
|
||||
await user.selectOptions(behaviour, 'r4r-media');
|
||||
const maxTurns = screen.getByRole('spinbutton', { name: 'Subreddit 1 maximum automated turns' });
|
||||
const rapportTurns = screen.getByRole('spinbutton', { name: 'Subreddit 1 rapport turns before media ask' });
|
||||
await user.click(screen.getByRole('button', { name: 'Save settings' }));
|
||||
expect(screen.getByText('Rapport turns must be lower than the maximum automated turns.')).toBeInTheDocument();
|
||||
expect(requestBody).toBeUndefined();
|
||||
await user.clear(maxTurns);
|
||||
await user.type(maxTurns, '6');
|
||||
await user.clear(rapportTurns);
|
||||
await user.type(rapportTurns, '3');
|
||||
await user.click(screen.getByRole('button', { name: 'Save settings' }));
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: 'Confirm risky settings' });
|
||||
expect(dialog).toHaveTextContent('hybrid mode can make one optional image request after rapport');
|
||||
await user.click(within(dialog).getByRole('button', { name: 'Apply risky settings' }));
|
||||
|
||||
await waitFor(() => expect(requestBody?.subreddits[0].conversation).toEqual({
|
||||
mode: 'r4r-media', maxAutomatedTurns: 6, rapportTurnsBeforeMediaAsk: 3,
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user