diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 12:08:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 12:08:13 +0300 |
commit | 8e94dad32b10edebf79285c083176c2b7005ef64 (patch) | |
tree | 3bb66395f2962063ca0d20f98b35ac852d801c7e /spec | |
parent | ab128cc125f9db0c3a1bd48845f90c3d61ef42c9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 75 insertions, 27 deletions
diff --git a/spec/frontend/helpers/dom_shims/form_element.js b/spec/frontend/helpers/dom_shims/form_element.js new file mode 100644 index 00000000000..46ef0374848 --- /dev/null +++ b/spec/frontend/helpers/dom_shims/form_element.js @@ -0,0 +1 @@ +HTMLFormElement.prototype.submit = jest.fn(); diff --git a/spec/frontend/helpers/dom_shims/index.js b/spec/frontend/helpers/dom_shims/index.js index 855b707a4cf..bcd5da0ce48 100644 --- a/spec/frontend/helpers/dom_shims/index.js +++ b/spec/frontend/helpers/dom_shims/index.js @@ -1,4 +1,5 @@ import './element_scroll_into_view'; +import './form_element'; import './get_client_rects'; import './inner_text'; import './window_scroll_to'; diff --git a/spec/frontend/vue_shared/components/confirm_modal_spec.js b/spec/frontend/vue_shared/components/confirm_modal_spec.js index 722380d3383..d3dea73e4a6 100644 --- a/spec/frontend/vue_shared/components/confirm_modal_spec.js +++ b/spec/frontend/vue_shared/components/confirm_modal_spec.js @@ -3,6 +3,8 @@ import { GlModal } from '@gitlab/ui'; import { TEST_HOST } from 'helpers/test_constants'; import ConfirmModal from '~/vue_shared/components/confirm_modal.vue'; +jest.mock('~/lib/utils/csrf', () => ({ token: 'test-csrf-token' })); + describe('vue_shared/components/confirm_modal', () => { const testModalProps = { path: `${TEST_HOST}/1`, @@ -39,45 +41,61 @@ describe('vue_shared/components/confirm_modal', () => { }); const findModal = () => wrapper.find(GlModal); + const findForm = () => wrapper.find('form'); + const findFormData = () => + findForm() + .findAll('input') + .wrappers.map(x => ({ name: x.attributes('name'), value: x.attributes('value') })); describe('template', () => { - beforeEach(() => { - createComponent(); - }); + describe('when showModal is false', () => { + beforeEach(() => { + createComponent(); + }); - it('calls openModal on mount', () => { - expect(actionSpies.openModal).toHaveBeenCalled(); + it('does not render GlModal', () => { + expect(findModal().exists()).toBeFalsy(); + }); }); - it('renders GlModal', () => { - expect(findModal().exists()).toBeTruthy(); + describe('when showModal is true', () => { + beforeEach(() => { + createComponent({ showModal: true }); + }); + + it('renders GlModal', () => { + expect(findModal().exists()).toBeTruthy(); + expect(findModal().attributes()).toEqual( + expect.objectContaining({ + modalid: testModalProps.modalAttributes.modalId, + oktitle: testModalProps.modalAttributes.okTitle, + okvariant: testModalProps.modalAttributes.okVariant, + }), + ); + }); }); }); describe('methods', () => { beforeEach(() => { - createComponent(); + createComponent({ showModal: true }); }); - describe('submitModal', () => { - beforeEach(() => { - wrapper.vm.$refs.form.requestSubmit = jest.fn(); - }); - - it('calls requestSubmit', () => { - wrapper.vm.submitModal(); - expect(wrapper.vm.$refs.form.requestSubmit).toHaveBeenCalled(); - }); + it('does not submit form', () => { + expect(findForm().element.submit).not.toHaveBeenCalled(); }); - describe('dismiss', () => { - it('removes gl-modal', () => { - expect(findModal().exists()).toBeTruthy(); - wrapper.vm.dismiss(); + describe('when modal submitted', () => { + beforeEach(() => { + findModal().vm.$emit('primary'); + }); - return wrapper.vm.$nextTick(() => { - expect(findModal().exists()).toBeFalsy(); - }); + it('submits form', () => { + expect(findFormData()).toEqual([ + { name: '_method', value: testModalProps.method }, + { name: 'authenticity_token', value: 'test-csrf-token' }, + ]); + expect(findForm().element.submit).toHaveBeenCalled(); }); }); }); diff --git a/spec/lib/banzai/filter/repository_link_filter_spec.rb b/spec/lib/banzai/filter/repository_link_filter_spec.rb index cf73c77ecb8..f093a5b0a79 100644 --- a/spec/lib/banzai/filter/repository_link_filter_spec.rb +++ b/spec/lib/banzai/filter/repository_link_filter_spec.rb @@ -149,6 +149,34 @@ describe Banzai::Filter::RepositoryLinkFilter do end shared_examples :valid_repository do + it 'handles Gitaly unavailable exceptions gracefully' do + allow_next_instance_of(Gitlab::GitalyClient::BlobService) do |blob_service| + allow(blob_service).to receive(:get_blob_types).and_raise(GRPC::Unavailable) + end + + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + an_instance_of(GRPC::Unavailable), project_id: project.id + ) + doc = "" + expect { doc = filter(link('doc/api/README.md')) }.not_to raise_error + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" + end + + it 'handles Gitaly timeout exceptions gracefully' do + allow_next_instance_of(Gitlab::GitalyClient::BlobService) do |blob_service| + allow(blob_service).to receive(:get_blob_types).and_raise(GRPC::DeadlineExceeded) + end + + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + an_instance_of(GRPC::DeadlineExceeded), project_id: project.id + ) + doc = "" + expect { doc = filter(link('doc/api/README.md')) }.not_to raise_error + expect(doc.at_css('a')['href']) + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" + end + it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) expect(doc.at_css('a')['href']) diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb index 31209a70018..d7fd0d06b05 100644 --- a/spec/models/clusters/applications/cert_manager_spec.rb +++ b/spec/models/clusters/applications/cert_manager_spec.rb @@ -46,11 +46,11 @@ describe Clusters::Applications::CertManager do expect(subject.name).to eq('certmanager') expect(subject.chart).to eq('certmanager/cert-manager') expect(subject.repository).to eq('https://charts.jetstack.io') - expect(subject.version).to eq('v0.9.1') + expect(subject.version).to eq('v0.10.1') expect(subject).to be_rbac expect(subject.files).to eq(cert_manager.files.merge(cluster_issuer_file)) expect(subject.preinstall).to eq([ - 'kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.9/deploy/manifests/00-crds.yaml', + 'kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.10/deploy/manifests/00-crds.yaml', 'kubectl label --overwrite namespace gitlab-managed-apps certmanager.k8s.io/disable-validation=true' ]) expect(subject.postinstall).to eq([ @@ -82,7 +82,7 @@ describe Clusters::Applications::CertManager do let(:cert_manager) { create(:clusters_applications_cert_manager, :errored, version: '0.0.1') } it 'is initialized with the locked version' do - expect(subject.version).to eq('v0.9.1') + expect(subject.version).to eq('v0.10.1') end end end |