HH-598: hide unavailable AI takeover (#155)
* fix(HH-598): hide unavailable AI takeover * fix: isolate inbox assistant availability --------- Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
+35
-10
@@ -1002,22 +1002,47 @@ describe('#addMentions', () => {
|
||||
it('fetches inbox assistant by id', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: {
|
||||
id: 1,
|
||||
name: 'Assistant',
|
||||
description: 'Assistant description',
|
||||
},
|
||||
});
|
||||
await actions.getInboxCaptainAssistantById({ commit }, 1);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[
|
||||
types.SET_INBOX_CAPTAIN_ASSISTANT,
|
||||
{
|
||||
assistant: {
|
||||
id: 1,
|
||||
name: 'Assistant',
|
||||
description: 'Assistant description',
|
||||
},
|
||||
},
|
||||
});
|
||||
await actions.getInboxCaptainAssistantById({ commit }, 1);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.SET_INBOX_CAPTAIN_ASSISTANT, { assistant: null }],
|
||||
[
|
||||
types.SET_INBOX_CAPTAIN_ASSISTANT,
|
||||
{
|
||||
assistant: {
|
||||
id: 1,
|
||||
name: 'Assistant',
|
||||
description: 'Assistant description',
|
||||
},
|
||||
},
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
it('ignores an older response after switching conversations', async () => {
|
||||
const resolvers = [];
|
||||
axios.get.mockImplementation(
|
||||
() => new Promise(resolve => resolvers.push(resolve))
|
||||
);
|
||||
|
||||
const requestA = actions.getInboxCaptainAssistantById({ commit }, 1);
|
||||
const requestB = actions.getInboxCaptainAssistantById({ commit }, 2);
|
||||
resolvers[1]({ data: { assistant: null } });
|
||||
await requestB;
|
||||
resolvers[0]({ data: { assistant: { id: 1, name: 'Assistant A' } } });
|
||||
await requestA;
|
||||
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.SET_INBOX_CAPTAIN_ASSISTANT, { assistant: null }],
|
||||
[types.SET_INBOX_CAPTAIN_ASSISTANT, { assistant: null }],
|
||||
[types.SET_INBOX_CAPTAIN_ASSISTANT, { assistant: null }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user