fix(channel): Feishu channel gateway wont restart after config (#291)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
getDeferredRestartAction,
|
||||
getReconnectSkipReason,
|
||||
isLifecycleSuperseded,
|
||||
nextLifecycleEpoch,
|
||||
shouldDeferRestart,
|
||||
} from '@electron/gateway/process-policy';
|
||||
|
||||
describe('gateway process policy helpers', () => {
|
||||
@@ -49,4 +51,62 @@ describe('gateway process policy helpers', () => {
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('restart deferral policy', () => {
|
||||
it('defers restart while startup or reconnect is in progress', () => {
|
||||
expect(shouldDeferRestart({ state: 'starting', startLock: false })).toBe(true);
|
||||
expect(shouldDeferRestart({ state: 'reconnecting', startLock: false })).toBe(true);
|
||||
expect(shouldDeferRestart({ state: 'running', startLock: true })).toBe(true);
|
||||
});
|
||||
|
||||
it('does not defer restart for stable states when no start lock', () => {
|
||||
expect(shouldDeferRestart({ state: 'running', startLock: false })).toBe(false);
|
||||
expect(shouldDeferRestart({ state: 'stopped', startLock: false })).toBe(false);
|
||||
expect(shouldDeferRestart({ state: 'error', startLock: false })).toBe(false);
|
||||
});
|
||||
|
||||
it('drops deferred restart once lifecycle recovers to running', () => {
|
||||
expect(
|
||||
getDeferredRestartAction({
|
||||
hasPendingRestart: true,
|
||||
state: 'running',
|
||||
startLock: false,
|
||||
shouldReconnect: true,
|
||||
})
|
||||
).toBe('drop');
|
||||
});
|
||||
|
||||
it('waits deferred restart while lifecycle is still busy', () => {
|
||||
expect(
|
||||
getDeferredRestartAction({
|
||||
hasPendingRestart: true,
|
||||
state: 'starting',
|
||||
startLock: false,
|
||||
shouldReconnect: true,
|
||||
})
|
||||
).toBe('wait');
|
||||
});
|
||||
|
||||
it('executes deferred restart when manager is idle and not running', () => {
|
||||
expect(
|
||||
getDeferredRestartAction({
|
||||
hasPendingRestart: true,
|
||||
state: 'error',
|
||||
startLock: false,
|
||||
shouldReconnect: true,
|
||||
})
|
||||
).toBe('execute');
|
||||
});
|
||||
|
||||
it('drops deferred restart when reconnect is disabled', () => {
|
||||
expect(
|
||||
getDeferredRestartAction({
|
||||
hasPendingRestart: true,
|
||||
state: 'stopped',
|
||||
startLock: false,
|
||||
shouldReconnect: false,
|
||||
})
|
||||
).toBe('drop');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user