summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 06:06:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 06:06:26 +0000
commit42b933efc3384386c1991daca1a6d58160f70176 (patch)
tree31c59c87b26efd7a51b7230ddab894131dc2e0f7 /spec
parent3d67f14ecb37274f1c269c0d50b61615788c7f16 (diff)
downloadgitlab-ce-42b933efc3384386c1991daca1a6d58160f70176.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/cluster_form_dropdown_spec.js137
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/role_name_dropdown_spec.js43
-rw-r--r--spec/migrations/add_gitlab_instance_administration_project_spec.rb39
3 files changed, 180 insertions, 39 deletions
diff --git a/spec/frontend/create_cluster/eks_cluster/components/cluster_form_dropdown_spec.js b/spec/frontend/create_cluster/eks_cluster/components/cluster_form_dropdown_spec.js
new file mode 100644
index 00000000000..e873ef0b2fa
--- /dev/null
+++ b/spec/frontend/create_cluster/eks_cluster/components/cluster_form_dropdown_spec.js
@@ -0,0 +1,137 @@
+import { shallowMount } from '@vue/test-utils';
+
+import ClusterFormDropdown from '~/create_cluster/eks_cluster/components/cluster_form_dropdown.vue';
+import DropdownButton from '~/vue_shared/components/dropdown/dropdown_button.vue';
+import DropdownSearchInput from '~/vue_shared/components/dropdown/dropdown_search_input.vue';
+import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidden_input.vue';
+
+describe('ClusterFormDropdown', () => {
+ let vm;
+
+ beforeEach(() => {
+ vm = shallowMount(ClusterFormDropdown);
+ });
+ afterEach(() => vm.destroy());
+
+ describe('when no item is selected', () => {
+ it('displays placeholder text', () => {
+ const placeholder = 'placeholder';
+
+ vm.setProps({ placeholder });
+
+ expect(vm.find(DropdownButton).props('toggleText')).toEqual(placeholder);
+ });
+ });
+
+ describe('when an item is selected', () => {
+ const selectedItem = { name: 'Name', value: 'value' };
+
+ beforeEach(() => {
+ vm.setData({ selectedItem });
+ });
+
+ it('displays selected item label', () => {
+ expect(vm.find(DropdownButton).props('toggleText')).toEqual(selectedItem.name);
+ });
+
+ it('sets selected value to dropdown hidden input', () => {
+ expect(vm.find(DropdownHiddenInput).props('value')).toEqual(selectedItem.value);
+ });
+ });
+
+ describe('when an item is selected and has a custom label property', () => {
+ it('displays selected item custom label', () => {
+ const labelProperty = 'customLabel';
+ const selectedItem = { [labelProperty]: 'Name' };
+
+ vm.setProps({ labelProperty });
+ vm.setData({ selectedItem });
+
+ expect(vm.find(DropdownButton).props('toggleText')).toEqual(selectedItem[labelProperty]);
+ });
+ });
+
+ describe('when loading', () => {
+ it('dropdown button isLoading', () => {
+ vm.setProps({ loading: true });
+
+ expect(vm.find(DropdownButton).props('isLoading')).toBe(true);
+ });
+ });
+
+ describe('when loading and loadingText is provided', () => {
+ it('uses loading text as toggle button text', () => {
+ const loadingText = 'loading text';
+
+ vm.setProps({ loading: true, loadingText });
+
+ expect(vm.find(DropdownButton).props('toggleText')).toEqual(loadingText);
+ });
+ });
+
+ describe('when disabled', () => {
+ it('dropdown button isDisabled', () => {
+ vm.setProps({ disabled: true });
+
+ expect(vm.find(DropdownButton).props('isDisabled')).toBe(true);
+ });
+ });
+
+ describe('when disabled and disabledText is provided', () => {
+ it('uses disabled text as toggle button text', () => {
+ const disabledText = 'disabled text';
+
+ vm.setProps({ disabled: true, disabledText });
+
+ expect(vm.find(DropdownButton).props('toggleText')).toBe(disabledText);
+ });
+ });
+
+ describe('when has errors', () => {
+ it('sets border-danger class selector to dropdown toggle', () => {
+ vm.setProps({ hasErrors: true });
+
+ expect(vm.find(DropdownButton).classes('border-danger')).toBe(true);
+ });
+ });
+
+ describe('when has errors and an error message', () => {
+ it('displays error message', () => {
+ const errorMessage = 'error message';
+
+ vm.setProps({ hasErrors: true, errorMessage });
+
+ expect(vm.find('.js-eks-dropdown-error-message').text()).toEqual(errorMessage);
+ });
+ });
+
+ describe('when no results are available', () => {
+ it('displays empty text', () => {
+ const emptyText = 'error message';
+
+ vm.setProps({ items: [], emptyText });
+
+ expect(vm.find('.js-empty-text').text()).toEqual(emptyText);
+ });
+ });
+
+ it('displays search field placeholder', () => {
+ const searchFieldPlaceholder = 'Placeholder';
+
+ vm.setProps({ searchFieldPlaceholder });
+
+ expect(vm.find(DropdownSearchInput).props('placeholderText')).toEqual(searchFieldPlaceholder);
+ });
+
+ it('it filters results by search query', () => {
+ const secondItem = { name: 'second item' };
+ const items = [{ name: 'first item' }, secondItem];
+ const searchQuery = 'second';
+
+ vm.setProps({ items });
+ vm.setData({ searchQuery });
+
+ expect(vm.findAll('.js-dropdown-item').length).toEqual(1);
+ expect(vm.find('.js-dropdown-item').text()).toEqual(secondItem.name);
+ });
+});
diff --git a/spec/frontend/create_cluster/eks_cluster/components/role_name_dropdown_spec.js b/spec/frontend/create_cluster/eks_cluster/components/role_name_dropdown_spec.js
new file mode 100644
index 00000000000..657637c1b56
--- /dev/null
+++ b/spec/frontend/create_cluster/eks_cluster/components/role_name_dropdown_spec.js
@@ -0,0 +1,43 @@
+import { shallowMount } from '@vue/test-utils';
+
+import ClusterFormDropdown from '~/create_cluster/eks_cluster/components/cluster_form_dropdown.vue';
+import RoleNameDropdown from '~/create_cluster/eks_cluster/components/role_name_dropdown.vue';
+
+describe('RoleNameDropdown', () => {
+ let vm;
+
+ beforeEach(() => {
+ vm = shallowMount(RoleNameDropdown);
+ });
+ afterEach(() => vm.destroy());
+
+ it('renders a cluster-form-dropdown', () => {
+ expect(vm.find(ClusterFormDropdown).exists()).toBe(true);
+ });
+
+ it('sets roles to cluster-form-dropdown items property', () => {
+ const roles = [{ name: 'basic' }];
+
+ vm.setProps({ roles });
+
+ expect(vm.find(ClusterFormDropdown).props('items')).toEqual(roles);
+ });
+
+ it('sets a loading text', () => {
+ expect(vm.find(ClusterFormDropdown).props('loadingText')).toEqual('Loading IAM Roles');
+ });
+
+ it('sets a placeholder', () => {
+ expect(vm.find(ClusterFormDropdown).props('placeholder')).toEqual('Select role name');
+ });
+
+ it('sets an empty results text', () => {
+ expect(vm.find(ClusterFormDropdown).props('emptyText')).toEqual('No IAM Roles found');
+ });
+
+ it('sets a search field placeholder', () => {
+ expect(vm.find(ClusterFormDropdown).props('searchFieldPlaceholder')).toEqual(
+ 'Search IAM Roles',
+ );
+ });
+});
diff --git a/spec/migrations/add_gitlab_instance_administration_project_spec.rb b/spec/migrations/add_gitlab_instance_administration_project_spec.rb
deleted file mode 100644
index 58fbba9836d..00000000000
--- a/spec/migrations/add_gitlab_instance_administration_project_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20190801072937_add_gitlab_instance_administration_project.rb')
-
-describe AddGitlabInstanceAdministrationProject, :migration do
- let(:application_settings) { table(:application_settings) }
- let(:users) { table(:users) }
-
- let(:prometheus_settings) do
- {
- enable: true,
- listen_address: 'localhost:9090'
- }
- end
-
- before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
-
- stub_config(prometheus: prometheus_settings)
- end
-
- describe 'down' do
- let!(:application_setting) { application_settings.create! }
- let!(:user) { users.create!(admin: true, email: 'admin1@example.com', projects_limit: 10, state: :active) }
-
- it 'deletes group and project' do
- migrate!
-
- expect(Project.count).to eq(1)
- expect(Group.count).to eq(1)
-
- schema_migrate_down!
-
- expect(Project.count).to eq(0)
- expect(Group.count).to eq(0)
- end
- end
-end