Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/profiles_controller_spec.rb11
-rw-r--r--spec/factories/user_details.rb1
-rw-r--r--spec/features/users/show_spec.rb8
-rw-r--r--spec/frontend/environments/environment_item_spec.js125
-rw-r--r--spec/frontend/environments/mock_data.js2
-rw-r--r--spec/frontend/pages/admin/application_settings/metrics_and_profiling/usage_statistics_spec.js58
-rw-r--r--spec/models/user_detail_spec.rb5
-rw-r--r--spec/models/user_spec.rb9
8 files changed, 181 insertions, 38 deletions
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 37a633afab4..b4019643baf 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -110,6 +110,17 @@ RSpec.describe ProfilesController, :request_store do
expect(user.reload.pronouns).to eq(pronouns)
expect(response).to have_gitlab_http_status(:found)
end
+
+ it 'allows updating user specified pronunciation', :aggregate_failures do
+ user = create(:user, name: 'Example')
+ pronunciation = 'uhg-zaam-pl'
+ sign_in(user)
+
+ put :update, params: { user: { pronunciation: pronunciation } }
+
+ expect(user.reload.pronunciation).to eq(pronunciation)
+ expect(response).to have_gitlab_http_status(:found)
+ end
end
describe 'GET audit_log' do
diff --git a/spec/factories/user_details.rb b/spec/factories/user_details.rb
index d3cf0d48577..6d58123f2e1 100644
--- a/spec/factories/user_details.rb
+++ b/spec/factories/user_details.rb
@@ -5,5 +5,6 @@ FactoryBot.define do
user
job_title { 'VP of Sales' }
pronouns { nil }
+ pronunciation { nil }
end
end
diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb
index fcbbe3b4d1f..fb2873f1c96 100644
--- a/spec/features/users/show_spec.rb
+++ b/spec/features/users/show_spec.rb
@@ -278,6 +278,14 @@ RSpec.describe 'User page' do
expect(page).to have_content("(they/them)")
end
+ it 'shows the pronunctiation of the user if there was one' do
+ user.user_detail.update_column(:pronunciation, 'pruh-nuhn-see-ay-shn')
+
+ subject
+
+ expect(page).to have_content("Pronounced as: pruh-nuhn-see-ay-shn")
+ end
+
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
diff --git a/spec/frontend/environments/environment_item_spec.js b/spec/frontend/environments/environment_item_spec.js
index 62806c9e44c..a568a7d5396 100644
--- a/spec/frontend/environments/environment_item_spec.js
+++ b/spec/frontend/environments/environment_item_spec.js
@@ -1,14 +1,21 @@
import { mount } from '@vue/test-utils';
import { cloneDeep } from 'lodash';
import { format } from 'timeago.js';
+import { mockTracking, unmockTracking, triggerEvent } from 'helpers/tracking_helper';
+import ActionsComponent from '~/environments/components/environment_actions.vue';
import DeleteComponent from '~/environments/components/environment_delete.vue';
+import ExternalUrlComponent from '~/environments/components/environment_external_url.vue';
import EnvironmentItem from '~/environments/components/environment_item.vue';
import PinComponent from '~/environments/components/environment_pin.vue';
+import RollbackComponent from '~/environments/components/environment_rollback.vue';
+import StopComponent from '~/environments/components/environment_stop.vue';
+import TerminalButtonComponent from '~/environments/components/environment_terminal_button.vue';
import { differenceInMilliseconds } from '~/lib/utils/datetime_utility';
import { environment, folder, tableData } from './mock_data';
describe('Environment item', () => {
let wrapper;
+ let tracking;
const factory = (options = {}) => {
// This destroys any wrappers created before a nested call to factory reassigns it
@@ -28,6 +35,12 @@ describe('Environment item', () => {
tableData,
},
});
+
+ tracking = mockTracking(undefined, wrapper.element, jest.spyOn);
+ });
+
+ afterEach(() => {
+ unmockTracking();
});
const findAutoStop = () => wrapper.find('.js-auto-stop');
@@ -62,7 +75,7 @@ describe('Environment item', () => {
});
it('should not render the delete button', () => {
- expect(wrapper.find(DeleteComponent).exists()).toBe(false);
+ expect(wrapper.findComponent(DeleteComponent).exists()).toBe(false);
});
describe('With user information', () => {
@@ -176,12 +189,14 @@ describe('Environment item', () => {
});
it('should not render the auto-stop button', () => {
- expect(wrapper.find(PinComponent).exists()).toBe(false);
+ expect(wrapper.findComponent(PinComponent).exists()).toBe(false);
});
});
describe('With auto-stop date', () => {
describe('in the future', () => {
+ let pin;
+
const futureDate = new Date(Date.now() + 100000);
beforeEach(() => {
factory({
@@ -195,6 +210,9 @@ describe('Environment item', () => {
shouldShowAutoStopDate: true,
},
});
+ tracking = mockTracking(undefined, wrapper.element, jest.spyOn);
+
+ pin = wrapper.findComponent(PinComponent);
});
it('renders the date', () => {
@@ -202,7 +220,15 @@ describe('Environment item', () => {
});
it('should render the auto-stop button', () => {
- expect(wrapper.find(PinComponent).exists()).toBe(true);
+ expect(pin.exists()).toBe(true);
+ });
+
+ it('should tracks clicks', () => {
+ pin.trigger('click');
+
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_button', {
+ label: 'environment_pin',
+ });
});
});
@@ -227,33 +253,104 @@ describe('Environment item', () => {
});
it('should not render the suto-stop button', () => {
- expect(wrapper.find(PinComponent).exists()).toBe(false);
+ expect(wrapper.findComponent(PinComponent).exists()).toBe(false);
});
});
});
});
describe('With manual actions', () => {
+ let actions;
+
+ beforeEach(() => {
+ actions = wrapper.findComponent(ActionsComponent);
+ });
+
it('should render actions component', () => {
- expect(wrapper.find('.js-manual-actions-container')).toBeDefined();
+ expect(actions.exists()).toBe(true);
+ });
+
+ it('should track clicks', () => {
+ actions.trigger('click');
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_dropdown', {
+ label: 'environment_actions',
+ });
});
});
describe('With external URL', () => {
+ let externalUrl;
+
+ beforeEach(() => {
+ externalUrl = wrapper.findComponent(ExternalUrlComponent);
+ });
+
it('should render external url component', () => {
- expect(wrapper.find('.js-external-url-container')).toBeDefined();
+ expect(externalUrl.exists()).toBe(true);
+ });
+
+ it('should track clicks', () => {
+ externalUrl.trigger('click');
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_button', {
+ label: 'environment_url',
+ });
});
});
describe('With stop action', () => {
+ let stop;
+
+ beforeEach(() => {
+ stop = wrapper.findComponent(StopComponent);
+ });
+
it('should render stop action component', () => {
- expect(wrapper.find('.js-stop-component-container')).toBeDefined();
+ expect(stop.exists()).toBe(true);
+ });
+
+ it('should track clicks', () => {
+ stop.trigger('click');
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_button', {
+ label: 'environment_stop',
+ });
});
});
describe('With retry action', () => {
+ let rollback;
+
+ beforeEach(() => {
+ rollback = wrapper.findComponent(RollbackComponent);
+ });
+
it('should render rollback component', () => {
- expect(wrapper.find('.js-rollback-component-container')).toBeDefined();
+ expect(rollback.exists()).toBe(true);
+ });
+
+ it('should track clicks', () => {
+ rollback.trigger('click');
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_button', {
+ label: 'environment_rollback',
+ });
+ });
+ });
+
+ describe('With terminal path', () => {
+ let terminal;
+
+ beforeEach(() => {
+ terminal = wrapper.findComponent(TerminalButtonComponent);
+ });
+
+ it('should render terminal action component', () => {
+ expect(terminal.exists()).toBe(true);
+ });
+
+ it('should track clicks', () => {
+ triggerEvent(terminal.element);
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_button', {
+ label: 'environment_terminal',
+ });
});
});
});
@@ -312,7 +409,17 @@ describe('Environment item', () => {
});
it('should render the delete button', () => {
- expect(wrapper.find(DeleteComponent).exists()).toBe(true);
+ expect(wrapper.findComponent(DeleteComponent).exists()).toBe(true);
+ });
+
+ it('should trigger a tracking event', async () => {
+ tracking = mockTracking(undefined, wrapper.element, jest.spyOn);
+
+ await wrapper.findComponent(DeleteComponent).trigger('click');
+
+ expect(tracking).toHaveBeenCalledWith('_category_', 'click_button', {
+ label: 'environment_delete',
+ });
});
});
});
diff --git a/spec/frontend/environments/mock_data.js b/spec/frontend/environments/mock_data.js
index b04d0551b50..a6d67c26304 100644
--- a/spec/frontend/environments/mock_data.js
+++ b/spec/frontend/environments/mock_data.js
@@ -71,6 +71,8 @@ const environment = {
state: 'stopped',
external_url: 'http://external.com',
environment_type: null,
+ can_stop: true,
+ terminal_path: '/terminal',
last_deployment: {
id: 66,
iid: 6,
diff --git a/spec/frontend/pages/admin/application_settings/metrics_and_profiling/usage_statistics_spec.js b/spec/frontend/pages/admin/application_settings/metrics_and_profiling/usage_statistics_spec.js
index 858c7b76ac8..4140b985682 100644
--- a/spec/frontend/pages/admin/application_settings/metrics_and_profiling/usage_statistics_spec.js
+++ b/spec/frontend/pages/admin/application_settings/metrics_and_profiling/usage_statistics_spec.js
@@ -5,53 +5,53 @@ import initSetHelperText, {
describe('UsageStatistics', () => {
const FIXTURE = 'application_settings/usage.html';
- let usagePingCheckBox;
- let usagePingFeaturesCheckBox;
- let usagePingFeaturesLabel;
- let usagePingFeaturesHelperText;
+ let servicePingCheckBox;
+ let servicePingFeaturesCheckBox;
+ let servicePingFeaturesLabel;
+ let servicePingFeaturesHelperText;
beforeEach(() => {
loadFixtures(FIXTURE);
initSetHelperText();
- usagePingCheckBox = document.getElementById('application_setting_usage_ping_enabled');
- usagePingFeaturesCheckBox = document.getElementById(
+ servicePingCheckBox = document.getElementById('application_setting_usage_ping_enabled');
+ servicePingFeaturesCheckBox = document.getElementById(
'application_setting_usage_ping_features_enabled',
);
- usagePingFeaturesLabel = document.getElementById('service_ping_features_label');
- usagePingFeaturesHelperText = document.getElementById('service_ping_features_helper_text');
+ servicePingFeaturesLabel = document.getElementById('service_ping_features_label');
+ servicePingFeaturesHelperText = document.getElementById('service_ping_features_helper_text');
});
- const expectEnabledUsagePingFeaturesCheckBox = () => {
- expect(usagePingFeaturesCheckBox.classList.contains('gl-cursor-not-allowed')).toBe(false);
- expect(usagePingFeaturesHelperText.textContent).toEqual(HELPER_TEXT_SERVICE_PING_ENABLED);
+ const expectEnabledservicePingFeaturesCheckBox = () => {
+ expect(servicePingFeaturesCheckBox.classList.contains('gl-cursor-not-allowed')).toBe(false);
+ expect(servicePingFeaturesHelperText.textContent).toEqual(HELPER_TEXT_SERVICE_PING_ENABLED);
};
- const expectDisabledUsagePingFeaturesCheckBox = () => {
- expect(usagePingFeaturesLabel.classList.contains('gl-cursor-not-allowed')).toBe(true);
- expect(usagePingFeaturesHelperText.textContent).toEqual(HELPER_TEXT_SERVICE_PING_DISABLED);
+ const expectDisabledservicePingFeaturesCheckBox = () => {
+ expect(servicePingFeaturesLabel.classList.contains('gl-cursor-not-allowed')).toBe(true);
+ expect(servicePingFeaturesHelperText.textContent).toEqual(HELPER_TEXT_SERVICE_PING_DISABLED);
};
describe('Registration Features checkbox', () => {
- it('is disabled when Usage Ping checkbox is unchecked', () => {
- expect(usagePingCheckBox.checked).toBe(false);
- expectDisabledUsagePingFeaturesCheckBox();
+ it('is disabled when Service Ping checkbox is unchecked', () => {
+ expect(servicePingCheckBox.checked).toBe(false);
+ expectDisabledservicePingFeaturesCheckBox();
});
- it('is enabled when Usage Ping checkbox is checked', () => {
- usagePingCheckBox.click();
- expect(usagePingCheckBox.checked).toBe(true);
- expectEnabledUsagePingFeaturesCheckBox();
+ it('is enabled when Servie Ping checkbox is checked', () => {
+ servicePingCheckBox.click();
+ expect(servicePingCheckBox.checked).toBe(true);
+ expectEnabledservicePingFeaturesCheckBox();
});
- it('is switched to disabled when Usage Ping checkbox is unchecked ', () => {
- usagePingCheckBox.click();
- usagePingFeaturesCheckBox.click();
- expectEnabledUsagePingFeaturesCheckBox();
+ it('is switched to disabled when Service Ping checkbox is unchecked ', () => {
+ servicePingCheckBox.click();
+ servicePingFeaturesCheckBox.click();
+ expectEnabledservicePingFeaturesCheckBox();
- usagePingCheckBox.click();
- expect(usagePingCheckBox.checked).toBe(false);
- expect(usagePingFeaturesCheckBox.checked).toBe(false);
- expectDisabledUsagePingFeaturesCheckBox();
+ servicePingCheckBox.click();
+ expect(servicePingCheckBox.checked).toBe(false);
+ expect(servicePingFeaturesCheckBox.checked).toBe(false);
+ expectDisabledservicePingFeaturesCheckBox();
});
});
});
diff --git a/spec/models/user_detail_spec.rb b/spec/models/user_detail_spec.rb
index c2d9b916a1c..3c87dcdcbd9 100644
--- a/spec/models/user_detail_spec.rb
+++ b/spec/models/user_detail_spec.rb
@@ -16,6 +16,11 @@ RSpec.describe UserDetail do
it { is_expected.to validate_length_of(:pronouns).is_at_most(50) }
end
+ describe '#pronunciation' do
+ it { is_expected.not_to validate_presence_of(:pronunciation) }
+ it { is_expected.to validate_length_of(:pronunciation).is_at_most(255) }
+ end
+
describe '#bio' do
it { is_expected.to validate_length_of(:bio).is_at_most(255) }
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index f16277c3ff6..bce21cfdab2 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -77,6 +77,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:pronouns).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:pronouns=).to(:user_detail).with_arguments(:args).allow_nil }
+ it { is_expected.to delegate_method(:pronunciation).to(:user_detail).allow_nil }
+ it { is_expected.to delegate_method(:pronunciation=).to(:user_detail).with_arguments(:args).allow_nil }
+
it { is_expected.to delegate_method(:bio).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:bio=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:bio_html).to(:user_detail).allow_nil }
@@ -146,6 +149,12 @@ RSpec.describe User do
expect(user.pronouns).to eq(user.user_detail.pronouns)
end
+ it 'delegates `pronunciation` to `user_detail`' do
+ user = create(:user, name: 'Example', pronunciation: 'uhg-zaam-pl')
+
+ expect(user.pronunciation).to eq(user.user_detail.pronunciation)
+ end
+
it 'creates `user_detail` when `bio` is first updated' do
user = create(:user)