diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-04 21:10:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-04 21:10:20 +0300 |
commit | 9bbcab8301ed38576debcb6a7f07f99005ff805a (patch) | |
tree | 20e348b90c8fc27db66a68d6a87546448590f31b /spec | |
parent | 39a548dd06b8ddcc0d2acb7832460f5fe1876521 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/identities.rb | 2 | ||||
-rw-r--r-- | spec/features/issues/filtered_search/visual_tokens_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/projects/graph_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/pipelines/pipelines_table_spec.js | 66 | ||||
-rw-r--r-- | spec/frontend/users_select/utils_spec.js | 33 | ||||
-rw-r--r-- | spec/graphql/types/snippets/blob_viewer_type_spec.rb | 81 | ||||
-rw-r--r-- | spec/javascripts/pipelines/pipelines_table_spec.js | 86 | ||||
-rw-r--r-- | spec/requests/api/features_spec.rb | 36 | ||||
-rw-r--r-- | spec/requests/api/graphql/project/issues_spec.rb | 4 |
9 files changed, 219 insertions, 93 deletions
diff --git a/spec/factories/identities.rb b/spec/factories/identities.rb index a2615ce30c3..fda4bfa589b 100644 --- a/spec/factories/identities.rb +++ b/spec/factories/identities.rb @@ -3,6 +3,6 @@ FactoryBot.define do factory :identity do provider { 'ldapmain' } - extern_uid { 'my-ldap-id' } + sequence(:extern_uid) { |n| "my-ldap-id-#{n}" } end end diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb index 3c50cb4c997..2b164e2fd97 100644 --- a/spec/features/issues/filtered_search/visual_tokens_spec.rb +++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb @@ -113,7 +113,7 @@ describe 'Visual tokens', :js do describe 'add new token after editing existing token' do before do input_filtered_search('author:=@root assignee:=none', submit: false) - first('.tokens-container .filtered-search-token').double_click + first('.tokens-container .filtered-search-token').click filtered_search.send_keys(' ') end diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb index 6b2a9a6b852..25efb7b28a7 100644 --- a/spec/features/projects/graph_spec.rb +++ b/spec/features/projects/graph_spec.rb @@ -59,7 +59,7 @@ describe 'Project Graph', :js do it 'HTML escapes branch name' do expect(page.body).to include("Commit statistics for <strong>#{ERB::Util.html_escape(branch_name)}</strong>") - expect(page.body).not_to include(branch_name) + expect(page.find('.dropdown-toggle-text')['innerHTML']).to eq(ERB::Util.html_escape(branch_name)) end end diff --git a/spec/frontend/pipelines/pipelines_table_spec.js b/spec/frontend/pipelines/pipelines_table_spec.js new file mode 100644 index 00000000000..b0ab250dd16 --- /dev/null +++ b/spec/frontend/pipelines/pipelines_table_spec.js @@ -0,0 +1,66 @@ +import { mount } from '@vue/test-utils'; +import PipelinesTable from '~/pipelines/components/pipelines_table.vue'; + +describe('Pipelines Table', () => { + let pipeline; + let wrapper; + + const jsonFixtureName = 'pipelines/pipelines.json'; + + const defaultProps = { + pipelines: [], + autoDevopsHelpPath: 'foo', + viewType: 'root', + }; + + const createComponent = (props = defaultProps) => { + wrapper = mount(PipelinesTable, { + propsData: props, + }); + }; + const findRows = () => wrapper.findAll('.commit.gl-responsive-table-row'); + + preloadFixtures(jsonFixtureName); + + beforeEach(() => { + const { pipelines } = getJSONFixture(jsonFixtureName); + pipeline = pipelines.find(p => p.user !== null && p.commit !== null); + + createComponent(); + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('table', () => { + it('should render a table', () => { + expect(wrapper.classes()).toContain('ci-table'); + }); + + it('should render table head with correct columns', () => { + expect(wrapper.find('.table-section.js-pipeline-status').text()).toEqual('Status'); + + expect(wrapper.find('.table-section.js-pipeline-info').text()).toEqual('Pipeline'); + + expect(wrapper.find('.table-section.js-pipeline-commit').text()).toEqual('Commit'); + + expect(wrapper.find('.table-section.js-pipeline-stages').text()).toEqual('Stages'); + }); + }); + + describe('without data', () => { + it('should render an empty table', () => { + expect(findRows()).toHaveLength(0); + }); + }); + + describe('with data', () => { + it('should render rows', () => { + createComponent({ pipelines: [pipeline], autoDevopsHelpPath: 'foo', viewType: 'root' }); + + expect(findRows()).toHaveLength(1); + }); + }); +}); diff --git a/spec/frontend/users_select/utils_spec.js b/spec/frontend/users_select/utils_spec.js new file mode 100644 index 00000000000..a09935d8a04 --- /dev/null +++ b/spec/frontend/users_select/utils_spec.js @@ -0,0 +1,33 @@ +import $ from 'jquery'; +import { getAjaxUsersSelectOptions, getAjaxUsersSelectParams } from '~/users_select/utils'; + +const options = { + fooBar: 'baz', + activeUserId: 1, +}; + +describe('getAjaxUsersSelectOptions', () => { + it('returns options built from select data attributes', () => { + const $select = $('<select />', { 'data-foo-bar': 'baz', 'data-user-id': 1 }); + + expect( + getAjaxUsersSelectOptions($select, { fooBar: 'fooBar', activeUserId: 'user-id' }), + ).toEqual(options); + }); +}); + +describe('getAjaxUsersSelectParams', () => { + it('returns query parameters built from provided options', () => { + expect( + getAjaxUsersSelectParams(options, { + foo_bar: 'fooBar', + active_user_id: 'activeUserId', + non_existent_key: 'nonExistentKey', + }), + ).toEqual({ + foo_bar: 'baz', + active_user_id: 1, + non_existent_key: null, + }); + }); +}); diff --git a/spec/graphql/types/snippets/blob_viewer_type_spec.rb b/spec/graphql/types/snippets/blob_viewer_type_spec.rb index a51d09813ab..841e22451db 100644 --- a/spec/graphql/types/snippets/blob_viewer_type_spec.rb +++ b/spec/graphql/types/snippets/blob_viewer_type_spec.rb @@ -3,10 +3,91 @@ require 'spec_helper' describe GitlabSchema.types['SnippetBlobViewer'] do + let_it_be(:snippet) { create(:personal_snippet, :repository) } + let_it_be(:blob) { snippet.repository.blob_at('HEAD', 'files/images/6049019_460s.jpg') } + it 'has the correct fields' do expected_fields = [:type, :load_async, :too_large, :collapsed, :render_error, :file_type, :loading_partial_name] expect(described_class).to have_graphql_fields(*expected_fields) end + + it { expect(described_class.fields['type'].type).to be_non_null } + it { expect(described_class.fields['loadAsync'].type).to be_non_null } + it { expect(described_class.fields['collapsed'].type).to be_non_null } + it { expect(described_class.fields['tooLarge'].type).to be_non_null } + it { expect(described_class.fields['renderError'].type).not_to be_non_null } + it { expect(described_class.fields['fileType'].type).to be_non_null } + it { expect(described_class.fields['loadingPartialName'].type).to be_non_null } + + shared_examples 'nil field converted to false' do + subject { GitlabSchema.execute(query, context: { current_user: snippet.author }).as_json } + + before do + allow_next_instance_of(SnippetPresenter) do |instance| + allow(instance).to receive(:blob).and_return(blob) + end + end + + it 'returns false' do + snippet_blob = subject.dig('data', 'snippets', 'edges')[0].dig('node', 'blob') + + expect(snippet_blob['path']).to eq blob.path + expect(blob_attribute).to be_nil + expect(snippet_blob['simpleViewer'][attribute]).to eq false + end + end + + describe 'collapsed' do + it_behaves_like 'nil field converted to false' do + let(:query) do + %( + query { + snippets(ids:"#{snippet.to_global_id}"){ + edges { + node { + blob { + path + simpleViewer { + collapsed + } + } + } + } + } + } + ) + end + + let(:attribute) { 'collapsed' } + let(:blob_attribute) { blob.simple_viewer.collapsed? } + end + end + + describe 'tooLarge' do + it_behaves_like 'nil field converted to false' do + let(:query) do + %( + query { + snippets(ids:"#{snippet.to_global_id}"){ + edges { + node { + blob { + path + simpleViewer { + tooLarge + } + } + } + } + } + } + ) + end + + let(:attribute) { 'tooLarge' } + let(:blob_attribute) { blob.simple_viewer.too_large? } + end + end end diff --git a/spec/javascripts/pipelines/pipelines_table_spec.js b/spec/javascripts/pipelines/pipelines_table_spec.js deleted file mode 100644 index 5c3387190ab..00000000000 --- a/spec/javascripts/pipelines/pipelines_table_spec.js +++ /dev/null @@ -1,86 +0,0 @@ -import Vue from 'vue'; -import pipelinesTableComp from '~/pipelines/components/pipelines_table.vue'; -import '~/lib/utils/datetime_utility'; - -describe('Pipelines Table', () => { - const jsonFixtureName = 'pipelines/pipelines.json'; - - let pipeline; - let PipelinesTableComponent; - - preloadFixtures(jsonFixtureName); - - beforeEach(() => { - const { pipelines } = getJSONFixture(jsonFixtureName); - - PipelinesTableComponent = Vue.extend(pipelinesTableComp); - pipeline = pipelines.find(p => p.user !== null && p.commit !== null); - }); - - describe('table', () => { - let component; - beforeEach(() => { - component = new PipelinesTableComponent({ - propsData: { - pipelines: [], - autoDevopsHelpPath: 'foo', - viewType: 'root', - }, - }).$mount(); - }); - - afterEach(() => { - component.$destroy(); - }); - - it('should render a table', () => { - expect(component.$el.getAttribute('class')).toContain('ci-table'); - }); - - it('should render table head with correct columns', () => { - expect( - component.$el.querySelector('.table-section.js-pipeline-status').textContent.trim(), - ).toEqual('Status'); - - expect( - component.$el.querySelector('.table-section.js-pipeline-info').textContent.trim(), - ).toEqual('Pipeline'); - - expect( - component.$el.querySelector('.table-section.js-pipeline-commit').textContent.trim(), - ).toEqual('Commit'); - - expect( - component.$el.querySelector('.table-section.js-pipeline-stages').textContent.trim(), - ).toEqual('Stages'); - }); - }); - - describe('without data', () => { - it('should render an empty table', () => { - const component = new PipelinesTableComponent({ - propsData: { - pipelines: [], - autoDevopsHelpPath: 'foo', - viewType: 'root', - }, - }).$mount(); - - expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0); - }); - }); - - describe('with data', () => { - it('should render rows', () => { - const component = new PipelinesTableComponent({ - propsData: { - pipelines: [pipeline], - autoDevopsHelpPath: 'foo', - viewType: 'root', - }, - }).$mount(); - - expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(1); - }); - }); -}); diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index ce72a416c33..4ad5b4f9d49 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -198,7 +198,7 @@ describe API::Features do end end - it 'creates a feature with the given percentage if passed an integer' do + it 'creates a feature with the given percentage of time if passed an integer' do post api("/features/#{feature_name}", admin), params: { value: '50' } expect(response).to have_gitlab_http_status(:created) @@ -210,6 +210,19 @@ describe API::Features do { 'key' => 'percentage_of_time', 'value' => 50 } ]) end + + it 'creates a feature with the given percentage of actors if passed an integer' do + post api("/features/#{feature_name}", admin), params: { value: '50', key: 'percentage_of_actors' } + + expect(response).to have_gitlab_http_status(:created) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'percentage_of_actors', 'value' => 50 } + ]) + end end context 'when the feature exists' do @@ -298,7 +311,7 @@ describe API::Features do end end - context 'with a pre-existing percentage value' do + context 'with a pre-existing percentage of time value' do before do feature.enable_percentage_of_time(50) end @@ -316,6 +329,25 @@ describe API::Features do ]) end end + + context 'with a pre-existing percentage of actors value' do + before do + feature.enable_percentage_of_actors(42) + end + + it 'updates the percentage of actors if passed an integer' do + post api("/features/#{feature_name}", admin), params: { value: '74', key: 'percentage_of_actors' } + + expect(response).to have_gitlab_http_status(:created) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'percentage_of_actors', 'value' => 74 } + ]) + end + end end end diff --git a/spec/requests/api/graphql/project/issues_spec.rb b/spec/requests/api/graphql/project/issues_spec.rb index 256b45498f6..31388b3061c 100644 --- a/spec/requests/api/graphql/project/issues_spec.rb +++ b/spec/requests/api/graphql/project/issues_spec.rb @@ -358,7 +358,7 @@ describe 'getting an issue list for a project' do cursored_query = query("sort: LABEL_PRIORITY_ASC, after: \"#{end_cursor}\"") post_graphql(cursored_query, current_user: current_user) - response_data = JSON.parse(response.body)['data']['project']['issues']['edges'] + response_data = Gitlab::Json.parse(response.body)['data']['project']['issues']['edges'] expect(grab_iids(response_data)).to eq [label_issue2.iid, label_issue4.iid] end @@ -380,7 +380,7 @@ describe 'getting an issue list for a project' do cursored_query = query("sort: LABEL_PRIORITY_DESC, after: \"#{end_cursor}\"") post_graphql(cursored_query, current_user: current_user) - response_data = JSON.parse(response.body)['data']['project']['issues']['edges'] + response_data = Gitlab::Json.parse(response.body)['data']['project']['issues']['edges'] expect(grab_iids(response_data)).to eq [label_issue1.iid, label_issue4.iid] end |