mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-15 02:49:33 +01:00
fix(discord): tidy a thread made in the old channel, keep the two pending sets in step, settle the hint when the settings are off
This commit is contained in:
1 parent
97c698b249
commit
d6c7d30bd4
2 files changed
+28
-3
No files matched your search
@@ -533,11 +533,16 @@ describe('DiscordBridge', () => {
|
||||
it('drops a thread whose creation finished after the parent channel changed', async () => {
|
||||
let release!: () => void;
|
||||
const gate = new Promise<void>((r) => (release = r));
|
||||
const b = bridge({}, async (url) => {
|
||||
const b = bridge({}, async (url, init) => {
|
||||
if (String(url).endsWith(`/channels/${PARENT}/threads`)) {
|
||||
await gate;
|
||||
return jsonRes({ id: THREAD });
|
||||
}
|
||||
posts.push({
|
||||
path: new URL(String(url)).pathname.replace('/api/v10', ''),
|
||||
method: String(init.method),
|
||||
body: init.body ? JSON.parse(String(init.body)) : undefined,
|
||||
});
|
||||
return jsonRes({ id: 'msg' });
|
||||
});
|
||||
const first = b.notify(MSG);
|
||||
@@ -546,6 +551,8 @@ describe('DiscordBridge', () => {
|
||||
await b.reload();
|
||||
release();
|
||||
expect(await first).toMatchObject({ ok: false });
|
||||
// The thread made in the old channel is tidied, not left open there.
|
||||
expect(posts).toContainEqual({ path: `/channels/${THREAD}`, method: 'PATCH', body: { archived: true } });
|
||||
expect(await readThreadMap(dir)).toEqual({});
|
||||
b.stop();
|
||||
});
|
||||
@@ -943,6 +950,17 @@ describe('DiscordBridge files and startup hint', () => {
|
||||
b.stop();
|
||||
});
|
||||
|
||||
it('does not hint a tab that was already past its first idle while the hint was off', async () => {
|
||||
const off = await make({ typedHint: false });
|
||||
await off.sessionCreated('s8', 'w8', t - 1000);
|
||||
await off.sessionIdle('s8', true); // first idle with the hint off: no longer new
|
||||
await writeDiscordConfig(dir, { ...CFG, typedHint: true });
|
||||
await off.reload();
|
||||
await off.sessionIdle('s8', true);
|
||||
expect(sent).toHaveLength(0);
|
||||
off.stop();
|
||||
});
|
||||
|
||||
it('says the agent has exited and types nothing when the tab reports it', async () => {
|
||||
const b = await make({}, undefined, undefined, () => true);
|
||||
await b.onGatewayMessage(reply({ content: 'hello', attachments: [] }));
|
||||
|
||||
Reference in new issue
Block a user