diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 12:10:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 12:10:41 +0300 |
commit | edf0e5b64384499283b406f9087e890ac4fad13f (patch) | |
tree | 5b634c08f9324749ee06b85334e2fad8340092ac /spec | |
parent | dd4c30182c16fe27efbbf4c19594bb292fb4ac48 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
7 files changed, 78 insertions, 14 deletions
diff --git a/spec/frontend/admin/applications/components/delete_application_spec.js b/spec/frontend/admin/applications/components/delete_application_spec.js index 315c38a2bbc..e0282b8c149 100644 --- a/spec/frontend/admin/applications/components/delete_application_spec.js +++ b/spec/frontend/admin/applications/components/delete_application_spec.js @@ -1,6 +1,7 @@ import { GlModal, GlSprintf } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; +import { stubComponent } from 'helpers/stub_component'; import DeleteApplication from '~/admin/applications/components/delete_application.vue'; const path = 'application/path/1'; @@ -14,6 +15,11 @@ describe('DeleteApplication', () => { const createComponent = () => { wrapper = shallowMount(DeleteApplication, { stubs: { + GlModal: stubComponent(GlModal, { + methods: { + show: jest.fn(), + }, + }), GlSprintf, }, }); @@ -36,7 +42,6 @@ describe('DeleteApplication', () => { describe('the modal component', () => { beforeEach(() => { - wrapper.vm.$refs.deleteModal.show = jest.fn(); document.querySelector('.js-application-delete-button').click(); }); diff --git a/spec/frontend/clusters/agents/components/revoke_token_button_spec.js b/spec/frontend/clusters/agents/components/revoke_token_button_spec.js index 970782a8e58..de47ff78696 100644 --- a/spec/frontend/clusters/agents/components/revoke_token_button_spec.js +++ b/spec/frontend/clusters/agents/components/revoke_token_button_spec.js @@ -2,6 +2,7 @@ import { GlButton, GlModal, GlFormInput, GlTooltip } from '@gitlab/ui'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; +import { stubComponent } from 'helpers/stub_component'; import waitForPromises from 'helpers/wait_for_promises'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { ENTER_KEY } from '~/lib/utils/keys'; @@ -81,12 +82,15 @@ describe('RevokeTokenButton', () => { }, propsData, stubs: { - GlModal, + GlModal: stubComponent(GlModal, { + methods: { + hide: jest.fn(), + }, + }), GlTooltip, }, mocks: { $toast: { show: toast } }, }); - wrapper.vm.$refs.modal.hide = jest.fn(); writeQuery(); await nextTick(); diff --git a/spec/frontend/clusters_list/components/delete_agent_button_spec.js b/spec/frontend/clusters_list/components/delete_agent_button_spec.js index 8bbb5ec92a7..afb12d9c856 100644 --- a/spec/frontend/clusters_list/components/delete_agent_button_spec.js +++ b/spec/frontend/clusters_list/components/delete_agent_button_spec.js @@ -9,6 +9,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import DeleteAgentButton from '~/clusters_list/components/delete_agent_button.vue'; import { DELETE_AGENT_BUTTON } from '~/clusters_list/constants'; +import { stubComponent } from 'helpers/stub_component'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { getAgentResponse, mockDeleteResponse, mockErrorDeleteResponse } from '../mocks/apollo'; @@ -84,9 +85,14 @@ describe('DeleteAgentButton', () => { }, propsData, mocks: { $toast: { show: toast } }, - stubs: { GlModal }, + stubs: { + GlModal: stubComponent(GlModal, { + methods: { + hide: jest.fn(), + }, + }), + }, }); - wrapper.vm.$refs.modal.hide = jest.fn(); writeQuery(); await nextTick(); diff --git a/spec/frontend/issuable/components/related_issuable_item_spec.js b/spec/frontend/issuable/components/related_issuable_item_spec.js index 7322894164b..bfb0aaa1c67 100644 --- a/spec/frontend/issuable/components/related_issuable_item_spec.js +++ b/spec/frontend/issuable/components/related_issuable_item_spec.js @@ -236,23 +236,21 @@ describe('RelatedIssuableItem', () => { describe('when work item is issue and the related issue title is clicked', () => { it('does not open', () => { mountComponent({ props: { workItemType: 'ISSUE' } }); - wrapper.vm.$refs.modal.show = jest.fn(); findTitleLink().vm.$emit('click', { preventDefault: () => {} }); - expect(wrapper.vm.$refs.modal.show).not.toHaveBeenCalled(); + expect(showModalSpy).not.toHaveBeenCalled(); }); }); describe('when work item is task and the related issue title is clicked', () => { beforeEach(() => { mountComponent({ props: { workItemType: 'TASK' } }); - wrapper.vm.$refs.modal.show = jest.fn(); findTitleLink().vm.$emit('click', { preventDefault: () => {} }); }); it('opens', () => { - expect(wrapper.vm.$refs.modal.show).toHaveBeenCalled(); + expect(showModalSpy).toHaveBeenCalled(); }); it('updates the url params with the work item id', () => { diff --git a/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js b/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js index d83a9192876..0b1ad0a2327 100644 --- a/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js +++ b/spec/frontend/monitoring/components/duplicate_dashboard_modal_spec.js @@ -3,6 +3,7 @@ import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; +import { stubComponent } from 'helpers/stub_component'; import waitForPromises from 'helpers/wait_for_promises'; import DuplicateDashboardForm from '~/monitoring/components/duplicate_dashboard_form.vue'; @@ -19,6 +20,8 @@ describe('duplicate dashboard modal', () => { let duplicateDashboardAction; let okEvent; + const modalHideSpy = jest.fn(); + function createComponent() { const store = new Vuex.Store({ modules: { @@ -41,6 +44,13 @@ describe('duplicate dashboard modal', () => { modalId: 'id', }, store, + stubs: { + GlModal: stubComponent(GlModal, { + methods: { + hide: modalHideSpy, + }, + }), + }, }); } @@ -59,8 +69,6 @@ describe('duplicate dashboard modal', () => { }; wrapper = createComponent(); - - wrapper.vm.$refs.duplicateDashboardModal.hide = jest.fn(); }); it('contains a form to duplicate a dashboard', () => { @@ -75,7 +83,7 @@ describe('duplicate dashboard modal', () => { expect(wrapper.emitted('dashboardDuplicated')).toHaveLength(1); expect(wrapper.emitted().dashboardDuplicated[0]).toEqual([dashboardGitResponse[0]]); expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(false); - expect(wrapper.vm.$refs.duplicateDashboardModal.hide).toHaveBeenCalled(); + expect(modalHideSpy).toHaveBeenCalled(); expect(findAlert().exists()).toBe(false); }); @@ -93,7 +101,7 @@ describe('duplicate dashboard modal', () => { expect(findAlert().text()).toBe(errMsg); expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(false); - expect(wrapper.vm.$refs.duplicateDashboardModal.hide).not.toHaveBeenCalled(); + expect(modalHideSpy).not.toHaveBeenCalled(); }); it('updates the form on changes', () => { diff --git a/spec/models/ci/runner_manager_spec.rb b/spec/models/ci/runner_manager_spec.rb index d69c9ef845e..80cffb98dff 100644 --- a/spec/models/ci/runner_manager_spec.rb +++ b/spec/models/ci/runner_manager_spec.rb @@ -69,6 +69,49 @@ RSpec.describe Ci::RunnerManager, feature_category: :runner_fleet, type: :model it { is_expected.to eq(7.days.ago) } end + describe '.for_runner' do + subject(:runner_managers) { described_class.for_runner(runner_arg) } + + let_it_be(:runner1) { create(:ci_runner) } + let_it_be(:runner_manager11) { create(:ci_runner_machine, runner: runner1) } + let_it_be(:runner_manager12) { create(:ci_runner_machine, runner: runner1) } + + context 'with single runner' do + let(:runner_arg) { runner1 } + + it { is_expected.to contain_exactly(runner_manager11, runner_manager12) } + end + + context 'with multiple runners' do + let(:runner_arg) { [runner1, runner2] } + + let_it_be(:runner2) { create(:ci_runner) } + let_it_be(:runner_manager2) { create(:ci_runner_machine, runner: runner2) } + + it { is_expected.to contain_exactly(runner_manager11, runner_manager12, runner_manager2) } + end + end + + describe '.aggregate_upgrade_status_by_runner_id' do + let!(:runner_version1) { create(:ci_runner_version, version: '16.0.0', status: :recommended) } + let!(:runner_version2) { create(:ci_runner_version, version: '16.0.1', status: :available) } + + let!(:runner1) { create(:ci_runner) } + let!(:runner2) { create(:ci_runner) } + let!(:runner_manager11) { create(:ci_runner_machine, runner: runner1, version: runner_version1.version) } + let!(:runner_manager12) { create(:ci_runner_machine, runner: runner1, version: runner_version2.version) } + let!(:runner_manager2) { create(:ci_runner_machine, runner: runner2, version: runner_version2.version) } + + subject { described_class.aggregate_upgrade_status_by_runner_id } + + it 'contains aggregate runner upgrade status by runner ID' do + is_expected.to eq({ + runner1.id => :recommended, + runner2.id => :available + }) + end + end + describe '#status', :freeze_time do let(:runner_manager) { build(:ci_runner_machine, created_at: 8.days.ago) } diff --git a/spec/models/integrations/unify_circuit_spec.rb b/spec/models/integrations/unify_circuit_spec.rb index 7a91b2d3c11..017443c799f 100644 --- a/spec/models/integrations/unify_circuit_spec.rb +++ b/spec/models/integrations/unify_circuit_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -RSpec.describe Integrations::UnifyCircuit do +RSpec.describe Integrations::UnifyCircuit, feature_category: :integrations do it_behaves_like "chat integration", "Unify Circuit" do let(:client_arguments) { webhook_url } let(:payload) do |