fix(tests): enhance messageId handling for legacy inbox rows
- Updated tests to ensure legacy inbox rows without messageId generate a deterministic hash-based messageId. - Modified test descriptions for clarity and accuracy regarding messageId generation. - Adjusted expectations in tests to reflect the new behavior of relaying legacy lead inbox rows with generated messageIds.
This commit is contained in:
parent
b24d90d799
commit
549fce4689
2 changed files with 23 additions and 10 deletions
|
|
@ -119,7 +119,7 @@ describe('TeamInboxReader', () => {
|
||||||
expect(merged[1].text).toBe('older');
|
expect(merged[1].text).toBe('older');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ignores legacy inbox rows without messageId', async () => {
|
it('generates deterministic messageId for legacy inbox rows without messageId', async () => {
|
||||||
hoisted.files.set(
|
hoisted.files.set(
|
||||||
'/mock/teams/my-team/inboxes/alice.json',
|
'/mock/teams/my-team/inboxes/alice.json',
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
|
|
@ -140,8 +140,14 @@ describe('TeamInboxReader', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const messages = await reader.getMessagesFor('my-team', 'alice');
|
const messages = await reader.getMessagesFor('my-team', 'alice');
|
||||||
expect(messages).toHaveLength(1);
|
expect(messages).toHaveLength(2);
|
||||||
expect(messages[0].text).toBe('supported');
|
// Legacy row gets a deterministic hash-based messageId
|
||||||
expect(messages[0].messageId).toBe('m-1');
|
const legacy = messages.find((m) => m.text === 'legacy');
|
||||||
|
expect(legacy).toBeDefined();
|
||||||
|
expect(legacy!.messageId).toMatch(/^inbox-[a-f0-9]{16}$/);
|
||||||
|
// Explicit messageId is preserved
|
||||||
|
const supported = messages.find((m) => m.text === 'supported');
|
||||||
|
expect(supported).toBeDefined();
|
||||||
|
expect(supported!.messageId).toBe('m-1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ describe('TeamProvisioningService relayLeadInboxMessages', () => {
|
||||||
expect(writeSpy).toHaveBeenCalledTimes(1);
|
expect(writeSpy).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ignores unread lead inbox rows without messageId', async () => {
|
it('relays legacy lead inbox rows with generated messageId', async () => {
|
||||||
const service = new TeamProvisioningService();
|
const service = new TeamProvisioningService();
|
||||||
const teamName = 'my-team';
|
const teamName = 'my-team';
|
||||||
seedConfig(teamName);
|
seedConfig(teamName);
|
||||||
|
|
@ -382,11 +382,18 @@ describe('TeamProvisioningService relayLeadInboxMessages', () => {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { writeSpy } = attachAliveRun(service, teamName);
|
const { writeSpy } = attachAliveRun(service, teamName);
|
||||||
const relayed = await service.relayLeadInboxMessages(teamName);
|
const relayPromise = service.relayLeadInboxMessages(teamName);
|
||||||
|
const run = await waitForCapture(service);
|
||||||
|
expect(run?.leadRelayCapture).toBeTruthy();
|
||||||
|
(service as any).handleStreamJsonMessage(run, {
|
||||||
|
type: 'assistant',
|
||||||
|
content: [{ type: 'text', text: 'Ok.' }],
|
||||||
|
});
|
||||||
|
(service as any).handleStreamJsonMessage(run, { type: 'result', subtype: 'success' });
|
||||||
|
const relayed = await relayPromise;
|
||||||
|
|
||||||
expect(relayed).toBe(0);
|
expect(relayed).toBe(1);
|
||||||
expect(writeSpy).toHaveBeenCalledTimes(0);
|
expect(writeSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(hoisted.appendSentMessage).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resolves cross-team reply metadata only for a single matching team hint', async () => {
|
it('resolves cross-team reply metadata only for a single matching team hint', async () => {
|
||||||
|
|
@ -625,7 +632,7 @@ describe('TeamProvisioningService relayLeadInboxMessages', () => {
|
||||||
expect(payload).toContain('"type":"user"');
|
expect(payload).toContain('"type":"user"');
|
||||||
expect(payload).toContain('recipient=\\"alice\\"');
|
expect(payload).toContain('recipient=\\"alice\\"');
|
||||||
expect(payload).toContain('Source: system_notification');
|
expect(payload).toContain('Source: system_notification');
|
||||||
expect(payload).toContain('Forward that automated notification exactly once;');
|
expect(payload).toContain('forward that notification exactly once without paraphrasing');
|
||||||
expect(payload).toContain('Please retry with logging enabled.');
|
expect(payload).toContain('Please retry with logging enabled.');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue