From 0c872e02b2c822e3397515ec324051ff540f0cd5 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Dec 2022 14:22:11 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-7-stable-ee --- .../diffs/components/diff_discussion_reply_spec.js | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'spec/frontend/diffs/components/diff_discussion_reply_spec.js') diff --git a/spec/frontend/diffs/components/diff_discussion_reply_spec.js b/spec/frontend/diffs/components/diff_discussion_reply_spec.js index 5ccd2002462..bf4a1a1c1f7 100644 --- a/spec/frontend/diffs/components/diff_discussion_reply_spec.js +++ b/spec/frontend/diffs/components/diff_discussion_reply_spec.js @@ -1,10 +1,12 @@ import { shallowMount } from '@vue/test-utils'; +import { GlButton } from '@gitlab/ui'; import Vue from 'vue'; import Vuex from 'vuex'; import DiffDiscussionReply from '~/diffs/components/diff_discussion_reply.vue'; -import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue'; import NoteSignedOutWidget from '~/notes/components/note_signed_out_widget.vue'; +import { START_THREAD } from '~/diffs/i18n'; + Vue.use(Vuex); describe('DiffDiscussionReply', () => { @@ -58,14 +60,42 @@ describe('DiffDiscussionReply', () => { expect(wrapper.find('#test-form').exists()).toBe(true); }); - it('should render a reply placeholder if there is no form', () => { + it('should render a reply placeholder button if there is no form', () => { createComponent({ renderReplyPlaceholder: true, hasForm: false, }); - expect(wrapper.findComponent(ReplyPlaceholder).exists()).toBe(true); + expect(wrapper.findComponent(GlButton).text()).toBe(START_THREAD); }); + + it.each` + userCanReply | hasForm | renderReplyPlaceholder | showButton + ${false} | ${false} | ${false} | ${false} + ${true} | ${false} | ${false} | ${false} + ${true} | ${true} | ${false} | ${false} + ${true} | ${true} | ${true} | ${false} + ${true} | ${false} | ${true} | ${true} + ${false} | ${false} | ${true} | ${false} + `( + 'reply button existence is `$showButton` when userCanReply is `$userCanReply`, hasForm is `$hasForm` and renderReplyPlaceholder is `$renderReplyPlaceholder`', + ({ userCanReply, hasForm, renderReplyPlaceholder, showButton }) => { + getters = { + userCanReply: () => userCanReply, + }; + + store = new Vuex.Store({ + getters, + }); + + createComponent({ + renderReplyPlaceholder, + hasForm, + }); + + expect(wrapper.findComponent(GlButton).exists()).toBe(showButton); + }, + ); }); it('renders a signed out widget when user is not logged in', () => { -- cgit v1.2.3