Skip to content
代码片段 群组 项目
提交 09b859ad 编辑于 作者: Phil Hughes's avatar Phil Hughes
浏览文件

Merge branch '428153-duo_chat_beta' into 'master'

Introduced the switch to Beta for Duo Chat

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136059



Merged-by: default avatarPhil Hughes <me@iamphill.com>
Approved-by: default avatarPhil Hughes <me@iamphill.com>
Approved-by: default avatarTomas Vik <tvik@gitlab.com>
Reviewed-by: default avatarPhil Hughes <me@iamphill.com>
Co-authored-by: default avatarDenys Mishunov <dmishunov@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -12,6 +12,7 @@ import aiResponseSubscription from 'ee/graphql_shared/subscriptions/ai_completio ...@@ -12,6 +12,7 @@ import aiResponseSubscription from 'ee/graphql_shared/subscriptions/ai_completio
import getAiMessages from 'ee/ai/graphql/get_ai_messages.query.graphql'; import getAiMessages from 'ee/ai/graphql/get_ai_messages.query.graphql';
import chatMutation from 'ee/ai/graphql/chat.mutation.graphql'; import chatMutation from 'ee/ai/graphql/chat.mutation.graphql';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { i18n, GENIE_CHAT_RESET_MESSAGE } from 'ee/ai/constants'; import { i18n, GENIE_CHAT_RESET_MESSAGE } from 'ee/ai/constants';
import { TANUKI_BOT_TRACKING_EVENT_NAME } from '../constants'; import { TANUKI_BOT_TRACKING_EVENT_NAME } from '../constants';
...@@ -37,7 +38,7 @@ export default { ...@@ -37,7 +38,7 @@ export default {
components: { components: {
GlDuoChat, GlDuoChat,
}, },
mixins: [Tracking.mixin()], mixins: [Tracking.mixin(), glFeatureFlagsMixin()],
provide() { provide() {
return { return {
renderMarkdown, renderMarkdown,
...@@ -174,6 +175,7 @@ export default { ...@@ -174,6 +175,7 @@ export default {
:is-loading="loading" :is-loading="loading"
:predefined-prompts="$options.i18n.predefinedPrompts" :predefined-prompts="$options.i18n.predefinedPrompts"
:experiment-help-page-url="$options.experimentHelpPagePath" :experiment-help-page-url="$options.experimentHelpPagePath"
:badge-type="glFeatures.duoChatBeta ? 'beta' : 'experiment'"
:badge-help-page-url="$options.experimentHelpPagePath" :badge-help-page-url="$options.experimentHelpPagePath"
:tool-name="toolName" :tool-name="toolName"
@send-chat-prompt="onSendChatPrompt" @send-chat-prompt="onSendChatPrompt"
......
---
name: duo_chat_beta
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136059
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/430071
milestone: '16.6'
type: development
group: group::ai framework
default_enabled: false
...@@ -27,6 +27,8 @@ def add_gon_variables ...@@ -27,6 +27,8 @@ def add_gon_variables
gon.payment_form_url = ::Gitlab::Routing.url_helpers.subscription_portal_payment_form_url gon.payment_form_url = ::Gitlab::Routing.url_helpers.subscription_portal_payment_form_url
gon.payment_validation_form_id = ::Gitlab::SubscriptionPortal::PAYMENT_VALIDATION_FORM_ID gon.payment_validation_form_id = ::Gitlab::SubscriptionPortal::PAYMENT_VALIDATION_FORM_ID
end end
push_frontend_feature_flag(:duo_chat_beta)
end end
# Exposes if a licensed feature is available. # Exposes if a licensed feature is available.
......
...@@ -44,10 +44,11 @@ describe('GitLab Duo Chat', () => { ...@@ -44,10 +44,11 @@ describe('GitLab Duo Chat', () => {
const chatMutationHandlerMock = jest.fn().mockResolvedValue(MOCK_TANUKI_BOT_MUTATATION_RES); const chatMutationHandlerMock = jest.fn().mockResolvedValue(MOCK_TANUKI_BOT_MUTATATION_RES);
const queryHandlerMock = jest.fn().mockResolvedValue(MOCK_CHAT_CACHED_MESSAGES_RES); const queryHandlerMock = jest.fn().mockResolvedValue(MOCK_CHAT_CACHED_MESSAGES_RES);
const createComponent = ( const createComponent = ({
initialState = {}, initialState = {},
propsData = { userId: MOCK_USER_ID, resourceId: MOCK_RESOURCE_ID }, propsData = { userId: MOCK_USER_ID, resourceId: MOCK_RESOURCE_ID },
) => { glFeatures = { duoChatBeta: false },
} = {}) => {
const store = new Vuex.Store({ const store = new Vuex.Store({
actions: actionSpies, actions: actionSpies,
state: { state: {
...@@ -65,6 +66,9 @@ describe('GitLab Duo Chat', () => { ...@@ -65,6 +66,9 @@ describe('GitLab Duo Chat', () => {
store, store,
apolloProvider, apolloProvider,
propsData, propsData,
provide: {
glFeatures,
},
}); });
}; };
...@@ -95,6 +99,18 @@ describe('GitLab Duo Chat', () => { ...@@ -95,6 +99,18 @@ describe('GitLab Duo Chat', () => {
it('renders the DuoChat component', () => { it('renders the DuoChat component', () => {
expect(findGlDuoChat().exists()).toBe(true); expect(findGlDuoChat().exists()).toBe(true);
}); });
it.each`
isFlagEnabled | expectedPropValue
${true} | ${'beta'}
${false} | ${'experiment'}
`(
'sets correct `badge-type` prop on the chat compnent when feature flag is $isFlagEnabled',
({ isFlagEnabled, expectedPropValue }) => {
createComponent({ glFeatures: { duoChatBeta: isFlagEnabled } });
expect(findGlDuoChat().props('badgeType')).toBe(expectedPropValue);
},
);
}); });
describe('events handling', () => { describe('events handling', () => {
...@@ -138,7 +154,7 @@ describe('GitLab Duo Chat', () => { ...@@ -138,7 +154,7 @@ describe('GitLab Duo Chat', () => {
`( `(
'calls correct GraphQL mutation with fallback to userId when input is submitted and feature flag is $isFlagEnabled', 'calls correct GraphQL mutation with fallback to userId when input is submitted and feature flag is $isFlagEnabled',
async ({ expectedMutation } = {}) => { async ({ expectedMutation } = {}) => {
createComponent({}, { userId: MOCK_USER_ID, resourceId }); createComponent({ propsData: { userId: MOCK_USER_ID, resourceId } });
findGlDuoChat().vm.$emit('send-chat-prompt', MOCK_USER_MESSAGE.msg); findGlDuoChat().vm.$emit('send-chat-prompt', MOCK_USER_MESSAGE.msg);
await nextTick(); await nextTick();
...@@ -154,7 +170,10 @@ describe('GitLab Duo Chat', () => { ...@@ -154,7 +170,10 @@ describe('GitLab Duo Chat', () => {
it('once response arrives via GraphQL subscription with userId fallback calls addDuoChatMessage', () => { it('once response arrives via GraphQL subscription with userId fallback calls addDuoChatMessage', () => {
subscriptionHandlerMock.mockClear(); subscriptionHandlerMock.mockClear();
createComponent({ loading: true }, { userId: MOCK_USER_ID, resourceId }); createComponent({
initialState: { loading: true },
propsData: { userId: MOCK_USER_ID, resourceId },
});
expect(subscriptionHandlerMock).toHaveBeenNthCalledWith(1, { expect(subscriptionHandlerMock).toHaveBeenNthCalledWith(1, {
userId: MOCK_USER_ID, userId: MOCK_USER_ID,
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册