summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-27 15:08:31 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-27 15:08:31 +0000
commite77cb2465fa34b8883987206a42648603d5bf073 (patch)
treef2bbff57b35c6a0c97309056a795e446a3e5b139 /spec
parente9de373448d0ae4dd330c131db2366a30e0c025d (diff)
downloadgitlab-ce-e77cb2465fa34b8883987206a42648603d5bf073.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/issues/form_spec.rb13
-rw-r--r--spec/features/issues/user_creates_issue_spec.rb6
-rw-r--r--spec/features/jira_connect/branches_spec.rb2
-rw-r--r--spec/features/projects/environments/environment_spec.rb30
-rw-r--r--spec/frontend/editor/components/source_editor_toolbar_button_spec.js27
-rw-r--r--spec/frontend/environments/environment_details/components/deployment_actions_spec.js115
-rw-r--r--spec/frontend/environments/environment_details/page_spec.js25
-rw-r--r--spec/frontend/environments/helpers/__snapshots__/deployment_data_transformation_helper_spec.js.snap25
-rw-r--r--spec/frontend/issues/new/components/type_select_spec.js141
-rw-r--r--spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js2
-rw-r--r--spec/helpers/issuables_helper_spec.rb33
-rw-r--r--spec/helpers/issues_helper_spec.rb12
-rw-r--r--spec/models/concerns/has_user_type_spec.rb14
-rw-r--r--spec/support/shared_examples/quick_actions/issue/promote_to_incident_quick_action_shared_examples.rb6
-rw-r--r--spec/workers/users/deactivate_dormant_users_worker_spec.rb3
15 files changed, 391 insertions, 63 deletions
diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb
index 85ca3d91a1a..a9605b214bd 100644
--- a/spec/features/issues/form_spec.rb
+++ b/spec/features/issues/form_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do
include ActionView::Helpers::JavaScriptHelper
+ include ListboxHelpers
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
@@ -249,19 +250,15 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do
describe 'displays issue type options in the dropdown' do
shared_examples 'type option is visible' do |label:, identifier:|
it "shows #{identifier} option", :aggregate_failures do
- page.within('[data-testid="issue-type-select-dropdown"]') do
- expect(page).to have_selector(%([data-testid="issue-type-#{identifier}-icon"]))
- expect(page).to have_content(label)
- end
+ wait_for_requests
+ expect_listbox_item(label)
end
end
shared_examples 'type option is missing' do |label:, identifier:|
it "does not show #{identifier} option", :aggregate_failures do
- page.within('[data-testid="issue-type-select-dropdown"]') do
- expect(page).not_to have_selector(%([data-testid="issue-type-#{identifier}-icon"]))
- expect(page).not_to have_content(label)
- end
+ wait_for_requests
+ expect_no_listbox_item(label)
end
end
diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb
index c5d0791dc57..2377a2ba3c7 100644
--- a/spec/features/issues/user_creates_issue_spec.rb
+++ b/spec/features/issues/user_creates_issue_spec.rb
@@ -184,7 +184,7 @@ RSpec.describe "User creates issue", feature_category: :team_planning do
end
it 'pre-fills the issue type dropdown with issue type' do
- expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).to have_content('Issue')
+ expect(find('.js-issuable-type-filter-dropdown-wrap .gl-button-text')).to have_content('Issue')
end
it 'does not hide the milestone select' do
@@ -200,7 +200,7 @@ RSpec.describe "User creates issue", feature_category: :team_planning do
end
it 'does not pre-fill the issue type dropdown with incident type' do
- expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).not_to have_content('Incident')
+ expect(find('.js-issuable-type-filter-dropdown-wrap .gl-button-text')).not_to have_content('Incident')
end
it 'shows the milestone select' do
@@ -257,7 +257,7 @@ RSpec.describe "User creates issue", feature_category: :team_planning do
end
it 'pre-fills the issue type dropdown with incident type' do
- expect(find('.js-issuable-type-filter-dropdown-wrap .dropdown-toggle-text')).to have_content('Incident')
+ expect(find('.js-issuable-type-filter-dropdown-wrap .gl-button-text')).to have_content('Incident')
end
it 'hides the epic select' do
diff --git a/spec/features/jira_connect/branches_spec.rb b/spec/features/jira_connect/branches_spec.rb
index c90c0d2dda9..25dc14a1dc9 100644
--- a/spec/features/jira_connect/branches_spec.rb
+++ b/spec/features/jira_connect/branches_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe 'Create GitLab branches from Jira', :js, feature_category: :integ
select_listbox_item(source_branch)
fill_in 'Branch name', with: new_branch
- click_on 'Create branch'
+ click_button 'Create branch'
expect(page).to have_text('New branch was successfully created. You can now close this window and return to Jira.')
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb
index 91401d19fd1..527a146ff73 100644
--- a/spec/features/projects/environments/environment_spec.rb
+++ b/spec/features/projects/environments/environment_spec.rb
@@ -94,6 +94,36 @@ RSpec.describe 'Environment', feature_category: :projects do
expect(page).to have_link("#{build.name} (##{build.id})")
end
end
+
+ context 'with related deployable present' do
+ let_it_be(:previous_pipeline) { create(:ci_pipeline, project: project) }
+
+ let_it_be(:previous_build) do
+ create(:ci_build, :success, pipeline: previous_pipeline, environment: environment.name)
+ end
+
+ let_it_be(:previous_deployment) do
+ create(:deployment, :success, environment: environment, deployable: previous_build)
+ end
+
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be(:build) { create(:ci_build, pipeline: pipeline, environment: environment.name) }
+
+ let_it_be(:deployment) do
+ create(:deployment, :success, environment: environment, deployable: build)
+ end
+
+ before do
+ visit_environment(environment)
+ end
+
+ it 'shows deployment information and buttons', :js do
+ wait_for_requests
+ expect(page).to have_button('Re-deploy to environment')
+ expect(page).to have_button('Rollback environment')
+ expect(page).to have_link("#{build.name} (##{build.id})")
+ end
+ end
end
end
diff --git a/spec/frontend/editor/components/source_editor_toolbar_button_spec.js b/spec/frontend/editor/components/source_editor_toolbar_button_spec.js
index 79692ab4557..a94ebdfd827 100644
--- a/spec/frontend/editor/components/source_editor_toolbar_button_spec.js
+++ b/spec/frontend/editor/components/source_editor_toolbar_button_spec.js
@@ -33,7 +33,7 @@ describe('Source Editor Toolbar button', () => {
it('does not render the button if the props have not been passed', () => {
createComponent({});
- expect(findButton().vm).toBeUndefined();
+ expect(findButton().exists()).toBe(false);
});
it('renders a default button without props', async () => {
@@ -107,34 +107,31 @@ describe('Source Editor Toolbar button', () => {
});
describe('click handler', () => {
- let clickEvent;
-
- beforeEach(() => {
- clickEvent = new Event('click');
- });
-
it('fires the click handler on the button when available', async () => {
- const spy = jest.fn();
+ const clickSpy = jest.fn();
+ const clickEvent = new Event('click');
createComponent({
button: {
- onClick: spy,
+ onClick: clickSpy,
},
});
- expect(spy).not.toHaveBeenCalled();
+ expect(wrapper.emitted('click')).toEqual(undefined);
findButton().vm.$emit('click', clickEvent);
await nextTick();
- expect(spy).toHaveBeenCalledWith(clickEvent);
+
+ expect(wrapper.emitted('click')).toEqual([[clickEvent]]);
+ expect(clickSpy).toHaveBeenCalledWith(clickEvent);
});
+
it('emits the "click" event, passing the event itself', async () => {
createComponent();
- jest.spyOn(wrapper.vm, '$emit');
- expect(wrapper.vm.$emit).not.toHaveBeenCalled();
+ expect(wrapper.emitted('click')).toEqual(undefined);
- findButton().vm.$emit('click', clickEvent);
+ findButton().vm.$emit('click');
await nextTick();
- expect(wrapper.vm.$emit).toHaveBeenCalledWith('click', clickEvent);
+ expect(wrapper.emitted('click')).toHaveLength(1);
});
});
});
diff --git a/spec/frontend/environments/environment_details/components/deployment_actions_spec.js b/spec/frontend/environments/environment_details/components/deployment_actions_spec.js
index 725c8c6479e..4aac25bc8b3 100644
--- a/spec/frontend/environments/environment_details/components/deployment_actions_spec.js
+++ b/spec/frontend/environments/environment_details/components/deployment_actions_spec.js
@@ -1,8 +1,15 @@
+import Vue from 'vue';
+import VueApollo from 'vue-apollo';
+import { GlButton } from '@gitlab/ui';
import DeploymentActions from '~/environments/environment_details/components/deployment_actions.vue';
import { mountExtended } from 'helpers/vue_test_utils_helper';
+import { translations } from '~/environments/environment_details/constants';
import ActionsComponent from '~/environments/components/environment_actions.vue';
+import createMockApollo from '../../../__helpers__/mock_apollo_helper';
+import waitForPromises from '../../../__helpers__/wait_for_promises';
describe('~/environments/environment_details/components/deployment_actions.vue', () => {
+ Vue.use(VueApollo);
let wrapper;
const actionsData = [
@@ -14,34 +21,112 @@ describe('~/environments/environment_details/components/deployment_actions.vue',
},
];
- const createWrapper = ({ actions }) => {
+ const rollbackData = {
+ id: '123',
+ name: 'enironment-name',
+ lastDeployment: {
+ commit: {
+ shortSha: 'abcd1234',
+ },
+ isLast: true,
+ },
+ retryUrl: 'deployment/retry',
+ };
+
+ const mockSetEnvironmentToRollback = jest.fn();
+ const mockResolvers = {
+ Mutation: {
+ setEnvironmentToRollback: mockSetEnvironmentToRollback,
+ },
+ };
+ const createWrapper = ({ actions, rollback }) => {
+ const mockApollo = createMockApollo([], mockResolvers);
return mountExtended(DeploymentActions, {
+ apolloProvider: mockApollo,
propsData: {
actions,
+ rollback,
},
});
};
- describe('when there is no actions provided', () => {
- beforeEach(() => {
- wrapper = createWrapper({ actions: [] });
+ const findRollbackButton = () => wrapper.findComponent(GlButton);
+
+ describe('deployment actions', () => {
+ describe('when there is no actions provided', () => {
+ beforeEach(() => {
+ wrapper = createWrapper({ actions: [] });
+ });
+
+ it('should not render actions component', () => {
+ const actionsComponent = wrapper.findComponent(ActionsComponent);
+ expect(actionsComponent.exists()).toBe(false);
+ });
});
- it('should not render actions component', () => {
- const actionsComponent = wrapper.findComponent(ActionsComponent);
- expect(actionsComponent.exists()).toBe(false);
+ describe('when there are actions provided', () => {
+ beforeEach(() => {
+ wrapper = createWrapper({ actions: actionsData });
+ });
+
+ it('should render actions component', () => {
+ const actionsComponent = wrapper.findComponent(ActionsComponent);
+ expect(actionsComponent.exists()).toBe(true);
+ expect(actionsComponent.props().actions).toBe(actionsData);
+ });
});
});
- describe('when there are actions provided', () => {
- beforeEach(() => {
- wrapper = createWrapper({ actions: actionsData });
+ describe('rollback action', () => {
+ describe('when there is no rollback data available', () => {
+ it('should not show a rollback button', () => {
+ wrapper = createWrapper({ actions: [] });
+ const button = findRollbackButton();
+ expect(button.exists()).toBe(false);
+ });
});
- it('should render actions component', () => {
- const actionsComponent = wrapper.findComponent(ActionsComponent);
- expect(actionsComponent.exists()).toBe(true);
- expect(actionsComponent.props().actions).toBe(actionsData);
- });
+ describe.each([
+ { isLast: true, buttonTitle: translations.redeployButtonTitle, icon: 'repeat' },
+ { isLast: false, buttonTitle: translations.rollbackButtonTitle, icon: 'redo' },
+ ])(
+ `when there is a rollback data available and the deployment isLast=$isLast`,
+ ({ isLast, buttonTitle, icon }) => {
+ let rollback;
+ beforeEach(() => {
+ const lastDeployment = { ...rollbackData.lastDeployment, isLast };
+ rollback = { ...rollbackData };
+ rollback.lastDeployment = lastDeployment;
+ wrapper = createWrapper({ actions: [], rollback });
+ });
+
+ it('should show the rollback button', () => {
+ const button = findRollbackButton();
+ expect(button.exists()).toBe(true);
+ });
+
+ it(`the rollback button should have "${icon}" icon`, () => {
+ const button = findRollbackButton();
+ expect(button.props().icon).toBe(icon);
+ });
+
+ it(`the rollback button should have "${buttonTitle}" title`, () => {
+ const button = findRollbackButton();
+ expect(button.attributes().title).toBe(buttonTitle);
+ });
+
+ it(`the rollback button click should send correct mutation`, async () => {
+ const button = findRollbackButton();
+ button.vm.$emit('click');
+ await waitForPromises();
+ expect(mockSetEnvironmentToRollback).toHaveBeenCalledWith(
+ expect.anything(),
+ { environment: rollback },
+ expect.anything(),
+ expect.anything(),
+ );
+ });
+ },
+ );
});
});
diff --git a/spec/frontend/environments/environment_details/page_spec.js b/spec/frontend/environments/environment_details/page_spec.js
index 3a1a3238abe..0e1d7221a7d 100644
--- a/spec/frontend/environments/environment_details/page_spec.js
+++ b/spec/frontend/environments/environment_details/page_spec.js
@@ -15,14 +15,31 @@ describe('~/environments/environment_details/page.vue', () => {
let wrapper;
+ const emptyEnvironmentToRollbackData = { id: '', name: '', lastDeployment: null, retryUrl: '' };
+ const environmentToRollbackMock = jest.fn();
+
+ const mockResolvers = {
+ Query: {
+ environmentToRollback: environmentToRollbackMock,
+ },
+ };
+
const defaultWrapperParameters = {
resolvedData: resolvedEnvironmentDetails,
+ environmentToRollbackData: emptyEnvironmentToRollbackData,
};
- const createWrapper = ({ resolvedData } = defaultWrapperParameters) => {
- const mockApollo = createMockApollo([
- [getEnvironmentDetails, jest.fn().mockResolvedValue(resolvedData)],
- ]);
+ const createWrapper = ({
+ resolvedData,
+ environmentToRollbackData,
+ } = defaultWrapperParameters) => {
+ const mockApollo = createMockApollo(
+ [[getEnvironmentDetails, jest.fn().mockResolvedValue(resolvedData)]],
+ mockResolvers,
+ );
+ environmentToRollbackMock.mockReturnValue(
+ environmentToRollbackData || emptyEnvironmentToRollbackData,
+ );
return mountExtended(EnvironmentsDetailPage, {
apolloProvider: mockApollo,
diff --git a/spec/frontend/environments/helpers/__snapshots__/deployment_data_transformation_helper_spec.js.snap b/spec/frontend/environments/helpers/__snapshots__/deployment_data_transformation_helper_spec.js.snap
index 326a28bd769..0462b614ee2 100644
--- a/spec/frontend/environments/helpers/__snapshots__/deployment_data_transformation_helper_spec.js.snap
+++ b/spec/frontend/environments/helpers/__snapshots__/deployment_data_transformation_helper_spec.js.snap
@@ -31,6 +31,29 @@ Object {
"label": "deploy-prod (#860)",
"webPath": "/gitlab-org/pipelinestest/-/jobs/860",
},
+ "rollback": Object {
+ "id": "gid://gitlab/Deployment/76",
+ "lastDeployment": Object {
+ "commit": Object {
+ "author": Object {
+ "avatarUrl": "/uploads/-/system/user/avatar/1/avatar.png",
+ "id": "gid://gitlab/User/1",
+ "name": "Administrator",
+ "webUrl": "http://gdk.test:3000/root",
+ },
+ "authorEmail": "admin@example.com",
+ "authorGravatar": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "authorName": "Administrator",
+ "id": "gid://gitlab/CommitPresenter/0cb48dd5deddb7632fd7c3defb16075fc6c3ca74",
+ "message": "Update .gitlab-ci.yml file",
+ "shortId": "0cb48dd5",
+ "webUrl": "http://gdk.test:3000/gitlab-org/pipelinestest/-/commit/0cb48dd5deddb7632fd7c3defb16075fc6c3ca74",
+ },
+ "isLast": false,
+ },
+ "name": undefined,
+ "retryUrl": "/gitlab-org/pipelinestest/-/jobs/860/retry",
+ },
"status": "success",
"triggerer": Object {
"avatarUrl": "/uploads/-/system/user/avatar/1/avatar.png",
@@ -62,6 +85,7 @@ Object {
"deployed": "2022-10-17T07:44:43Z",
"id": "31",
"job": undefined,
+ "rollback": null,
"status": "success",
"triggerer": Object {
"avatarUrl": "/uploads/-/system/user/avatar/1/avatar.png",
@@ -93,6 +117,7 @@ Object {
"deployed": "",
"id": "31",
"job": null,
+ "rollback": null,
"status": "success",
"triggerer": Object {
"avatarUrl": "/uploads/-/system/user/avatar/1/avatar.png",
diff --git a/spec/frontend/issues/new/components/type_select_spec.js b/spec/frontend/issues/new/components/type_select_spec.js
new file mode 100644
index 00000000000..a25ace10fe7
--- /dev/null
+++ b/spec/frontend/issues/new/components/type_select_spec.js
@@ -0,0 +1,141 @@
+import { GlCollapsibleListbox, GlIcon } from '@gitlab/ui';
+import { mount } from '@vue/test-utils';
+import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
+import * as urlUtility from '~/lib/utils/url_utility';
+import TypeSelect from '~/issues/new/components/type_select.vue';
+import { TYPE_ISSUE, TYPE_INCIDENT } from '~/issues/constants';
+import { __ } from '~/locale';
+
+const issuePath = 'issues/new';
+const incidentPath = 'issues/new?issuable_template=incident';
+const tracking = {
+ action: 'select_issue_type_incident',
+ label: 'select_issue_type_incident_dropdown_option',
+};
+
+const defaultProps = {
+ selectedType: '',
+ isIssueAllowed: true,
+ isIncidentAllowed: true,
+ issuePath,
+ incidentPath,
+};
+
+const issue = {
+ value: TYPE_ISSUE,
+ text: __('Issue'),
+ icon: 'issue-type-issue',
+ href: issuePath,
+};
+const incident = {
+ value: TYPE_INCIDENT,
+ text: __('Incident'),
+ icon: 'issue-type-incident',
+ href: incidentPath,
+ tracking,
+};
+
+describe('Issue type select component', () => {
+ let wrapper;
+ let trackingSpy;
+ let navigationSpy;
+
+ const createComponent = (props = {}) => {
+ wrapper = mount(TypeSelect, {
+ propsData: { ...defaultProps, ...props },
+ });
+ };
+
+ const findListbox = () => wrapper.findComponent(GlCollapsibleListbox);
+ const findAllIcons = () => wrapper.findAllComponents(GlIcon);
+ const findListboxItemIcon = () => findAllIcons().at(2);
+
+ describe('initial state', () => {
+ it('renders listbox with the correct header text', () => {
+ createComponent();
+
+ expect(findListbox().props('headerText')).toBe(TypeSelect.i18n.selectType);
+ });
+
+ it.each`
+ selectedType | toggleText
+ ${''} | ${TypeSelect.i18n.selectType}
+ ${TYPE_ISSUE} | ${TypeSelect.i18n.issuableType[TYPE_ISSUE]}
+ ${TYPE_INCIDENT} | ${TypeSelect.i18n.issuableType[TYPE_INCIDENT]}
+ `(
+ 'renders listbox with the correct toggle text when selectedType is "$selectedType"',
+ ({ selectedType, toggleText }) => {
+ createComponent({ selectedType });
+
+ expect(findListbox().props('toggleText')).toBe(toggleText);
+ },
+ );
+
+ it.each`
+ isIssueAllowed | isIncidentAllowed | items
+ ${true} | ${true} | ${[issue, incident]}
+ ${true} | ${false} | ${[issue]}
+ ${false} | ${true} | ${[incident]}
+ `(
+ 'renders listbox with the correct items when isIssueAllowed is "$isIssueAllowed" and isIncidentAllowed is "$isIncidentAllowed"',
+ ({ isIssueAllowed, isIncidentAllowed, items }) => {
+ createComponent({ isIssueAllowed, isIncidentAllowed });
+
+ expect(findListbox().props('items')).toMatchObject(items);
+ },
+ );
+
+ it.each`
+ isIssueAllowed | isIncidentAllowed | icon
+ ${true} | ${false} | ${issue.icon}
+ ${false} | ${true} | ${incident.icon}
+ `(
+ 'renders listbox item with the correct $icon icon',
+ ({ isIssueAllowed, isIncidentAllowed, icon }) => {
+ createComponent({ isIssueAllowed, isIncidentAllowed });
+ findListbox().vm.$emit('shown');
+
+ expect(findListboxItemIcon().props('name')).toBe(icon);
+ },
+ );
+ });
+
+ describe('on type selected', () => {
+ beforeEach(() => {
+ navigationSpy = jest.spyOn(urlUtility, 'visitUrl').mockReturnValue({});
+ trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
+ });
+
+ afterEach(() => {
+ unmockTracking();
+ navigationSpy.mockRestore();
+ });
+
+ it.each`
+ selectedType | expectedUrl
+ ${TYPE_ISSUE} | ${issuePath}
+ ${TYPE_INCIDENT} | ${incidentPath}
+ `('navigates to the $selectedType issuable page', ({ selectedType, expectedUrl }) => {
+ createComponent();
+ findListbox().vm.$emit('select', selectedType);
+
+ expect(navigationSpy).toHaveBeenCalledWith(expectedUrl);
+ });
+
+ it("doesn't call tracking APIs when tracking is not available for the issuable type", () => {
+ createComponent();
+ findListbox().vm.$emit('select', TYPE_ISSUE);
+
+ expect(trackingSpy).not.toHaveBeenCalled();
+ });
+
+ it('calls tracking APIs when tracking is available for the issuable type', () => {
+ createComponent();
+ findListbox().vm.$emit('select', TYPE_INCIDENT);
+
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, tracking.action, {
+ label: tracking.label,
+ });
+ });
+ });
+});
diff --git a/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js b/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js
index be3fee148da..261bfe14fd8 100644
--- a/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js
+++ b/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js
@@ -135,7 +135,7 @@ describe('Sidebar date Widget', () => {
it('uses a correct prop to set the initial date and first day of the week for GlDatePicker', () => {
expect(findDatePicker().props()).toMatchObject({
- value: null,
+ value: new Date(date),
autocomplete: 'off',
defaultDate: expect.any(Object),
firstDay: window.gon.first_day_of_week,
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index 7549e37d4fd..960a7e03e49 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -695,4 +695,37 @@ RSpec.describe IssuablesHelper, feature_category: :team_planning do
end
end
end
+
+ describe '#issuable_type_selector_data' do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:project) { create(:project) }
+
+ where(:issuable_type, :issuable_display_type, :is_issue_allowed, :is_incident_allowed) do
+ :issue | 'issue' | true | false
+ :incident | 'incident' | false | true
+ end
+
+ with_them do
+ let(:issuable) { build_stubbed(issuable_type) }
+
+ before do
+ allow(helper).to receive(:create_issue_type_allowed?).with(project, :issue).and_return(is_issue_allowed)
+ allow(helper).to receive(:create_issue_type_allowed?).with(project, :incident).and_return(is_incident_allowed)
+ assign(:project, project)
+ end
+
+ it 'returns the correct data for the issuable type selector' do
+ expected_data = {
+ selected_type: issuable_display_type,
+ is_issue_allowed: is_issue_allowed.to_s,
+ is_incident_allowed: is_incident_allowed.to_s,
+ issue_path: new_project_issue_path(project),
+ incident_path: new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident' } })
+ }
+
+ expect(helper.issuable_type_selector_data(issuable)).to match(expected_data)
+ end
+ end
+ end
end
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 994a1ff4f75..087e8d0ecb7 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -6,18 +6,6 @@ RSpec.describe IssuesHelper do
let_it_be(:project) { create(:project) }
let_it_be_with_reload(:issue) { create(:issue, project: project) }
- describe '#work_item_type_icon' do
- it 'returns icon of all standard base types' do
- WorkItems::Type.base_types.each do |type|
- expect(work_item_type_icon(type[0])).to eq "issue-type-#{type[0].to_s.dasherize}"
- end
- end
-
- it 'defaults to issue icon if type is unknown' do
- expect(work_item_type_icon('invalid')).to eq 'issue-type-issue'
- end
- end
-
describe '#award_user_list' do
it 'returns a comma-separated list of the first X users' do
user = build_stubbed(:user, name: 'Joe')
diff --git a/spec/models/concerns/has_user_type_spec.rb b/spec/models/concerns/has_user_type_spec.rb
index 03d2c267098..1b8199fec55 100644
--- a/spec/models/concerns/has_user_type_spec.rb
+++ b/spec/models/concerns/has_user_type_spec.rb
@@ -5,8 +5,9 @@ require 'spec_helper'
RSpec.describe User, feature_category: :system_access do
specify 'types consistency checks', :aggregate_failures do
expect(described_class::USER_TYPES.keys)
- .to match_array(%w[human ghost alert_bot project_bot support_bot service_user security_bot visual_review_bot
- migration_bot automation_bot security_policy_bot admin_bot suggested_reviewers_bot service_account])
+ .to match_array(%w[human human_deprecated ghost alert_bot project_bot support_bot service_user security_bot
+ visual_review_bot migration_bot automation_bot security_policy_bot admin_bot suggested_reviewers_bot
+ service_account])
expect(described_class::USER_TYPES).to include(*described_class::BOT_USER_TYPES)
expect(described_class::USER_TYPES).to include(*described_class::NON_INTERNAL_USER_TYPES)
expect(described_class::USER_TYPES).to include(*described_class::INTERNAL_USER_TYPES)
@@ -22,7 +23,13 @@ RSpec.describe User, feature_category: :system_access do
describe '.humans' do
it 'includes humans only' do
- expect(described_class.humans).to match_array([human])
+ expect(described_class.humans).to match_array([human, human_deprecated])
+ end
+ end
+
+ describe '.human' do
+ it 'includes humans only' do
+ expect(described_class.human).to match_array([human, human_deprecated])
end
end
@@ -69,6 +76,7 @@ RSpec.describe User, feature_category: :system_access do
describe '#human?' do
it 'is true for humans only' do
expect(human).to be_human
+ expect(human_deprecated).to be_human
expect(alert_bot).not_to be_human
expect(User.new).to be_human
end
diff --git a/spec/support/shared_examples/quick_actions/issue/promote_to_incident_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issue/promote_to_incident_quick_action_shared_examples.rb
index 3f1a98ca08e..7bd7500d546 100644
--- a/spec/support/shared_examples/quick_actions/issue/promote_to_incident_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/issue/promote_to_incident_quick_action_shared_examples.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
RSpec.shared_examples 'promote_to_incident quick action' do
+ include ListboxHelpers
+
describe '/promote_to_incident' do
context 'when issue can be promoted' do
it 'promotes issue to incident' do
@@ -52,9 +54,11 @@ RSpec.shared_examples 'promote_to_incident quick action' do
context 'when incident is selected for issue type' do
it 'promotes issue to incident' do
visit new_project_issue_path(project)
+ wait_for_requests
+
fill_in('Title', with: 'Title')
find('.js-issuable-type-filter-dropdown-wrap').click
- click_link('Incident')
+ select_listbox_item(_('Incident'))
fill_in('Description', with: '/promote_to_incident')
click_button('Create issue')
diff --git a/spec/workers/users/deactivate_dormant_users_worker_spec.rb b/spec/workers/users/deactivate_dormant_users_worker_spec.rb
index 1fb936b1fc2..bd6c6dfc6b2 100644
--- a/spec/workers/users/deactivate_dormant_users_worker_spec.rb
+++ b/spec/workers/users/deactivate_dormant_users_worker_spec.rb
@@ -35,6 +35,7 @@ RSpec.describe Users::DeactivateDormantUsersWorker, feature_category: :subscript
where(:user_type, :expected_state) do
:human | 'deactivated'
+ :human_deprecated | 'deactivated'
:support_bot | 'active'
:alert_bot | 'active'
:visual_review_bot | 'active'
@@ -57,11 +58,13 @@ RSpec.describe Users::DeactivateDormantUsersWorker, feature_category: :subscript
it 'does not deactivate non-active users' do
human_user = create(:user, user_type: :human, state: :blocked, last_activity_on: Gitlab::CurrentSettings.deactivate_dormant_users_period.days.ago.to_date)
+ human_user2 = create(:user, user_type: :human_deprecated, state: :blocked, last_activity_on: Gitlab::CurrentSettings.deactivate_dormant_users_period.days.ago.to_date)
service_user = create(:user, user_type: :service_user, state: :blocked, last_activity_on: Gitlab::CurrentSettings.deactivate_dormant_users_period.days.ago.to_date)
worker.perform
expect(human_user.reload.state).to eq('blocked')
+ expect(human_user2.reload.state).to eq('blocked')
expect(service_user.reload.state).to eq('blocked')
end