diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 15:06:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 15:06:17 +0000 |
commit | b5ad06174bb1de39438c90847abb86ac6988e944 (patch) | |
tree | 1bb386b92f023fd2a8f776ccc10386675b3b1ef9 /spec | |
parent | 0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1 (diff) | |
download | gitlab-ce-b5ad06174bb1de39438c90847abb86ac6988e944.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/boards/issue_card_spec.js | 1 | ||||
-rw-r--r-- | spec/frontend/registry/components/app_spec.js | 29 | ||||
-rw-r--r-- | spec/frontend/registry/components/collapsible_container_spec.js | 22 | ||||
-rw-r--r-- | spec/frontend/registry/components/table_registry_spec.js | 48 | ||||
-rw-r--r-- | spec/frontend/releases/detail/components/app_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/sidebar/__snapshots__/todo_spec.js.snap | 2 | ||||
-rw-r--r-- | spec/frontend/sidebar/todo_spec.js | 6 | ||||
-rw-r--r-- | spec/models/project_auto_devops_spec.rb | 13 | ||||
-rw-r--r-- | spec/services/git/base_hooks_service_spec.rb | 101 | ||||
-rw-r--r-- | spec/services/git/branch_push_service_spec.rb | 1 |
10 files changed, 171 insertions, 54 deletions
diff --git a/spec/frontend/boards/issue_card_spec.js b/spec/frontend/boards/issue_card_spec.js index ebe97769ab7..c7ab477c0af 100644 --- a/spec/frontend/boards/issue_card_spec.js +++ b/spec/frontend/boards/issue_card_spec.js @@ -51,6 +51,7 @@ describe('Issue card component', () => { }, store, sync: false, + attachToDocument: true, }); }); diff --git a/spec/frontend/registry/components/app_spec.js b/spec/frontend/registry/components/app_spec.js index 2bb21c12fc9..63ef28c64f2 100644 --- a/spec/frontend/registry/components/app_spec.js +++ b/spec/frontend/registry/components/app_spec.js @@ -7,11 +7,11 @@ import { reposServerResponse, parsedReposServerResponse } from '../mock_data'; describe('Registry List', () => { let wrapper; - const findCollapsibleContainer = w => w.findAll({ name: 'CollapsibeContainerRegisty' }); - const findProjectEmptyState = w => w.find({ name: 'ProjectEmptyState' }); - const findGroupEmptyState = w => w.find({ name: 'GroupEmptyState' }); - const findSpinner = w => w.find('.gl-spinner'); - const findCharacterErrorText = w => w.find('.js-character-error-text'); + const findCollapsibleContainer = () => wrapper.findAll({ name: 'CollapsibeContainerRegisty' }); + const findProjectEmptyState = () => wrapper.find({ name: 'ProjectEmptyState' }); + const findGroupEmptyState = () => wrapper.find({ name: 'GroupEmptyState' }); + const findSpinner = () => wrapper.find('.gl-spinner'); + const findCharacterErrorText = () => wrapper.find('.js-character-error-text'); const propsData = { endpoint: `${TEST_HOST}/foo`, @@ -59,16 +59,15 @@ describe('Registry List', () => { describe('with data', () => { it('should render a list of CollapsibeContainerRegisty', () => { - const containers = findCollapsibleContainer(wrapper); + const containers = findCollapsibleContainer(); expect(wrapper.vm.repos.length).toEqual(reposServerResponse.length); expect(containers.length).toEqual(reposServerResponse.length); }); }); describe('without data', () => { - let localWrapper; beforeEach(() => { - localWrapper = mount(registry, { + wrapper = mount(registry, { attachToDocument: true, sync: false, propsData, @@ -82,16 +81,14 @@ describe('Registry List', () => { }); it('should render project empty message', () => { - const projectEmptyState = findProjectEmptyState(localWrapper); + const projectEmptyState = findProjectEmptyState(); expect(projectEmptyState.exists()).toBe(true); }); }); describe('while loading data', () => { - let localWrapper; - beforeEach(() => { - localWrapper = mount(registry, { + wrapper = mount(registry, { propsData, computed: { repos() { @@ -106,16 +103,14 @@ describe('Registry List', () => { }); it('should render a loading spinner', () => { - const spinner = findSpinner(localWrapper); + const spinner = findSpinner(); expect(spinner.exists()).toBe(true); }); }); describe('invalid characters in path', () => { - let localWrapper; - beforeEach(() => { - localWrapper = mount(registry, { + wrapper = mount(registry, { propsData: { ...propsData, characterError: true, @@ -130,7 +125,7 @@ describe('Registry List', () => { }); it('should render invalid characters error message', () => { - const characterErrorText = findCharacterErrorText(localWrapper); + const characterErrorText = findCharacterErrorText(); expect(characterErrorText.text()).toEqual( 'We are having trouble connecting to Docker, which could be due to an issue with your project name or path. More Information', ); diff --git a/spec/frontend/registry/components/collapsible_container_spec.js b/spec/frontend/registry/components/collapsible_container_spec.js index 3d07ab63776..2e471548a1b 100644 --- a/spec/frontend/registry/components/collapsible_container_spec.js +++ b/spec/frontend/registry/components/collapsible_container_spec.js @@ -17,10 +17,10 @@ describe('collapsible registry container', () => { let wrapper; let store; - const findDeleteBtn = (w = wrapper) => w.find('.js-remove-repo'); - const findContainerImageTags = (w = wrapper) => w.find('.container-image-tags'); - const findToggleRepos = (w = wrapper) => w.findAll('.js-toggle-repo'); - const findDeleteModal = (w = wrapper) => w.find({ ref: 'deleteModal' }); + const findDeleteBtn = () => wrapper.find('.js-remove-repo'); + const findContainerImageTags = () => wrapper.find('.container-image-tags'); + const findToggleRepos = () => wrapper.findAll('.js-toggle-repo'); + const findDeleteModal = () => wrapper.find({ ref: 'deleteModal' }); const mountWithStore = config => mount(collapsibleComponent, { @@ -62,7 +62,7 @@ describe('collapsible registry container', () => { }); const expectIsClosed = () => { - const container = findContainerImageTags(wrapper); + const container = findContainerImageTags(); expect(container.exists()).toBe(false); expect(wrapper.vm.iconName).toEqual('angle-right'); }; @@ -70,18 +70,20 @@ describe('collapsible registry container', () => { it('should be closed by default', () => { expectIsClosed(); }); + it('should be open when user clicks on closed repo', done => { - const toggleRepos = findToggleRepos(wrapper); + const toggleRepos = findToggleRepos(); toggleRepos.at(0).trigger('click'); Vue.nextTick(() => { - const container = findContainerImageTags(wrapper); + const container = findContainerImageTags(); expect(container.exists()).toBe(true); expect(wrapper.vm.fetchList).toHaveBeenCalled(); done(); }); }); + it('should be closed when the user clicks on an opened repo', done => { - const toggleRepos = findToggleRepos(wrapper); + const toggleRepos = findToggleRepos(); toggleRepos.at(0).trigger('click'); Vue.nextTick(() => { toggleRepos.at(0).trigger('click'); @@ -95,7 +97,7 @@ describe('collapsible registry container', () => { describe('delete repo', () => { it('should be possible to delete a repo', () => { - const deleteBtn = findDeleteBtn(wrapper); + const deleteBtn = findDeleteBtn(); expect(deleteBtn.exists()).toBe(true); }); @@ -132,7 +134,7 @@ describe('collapsible registry container', () => { }); it('should not render delete button', () => { - const deleteBtn = findDeleteBtn(wrapper); + const deleteBtn = findDeleteBtn(); expect(deleteBtn.exists()).toBe(false); }); }); diff --git a/spec/frontend/registry/components/table_registry_spec.js b/spec/frontend/registry/components/table_registry_spec.js index 4566e6ed705..7147988ab61 100644 --- a/spec/frontend/registry/components/table_registry_spec.js +++ b/spec/frontend/registry/components/table_registry_spec.js @@ -19,13 +19,13 @@ describe('table registry', () => { let wrapper; let store; - const findSelectAllCheckbox = (w = wrapper) => w.find('.js-select-all-checkbox > input'); - const findSelectCheckboxes = (w = wrapper) => w.findAll('.js-select-checkbox > input'); - const findDeleteButton = (w = wrapper) => w.find({ ref: 'bulkDeleteButton' }); - const findDeleteButtonsRow = (w = wrapper) => w.findAll('.js-delete-registry-row'); - const findPagination = (w = wrapper) => w.find('.js-registry-pagination'); - const findDeleteModal = (w = wrapper) => w.find({ ref: 'deleteModal' }); - const findImageId = (w = wrapper) => w.find({ ref: 'imageId' }); + const findSelectAllCheckbox = () => wrapper.find('.js-select-all-checkbox > input'); + const findSelectCheckboxes = () => wrapper.findAll('.js-select-checkbox > input'); + const findDeleteButton = () => wrapper.find({ ref: 'bulkDeleteButton' }); + const findDeleteButtonsRow = () => wrapper.findAll('.js-delete-registry-row'); + const findPagination = () => wrapper.find('.js-registry-pagination'); + const findDeleteModal = () => wrapper.find({ ref: 'deleteModal' }); + const findImageId = () => wrapper.find({ ref: 'imageId' }); const bulkDeletePath = 'path'; const mountWithStore = config => @@ -83,8 +83,8 @@ describe('table registry', () => { describe('multi select', () => { it('selecting a row should enable delete button', done => { - const deleteBtn = findDeleteButton(wrapper); - const checkboxes = findSelectCheckboxes(wrapper); + const deleteBtn = findDeleteButton(); + const checkboxes = findSelectCheckboxes(); expect(deleteBtn.attributes('disabled')).toBe('disabled'); @@ -96,8 +96,8 @@ describe('table registry', () => { }); it('selecting all checkbox should select all rows and enable delete button', done => { - const selectAll = findSelectAllCheckbox(wrapper); - const checkboxes = findSelectCheckboxes(wrapper); + const selectAll = findSelectAllCheckbox(); + const checkboxes = findSelectCheckboxes(); selectAll.trigger('click'); Vue.nextTick(() => { @@ -108,8 +108,8 @@ describe('table registry', () => { }); it('deselecting select all checkbox should deselect all rows and disable delete button', done => { - const checkboxes = findSelectCheckboxes(wrapper); - const selectAll = findSelectAllCheckbox(wrapper); + const checkboxes = findSelectCheckboxes(); + const selectAll = findSelectAllCheckbox(); selectAll.trigger('click'); selectAll.trigger('click'); @@ -123,11 +123,11 @@ describe('table registry', () => { it('should delete multiple items when multiple items are selected', done => { const multiDeleteItems = jest.fn().mockResolvedValue(); wrapper.setMethods({ multiDeleteItems }); - const selectAll = findSelectAllCheckbox(wrapper); + const selectAll = findSelectAllCheckbox(); selectAll.trigger('click'); Vue.nextTick(() => { - const deleteBtn = findDeleteButton(wrapper); + const deleteBtn = findDeleteButton(); expect(wrapper.vm.selectedItems).toEqual([0, 1]); expect(deleteBtn.attributes('disabled')).toEqual(undefined); wrapper.setData({ itemsToBeDeleted: [...wrapper.vm.selectedItems] }); @@ -165,8 +165,8 @@ describe('table registry', () => { }); it('should be possible to delete a registry', () => { - const deleteBtn = findDeleteButton(wrapper); - const deleteBtns = findDeleteButtonsRow(wrapper); + const deleteBtn = findDeleteButton(); + const deleteBtns = findDeleteButtonsRow(); expect(wrapper.vm.selectedItems).toEqual([0]); expect(deleteBtn).toBeDefined(); expect(deleteBtn.attributes('disable')).toBe(undefined); @@ -174,7 +174,7 @@ describe('table registry', () => { }); it('should allow deletion row by row', () => { - const deleteBtns = findDeleteButtonsRow(wrapper); + const deleteBtns = findDeleteButtonsRow(); const deleteSingleItem = jest.fn(); const deleteItem = jest.fn().mockResolvedValue(); wrapper.setMethods({ deleteSingleItem, deleteItem }); @@ -225,11 +225,11 @@ describe('table registry', () => { }); it('should exist', () => { - const pagination = findPagination(wrapper); + const pagination = findPagination(); expect(pagination.exists()).toBe(true); }); it('should be visible when pagination is needed', () => { - const pagination = findPagination(wrapper); + const pagination = findPagination(); expect(pagination.isVisible()).toBe(true); wrapper.setProps({ repo: { @@ -283,22 +283,22 @@ describe('table registry', () => { }); it('should not render select all', () => { - const selectAll = findSelectAllCheckbox(wrapper); + const selectAll = findSelectAllCheckbox(); expect(selectAll.exists()).toBe(false); }); it('should not render any select checkbox', () => { - const selects = findSelectCheckboxes(wrapper); + const selects = findSelectCheckboxes(); expect(selects.length).toBe(0); }); it('should not render delete registry button', () => { - const deleteBtn = findDeleteButton(wrapper); + const deleteBtn = findDeleteButton(); expect(deleteBtn.exists()).toBe(false); }); it('should not render delete row button', () => { - const deleteBtns = findDeleteButtonsRow(wrapper); + const deleteBtns = findDeleteButtonsRow(); expect(deleteBtns.length).toBe(0); }); }); diff --git a/spec/frontend/releases/detail/components/app_spec.js b/spec/frontend/releases/detail/components/app_spec.js index 4726f18c8fa..4f094e8639a 100644 --- a/spec/frontend/releases/detail/components/app_spec.js +++ b/spec/frontend/releases/detail/components/app_spec.js @@ -29,7 +29,7 @@ describe('Release detail component', () => { const store = new Vuex.Store({ actions, state }); - wrapper = mount(ReleaseDetailApp, { store }); + wrapper = mount(ReleaseDetailApp, { store, sync: false, attachToDocument: true }); return wrapper.vm.$nextTick(); }); diff --git a/spec/frontend/sidebar/__snapshots__/todo_spec.js.snap b/spec/frontend/sidebar/__snapshots__/todo_spec.js.snap index abcdf600a67..1704206c4ad 100644 --- a/spec/frontend/sidebar/__snapshots__/todo_spec.js.snap +++ b/spec/frontend/sidebar/__snapshots__/todo_spec.js.snap @@ -23,7 +23,7 @@ exports[`SidebarTodo template renders component container element with proper da <span class="issuable-todo-inner" > - Mark as done + Mark as done </span> <glloadingicon-stub diff --git a/spec/frontend/sidebar/todo_spec.js b/spec/frontend/sidebar/todo_spec.js index c93bbadc264..5bbb42d402d 100644 --- a/spec/frontend/sidebar/todo_spec.js +++ b/spec/frontend/sidebar/todo_spec.js @@ -89,5 +89,11 @@ describe('SidebarTodo', () => { expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); }); + + it('hides button icon when `isActionActive` prop is true', () => { + createComponent({ collapsed: true, isActionActive: true }); + + expect(wrapper.find(Icon).isVisible()).toBe(false); + }); }); }); diff --git a/spec/models/project_auto_devops_spec.rb b/spec/models/project_auto_devops_spec.rb index da9e56ef897..2a821b20aa8 100644 --- a/spec/models/project_auto_devops_spec.rb +++ b/spec/models/project_auto_devops_spec.rb @@ -23,7 +23,8 @@ describe ProjectAutoDevops do [ { key: 'INCREMENTAL_ROLLOUT_MODE', value: 'manual' }, { key: 'STAGING_ENABLED', value: '1' }, - { key: 'INCREMENTAL_ROLLOUT_ENABLED', value: '1' } + { key: 'INCREMENTAL_ROLLOUT_ENABLED', value: '1' }, + { key: 'AUTO_DEVOPS_EXPLICITLY_ENABLED', value: '1' } ] end @@ -33,6 +34,8 @@ describe ProjectAutoDevops do context 'when deploy_strategy is continuous' do let(:auto_devops) { build_stubbed(:project_auto_devops, :continuous_deployment, project: project) } + it { expect(auto_devops.predefined_variables).to include(key: 'AUTO_DEVOPS_EXPLICITLY_ENABLED', value: '1') } + it do expect(auto_devops.predefined_variables.map { |var| var[:key] }) .not_to include("STAGING_ENABLED", "INCREMENTAL_ROLLOUT_ENABLED") @@ -44,11 +47,19 @@ describe ProjectAutoDevops do it { expect(auto_devops.predefined_variables).to include(key: 'INCREMENTAL_ROLLOUT_MODE', value: 'timed') } + it { expect(auto_devops.predefined_variables).to include(key: 'AUTO_DEVOPS_EXPLICITLY_ENABLED', value: '1') } + it do expect(auto_devops.predefined_variables.map { |var| var[:key] }) .not_to include("STAGING_ENABLED", "INCREMENTAL_ROLLOUT_ENABLED") end end + + context 'when auto-devops is explicitly disabled' do + let(:auto_devops) { build_stubbed(:project_auto_devops, :disabled, project: project) } + + it { expect(auto_devops.predefined_variables.to_hash).to be_empty } + end end describe '#create_gitlab_deploy_token' do diff --git a/spec/services/git/base_hooks_service_spec.rb b/spec/services/git/base_hooks_service_spec.rb index f3f6b36a18d..07ce560bd88 100644 --- a/spec/services/git/base_hooks_service_spec.rb +++ b/spec/services/git/base_hooks_service_spec.rb @@ -11,6 +11,7 @@ describe Git::BaseHooksService do let(:oldrev) { Gitlab::Git::BLANK_SHA } let(:newrev) { "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" } # gitlab-test: git rev-parse refs/tags/v1.1.0 let(:ref) { 'refs/tags/v1.1.0' } + let(:checkout_sha) { '5937ac0a7beb003549fc5fd26fc247adbce4a52e' } let(:test_service) do Class.new(described_class) do @@ -131,4 +132,104 @@ describe Git::BaseHooksService do end end end + + describe 'Generating CI variables from push options' do + let(:pipeline_params) do + { + after: newrev, + before: oldrev, + checkout_sha: checkout_sha, + push_options: push_options, # defined in each context + ref: ref, + variables_attributes: variables_attributes # defined in each context + } + end + + shared_examples 'creates pipeline with params and expected variables' do + it 'calls the create pipeline service' do + expect(Ci::CreatePipelineService) + .to receive(:new) + .with(project, user, pipeline_params) + .and_return(double(execute!: true)) + + subject.execute + end + end + + context 'with empty push options' do + let(:push_options) { {} } + let(:variables_attributes) { [] } + + it_behaves_like 'creates pipeline with params and expected variables' + end + + context 'with push options not specifying variables' do + let(:push_options) do + { + mr: { + create: true + } + } + end + let(:variables_attributes) { [] } + + before do + params[:push_options] = push_options + end + + it_behaves_like 'creates pipeline with params and expected variables' + end + + context 'with push options specifying variables' do + let(:push_options) do + { + ci: { + variable: { + "FOO=123": 1, + "BAR=456": 1, + "MNO=890=ABC": 1 + } + } + } + end + let(:variables_attributes) do + [ + { "key" => "FOO", "variable_type" => "env_var", "secret_value" => "123" }, + { "key" => "BAR", "variable_type" => "env_var", "secret_value" => "456" }, + { "key" => "MNO", "variable_type" => "env_var", "secret_value" => "890=ABC" } + ] + end + + before do + params[:push_options] = push_options + end + + it_behaves_like 'creates pipeline with params and expected variables' + end + + context 'with push options not specifying variables in correct format' do + let(:push_options) do + { + ci: { + variable: { + "FOO=123": 1, + "BAR": 1, + "=MNO": 1 + } + } + } + end + let(:variables_attributes) do + [ + { "key" => "FOO", "variable_type" => "env_var", "secret_value" => "123" } + ] + end + + before do + params[:push_options] = push_options + end + + it_behaves_like 'creates pipeline with params and expected variables' + end + end end diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index febd4992682..19d7b84a3ce 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -86,6 +86,7 @@ describe Git::BranchPushService, services: true do after: newrev, ref: ref, checkout_sha: SeedRepo::Commit::ID, + variables_attributes: [], push_options: {} }).and_call_original |