diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-08 09:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-08 09:09:24 +0300 |
commit | dabcc5d12d22ca30d83c986d6ca0b9b81e7ccbfc (patch) | |
tree | 402520b6779be27a17265dd10b978836e7955e53 /spec | |
parent | 72db8879531eb432b1d3b6957477543d59d94c49 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
8 files changed, 146 insertions, 5 deletions
diff --git a/spec/frontend/organizations/shared/utils_spec.js b/spec/frontend/organizations/shared/utils_spec.js index 2912db739c3..778a18ab2bc 100644 --- a/spec/frontend/organizations/shared/utils_spec.js +++ b/spec/frontend/organizations/shared/utils_spec.js @@ -29,7 +29,11 @@ describe('formatGroups', () => { const formattedGroups = formatGroups(organizationGroups.nodes); const [firstFormattedGroup] = formattedGroups; - expect(firstFormattedGroup.id).toBe(getIdFromGraphQLId(firstMockGroup.id)); + expect(firstFormattedGroup).toMatchObject({ + id: getIdFromGraphQLId(firstMockGroup.id), + editPath: `${firstFormattedGroup.webUrl}/-/edit`, + availableActions: [ACTION_EDIT, ACTION_DELETE], + }); expect(formattedGroups.length).toBe(organizationGroups.nodes.length); }); }); diff --git a/spec/frontend/vue_shared/components/confirm_danger/confirm_danger_modal_spec.js b/spec/frontend/vue_shared/components/confirm_danger/confirm_danger_modal_spec.js index 0b5c8d9afc3..53218d794c7 100644 --- a/spec/frontend/vue_shared/components/confirm_danger/confirm_danger_modal_spec.js +++ b/spec/frontend/vue_shared/components/confirm_danger/confirm_danger_modal_spec.js @@ -31,6 +31,7 @@ describe('Confirm Danger Modal', () => { propsData: { modalId, phrase, + visible: false, }, provide, stubs: { GlSprintf }, @@ -103,4 +104,16 @@ describe('Confirm Danger Modal', () => { expect(wrapper.emitted('confirm')).not.toBeUndefined(); }); }); + + describe('v-model', () => { + it('emit `change` event', () => { + findModal().vm.$emit('change', true); + + expect(wrapper.emitted('change')).toEqual([[true]]); + }); + + it('sets `visible` prop', () => { + expect(findModal().props('visible')).toBe(false); + }); + }); }); diff --git a/spec/frontend/vue_shared/components/groups_list/groups_list_item_spec.js b/spec/frontend/vue_shared/components/groups_list/groups_list_item_spec.js index 877de4f4695..cba9f78790d 100644 --- a/spec/frontend/vue_shared/components/groups_list/groups_list_item_spec.js +++ b/spec/frontend/vue_shared/components/groups_list/groups_list_item_spec.js @@ -9,6 +9,9 @@ import { } from '~/visibility_level/constants'; import UserAccessRoleBadge from '~/vue_shared/components/user_access_role_badge.vue'; import { ACCESS_LEVEL_LABELS } from '~/access_level/constants'; +import ListActions from '~/vue_shared/components/list_actions/list_actions.vue'; +import { ACTION_EDIT, ACTION_DELETE } from '~/vue_shared/components/list_actions/constants'; +import DangerConfirmModal from '~/vue_shared/components/confirm_danger/confirm_danger_modal.vue'; import { groups } from './mock_data'; describe('GroupsListItem', () => { @@ -30,6 +33,8 @@ describe('GroupsListItem', () => { const findAvatarLabeled = () => wrapper.findComponent(GlAvatarLabeled); const findGroupDescription = () => wrapper.findByTestId('group-description'); const findVisibilityIcon = () => findAvatarLabeled().findComponent(GlIcon); + const findListActions = () => wrapper.findComponent(ListActions); + const findConfirmationModal = () => wrapper.findComponent(DangerConfirmModal); it('renders group avatar', () => { createComponent(); @@ -179,4 +184,68 @@ describe('GroupsListItem', () => { expect(wrapper.findByTestId('group-icon').exists()).toBe(false); }); }); + + describe('when group has actions', () => { + beforeEach(() => { + createComponent(); + }); + + it('displays actions dropdown', () => { + expect(findListActions().props()).toMatchObject({ + actions: { + [ACTION_EDIT]: { + href: group.editPath, + }, + [ACTION_DELETE]: { + action: expect.any(Function), + }, + }, + availableActions: [ACTION_EDIT, ACTION_DELETE], + }); + }); + + describe('when delete action is fired', () => { + beforeEach(() => { + findListActions().props('actions')[ACTION_DELETE].action(); + }); + + it('displays confirmation modal with correct props', () => { + expect(findConfirmationModal().props()).toMatchObject({ + visible: true, + phrase: group.fullName, + }); + }); + + describe('when deletion is confirmed', () => { + beforeEach(() => { + findConfirmationModal().vm.$emit('confirm'); + }); + + it('emits `delete` event', () => { + expect(wrapper.emitted('delete')).toMatchObject([[group]]); + }); + }); + }); + }); + + describe('when group does not have actions', () => { + beforeEach(() => { + createComponent({ + propsData: { + group: { + ...group, + availableActions: [], + }, + }, + }); + }); + + it('does not display actions dropdown', () => { + expect(findListActions().exists()).toBe(false); + }); + + it('does not display confirmation modal', () => { + expect(findConfirmationModal().exists()).toBe(false); + }); + }); }); diff --git a/spec/frontend/vue_shared/components/groups_list/groups_list_spec.js b/spec/frontend/vue_shared/components/groups_list/groups_list_spec.js index c65aa347bcf..ec6a1dc9576 100644 --- a/spec/frontend/vue_shared/components/groups_list/groups_list_spec.js +++ b/spec/frontend/vue_shared/components/groups_list/groups_list_spec.js @@ -31,4 +31,18 @@ describe('GroupsList', () => { })), ); }); + + describe('when `GroupsListItem` emits `delete` event', () => { + const [firstGroup] = defaultPropsData.groups; + + beforeEach(() => { + createComponent(); + + wrapper.findComponent(GroupsListItem).vm.$emit('delete', firstGroup); + }); + + it('emits `delete` event', () => { + expect(wrapper.emitted('delete')).toEqual([[firstGroup]]); + }); + }); }); diff --git a/spec/frontend/vue_shared/components/groups_list/mock_data.js b/spec/frontend/vue_shared/components/groups_list/mock_data.js index 0dad27f8311..08ee962892c 100644 --- a/spec/frontend/vue_shared/components/groups_list/mock_data.js +++ b/spec/frontend/vue_shared/components/groups_list/mock_data.js @@ -1,3 +1,5 @@ +import { ACTION_EDIT, ACTION_DELETE } from '~/vue_shared/components/list_actions/constants'; + export const groups = [ { id: 1, @@ -14,6 +16,8 @@ export const groups = [ accessLevel: { integerValue: 10, }, + editPath: 'http://127.0.0.1:3000/groups/gitlab-org/-/edit', + availableActions: [ACTION_EDIT, ACTION_DELETE], }, { id: 2, @@ -31,5 +35,7 @@ export const groups = [ accessLevel: { integerValue: 20, }, + editPath: 'http://127.0.0.1:3000/groups/gitlab-org/test-subgroup/-/edit', + availableActions: [ACTION_EDIT, ACTION_DELETE], }, ]; diff --git a/spec/frontend/vue_shared/components/markdown/apply_suggestion_spec.js b/spec/frontend/vue_shared/components/markdown/apply_suggestion_spec.js index e3d896ca93e..cdbdbfab9d1 100644 --- a/spec/frontend/vue_shared/components/markdown/apply_suggestion_spec.js +++ b/spec/frontend/vue_shared/components/markdown/apply_suggestion_spec.js @@ -14,6 +14,7 @@ describe('Apply Suggestion component', () => { const findTextArea = () => wrapper.findComponent(GlFormTextarea); const findApplyButton = () => wrapper.findComponent(GlButton); const findAlert = () => wrapper.findComponent(GlAlert); + const findHelpText = () => wrapper.find('span'); beforeEach(() => createWrapper()); @@ -41,6 +42,22 @@ describe('Apply Suggestion component', () => { }); }); + describe('help text', () => { + describe('when applying a single suggestion', () => { + it('renders the correct help text', () => { + expect(findHelpText().text()).toEqual('This also resolves this thread'); + }); + }); + + describe('when applying in batch', () => { + it('renders the correct help text', () => { + createWrapper({ batchSuggestionsCount: 3 }); + + expect(findHelpText().text()).toEqual('This also resolves all related threads'); + }); + }); + }); + describe('disabled', () => { it('disables the dropdown', () => { createWrapper({ disabled: true }); diff --git a/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js b/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js index 9768bc7a6dd..bc82357cb81 100644 --- a/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js +++ b/spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js @@ -219,12 +219,11 @@ describe('Suggestion Diff component', () => { describe('tooltip message for apply button', () => { const findTooltip = () => getBinding(findApplyButton().element, 'gl-tooltip'); - it('renders correct tooltip message when button is applicable', () => { - createComponent({ batchSuggestionsCount: 0 }); + it('renders no tooltip message when button is applicable', () => { + createComponent({ batchSuggestionsCount: 1, isBatched: true }); const tooltip = findTooltip(); - expect(tooltip.modifiers.viewport).toBe(true); - expect(tooltip.value).toBe('This also resolves this thread'); + expect(tooltip.value).toBe(false); }); it('renders the inapplicable reason in the tooltip when button is not applicable', () => { diff --git a/spec/lib/gitlab/database/click_house_client_spec.rb b/spec/lib/gitlab/database/click_house_client_spec.rb index 8e4a474cc9b..6e63ae56557 100644 --- a/spec/lib/gitlab/database/click_house_client_spec.rb +++ b/spec/lib/gitlab/database/click_house_client_spec.rb @@ -115,4 +115,23 @@ RSpec.describe 'ClickHouse::Client', :click_house, feature_category: :database d end end end + + describe 'logging' do + let(:query_string) { "SELECT * FROM events WHERE id IN (4, 5, 6)" } + + context 'on dev and test environments' do + it 'logs the un-redacted query' do + expect(ClickHouse::Client.configuration.logger).to receive(:info).with({ + query: query_string, + correlation_id: a_kind_of(String) + }) + + ClickHouse::Client.select(query_string, :main) + end + + it 'has a ClickHouse logger' do + expect(ClickHouse::Client.configuration.logger).to be_a(ClickHouse::Logger) + end + end + end end |