mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-11 13:40:12 +00:00
* Add conversation-entity support for mattermost-plugin-agents v2.0 * Align mobile agent post with plugin-agents v2.0 approval flow and fix rendering bugs * Lint: add blank line before comment in streaming_store test * Address coderabbitai feedback: scope auto-approval per-tool, harden conversation store, tighten tests * Self-review cleanup: clear stores on logout, type cleanup, comment trim, test naming * Fix i18n key ordering in en.json * Address coderabbitai feedback: anchor selection, REASONING_DONE fallback, decision-state race * Scope agent stores per-server and move fetch ownership to the action layer * Drop dead all-server clear helpers; tests use per-server clears
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import TestHelper from '@test/test_helper';
|
|
|
|
import {isConversationRequester} from './requester';
|
|
|
|
import type {ConversationResponse} from '@agents/types';
|
|
|
|
function fakePost(props: Record<string, unknown> = {}) {
|
|
return TestHelper.fakePostModel({props});
|
|
}
|
|
|
|
function fakeConversation(userId: string): ConversationResponse {
|
|
return {
|
|
id: 'c1',
|
|
user_id: userId,
|
|
bot_id: 'bot',
|
|
channel_id: null,
|
|
root_post_id: null,
|
|
title: '',
|
|
operation: '',
|
|
turns: [],
|
|
};
|
|
}
|
|
|
|
describe('isConversationRequester', () => {
|
|
it('should treat the conversation as authoritative when loaded', () => {
|
|
const post = fakePost({llm_requester_user_id: 'otherUser'});
|
|
|
|
expect(isConversationRequester({
|
|
post,
|
|
conversation: fakeConversation('userA'),
|
|
currentUserId: 'userA',
|
|
})).toBe(true);
|
|
});
|
|
|
|
it('should return false when the conversation owner is someone else', () => {
|
|
const post = fakePost({llm_requester_user_id: 'userA'});
|
|
|
|
expect(isConversationRequester({
|
|
post,
|
|
conversation: fakeConversation('userB'),
|
|
currentUserId: 'userA',
|
|
})).toBe(false);
|
|
});
|
|
|
|
it('should fall back to llm_requester_user_id when the conversation has not loaded', () => {
|
|
const post = fakePost({llm_requester_user_id: 'userA'});
|
|
|
|
expect(isConversationRequester({
|
|
post,
|
|
conversation: undefined,
|
|
currentUserId: 'userA',
|
|
})).toBe(true);
|
|
});
|
|
|
|
it('should return false when no conversation is loaded and the legacy prop is absent', () => {
|
|
const post = fakePost({});
|
|
|
|
expect(isConversationRequester({
|
|
post,
|
|
conversation: undefined,
|
|
currentUserId: 'userA',
|
|
})).toBe(false);
|
|
});
|
|
|
|
it('should return false when no current user id is provided', () => {
|
|
const post = fakePost({llm_requester_user_id: 'userA'});
|
|
|
|
expect(isConversationRequester({
|
|
post,
|
|
conversation: fakeConversation('userA'),
|
|
currentUserId: undefined,
|
|
})).toBe(false);
|
|
});
|
|
});
|