修复自定义邮箱收码模式默认手动

This commit is contained in:
QLHazyCoder
2026-05-28 06:14:04 +08:00
parent 1960b6e21a
commit 2992cc88ac
18 changed files with 1154 additions and 6 deletions
@@ -54,6 +54,84 @@ test('flow mail polling service dispatches API mail providers through shared hel
assert.equal(logs.some((entry) => entry.message.includes('Hotmail')), true);
});
test('flow mail polling service dispatches custom helper when custom provider is in helper mode', async () => {
const api = loadFlowMailPollingApi();
let customCall = null;
const service = api.createFlowMailPollingService({
addLog: async () => {},
buildVerificationPollPayloadForNode: (nodeId, state, overrides) => ({
flowId: state.activeFlowId,
nodeId,
step: 4,
targetEmail: 'custom@example.com',
maxAttempts: 1,
intervalMs: 100,
...overrides,
}),
CUSTOM_MAIL_PROVIDER: 'custom',
getMailConfig: () => ({ provider: 'custom', label: '自定义邮箱' }),
pollCustomMailVerificationCode: async (step, state, payload) => {
customCall = { step, state, payload };
return { code: '654321', emailTimestamp: 123 };
},
});
const result = await service.pollFlowVerificationCode({
flowId: 'kiro',
nodeId: 'kiro-submit-verification-code',
state: {
activeFlowId: 'kiro',
mailProvider: 'custom',
customMailReceiveMode: 'helper',
email: 'custom@example.com',
},
step: 4,
});
assert.equal(result.code, '654321');
assert.equal(customCall.step, 4);
assert.equal(customCall.payload.targetEmail, 'custom@example.com');
});
test('flow mail polling service rejects custom manual mode before helper polling', async () => {
const api = loadFlowMailPollingApi();
let customCallCount = 0;
const service = api.createFlowMailPollingService({
addLog: async () => {},
buildVerificationPollPayloadForNode: (nodeId, state, overrides) => ({
flowId: state.activeFlowId,
nodeId,
step: 4,
targetEmail: 'custom@example.com',
maxAttempts: 1,
intervalMs: 100,
...overrides,
}),
CUSTOM_MAIL_PROVIDER: 'custom',
getMailConfig: () => ({ provider: 'custom', label: '自定义邮箱' }),
pollCustomMailVerificationCode: async () => {
customCallCount += 1;
return { code: '654321', emailTimestamp: 123 };
},
});
await assert.rejects(
() => service.pollFlowVerificationCode({
flowId: 'kiro',
nodeId: 'kiro-submit-verification-code',
state: {
activeFlowId: 'kiro',
mailProvider: 'custom',
customMailReceiveMode: 'manual',
email: 'custom@example.com',
},
step: 4,
}),
/手动确认模式/
);
assert.equal(customCallCount, 0);
});
test('flow mail polling service prepares browser mail provider sessions and payload timeouts', async () => {
const api = loadFlowMailPollingApi();
let ensured2925 = null;