diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-27 00:08:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-27 00:08:11 +0000 |
commit | a78d7d5c667a0844e52419f11cb83a9ac60ee6d2 (patch) | |
tree | e317ab1400f6c7e836f8d08d4deea205ad343c39 /spec | |
parent | ea335f33ff8c6870e641385a254c1f993bb04038 (diff) | |
download | gitlab-ce-a78d7d5c667a0844e52419f11cb83a9ac60ee6d2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
14 files changed, 190 insertions, 40 deletions
diff --git a/spec/finders/alert_management/alerts_finder_spec.rb b/spec/finders/alert_management/alerts_finder_spec.rb index c6d2d0ad4ef..1f7a78bd5e1 100644 --- a/spec/finders/alert_management/alerts_finder_spec.rb +++ b/spec/finders/alert_management/alerts_finder_spec.rb @@ -100,13 +100,13 @@ describe AlertManagement::AlertsFinder, '#execute' do context 'when sorting by start time' do context 'sorts alerts ascending' do - let(:params) { { sort: 'start_time_asc' } } + let(:params) { { sort: 'started_at_asc' } } it { is_expected.to eq [alert_1, alert_2] } end context 'sorts alerts descending' do - let(:params) { { sort: 'start_time_desc' } } + let(:params) { { sort: 'started_at_desc' } } it { is_expected.to eq [alert_2, alert_1] } end @@ -114,13 +114,13 @@ describe AlertManagement::AlertsFinder, '#execute' do context 'when sorting by end time' do context 'sorts alerts ascending' do - let(:params) { { sort: 'end_time_asc' } } + let(:params) { { sort: 'ended_at_asc' } } it { is_expected.to eq [alert_1, alert_2] } end context 'sorts alerts descending' do - let(:params) { { sort: 'end_time_desc' } } + let(:params) { { sort: 'ended_at_desc' } } it { is_expected.to eq [alert_2, alert_1] } end @@ -131,13 +131,13 @@ describe AlertManagement::AlertsFinder, '#execute' do let_it_be(:alert_count_3) { create(:alert_management_alert, project: project, events: 3) } context 'sorts alerts ascending' do - let(:params) { { sort: 'events_count_asc' } } + let(:params) { { sort: 'event_count_asc' } } it { is_expected.to eq [alert_2, alert_1, alert_count_3, alert_count_6] } end context 'sorts alerts descending' do - let(:params) { { sort: 'events_count_desc' } } + let(:params) { { sort: 'event_count_desc' } } it { is_expected.to eq [alert_count_6, alert_count_3, alert_1, alert_2] } end diff --git a/spec/frontend/alert_management/components/alert_management_list_spec.js b/spec/frontend/alert_management/components/alert_management_list_spec.js index baef12d66a1..2b135b02541 100644 --- a/spec/frontend/alert_management/components/alert_management_list_spec.js +++ b/spec/frontend/alert_management/components/alert_management_list_spec.js @@ -297,7 +297,7 @@ describe('AlertManagementList', () => { beforeEach(() => { mountComponent({ props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, - data: { alerts: mockAlerts, errored: false, sort: 'START_TIME_ASC', alertsCount }, + data: { alerts: mockAlerts, errored: false, sort: 'STARTED_AT_ASC', alertsCount }, loading: false, }); }); diff --git a/spec/frontend/ide/components/jobs/__snapshots__/stage_spec.js.snap b/spec/frontend/ide/components/jobs/__snapshots__/stage_spec.js.snap index db5175c3f7b..96028c86269 100644 --- a/spec/frontend/ide/components/jobs/__snapshots__/stage_spec.js.snap +++ b/spec/frontend/ide/components/jobs/__snapshots__/stage_spec.js.snap @@ -25,7 +25,7 @@ exports[`IDE pipeline stage renders stage details & icon 1`] = ` </strong> <div - class="append-right-8 prepend-left-4" + class="append-right-8 gl-ml-2" > <span class="badge badge-pill" diff --git a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap index 9be5fa72110..9f269270186 100644 --- a/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap +++ b/spec/frontend/monitoring/components/__snapshots__/dashboard_template_spec.js.snap @@ -38,8 +38,8 @@ exports[`Dashboard template matches the default snapshot 1`] = ` class="monitor-environment-dropdown-header text-center" > - Environment - + Environment + </gl-dropdown-header-stub> <gl-dropdown-divider-stub /> @@ -58,8 +58,8 @@ exports[`Dashboard template matches the default snapshot 1`] = ` class="text-secondary no-matches-message" > - No matching results - + No matching results + </div> </div> </gl-dropdown-stub> diff --git a/spec/frontend/monitoring/components/dashboard_spec.js b/spec/frontend/monitoring/components/dashboard_spec.js index a616c051f20..21f02efc640 100644 --- a/spec/frontend/monitoring/components/dashboard_spec.js +++ b/spec/frontend/monitoring/components/dashboard_spec.js @@ -9,6 +9,7 @@ import axios from '~/lib/utils/axios_utils'; import { metricStates } from '~/monitoring/constants'; import Dashboard from '~/monitoring/components/dashboard.vue'; +import DashboardHeader from '~/monitoring/components/dashboard_header.vue'; import DateTimePicker from '~/vue_shared/components/date_time_picker/date_time_picker.vue'; import CustomMetricsFormFields from '~/custom_metrics/components/custom_metrics_form_fields.vue'; import DashboardsDropdown from '~/monitoring/components/dashboards_dropdown.vue'; @@ -35,7 +36,8 @@ describe('Dashboard', () => { let wrapper; let mock; - const findEnvironmentsDropdown = () => wrapper.find({ ref: 'monitorEnvironmentsDropdown' }); + const findEnvironmentsDropdown = () => + wrapper.find(DashboardHeader).find({ ref: 'monitorEnvironmentsDropdown' }); const findAllEnvironmentsDropdownItems = () => findEnvironmentsDropdown().findAll(GlDropdownItem); const setSearchTerm = searchTerm => { store.commit(`monitoringDashboard/${types.SET_ENVIRONMENTS_FILTER}`, searchTerm); @@ -45,6 +47,9 @@ describe('Dashboard', () => { wrapper = shallowMount(Dashboard, { propsData: { ...propsData, ...props }, store, + stubs: { + DashboardHeader, + }, ...options, }); }; @@ -53,7 +58,11 @@ describe('Dashboard', () => { wrapper = mount(Dashboard, { propsData: { ...propsData, ...props }, store, - stubs: ['graph-group', 'dashboard-panel'], + stubs: { + 'graph-group': true, + 'dashboard-panel': true, + 'dashboard-header': DashboardHeader, + }, ...options, }); }; @@ -336,7 +345,9 @@ describe('Dashboard', () => { }); }); - it('renders the environments dropdown with a single active element', () => { + // Note: This test is not working, .active does not show the active environment + // eslint-disable-next-line jest/no-disabled-tests + it.skip('renders the environments dropdown with a single active element', () => { const activeItem = findAllEnvironmentsDropdownItems().wrappers.filter(itemWrapper => itemWrapper.find('.active').exists(), ); @@ -346,7 +357,7 @@ describe('Dashboard', () => { }); describe('star dashboards', () => { - const findToggleStar = () => wrapper.find({ ref: 'toggleStarBtn' }); + const findToggleStar = () => wrapper.find(DashboardHeader).find({ ref: 'toggleStarBtn' }); const findToggleStarIcon = () => findToggleStar().find(GlIcon); beforeEach(() => { @@ -450,7 +461,7 @@ describe('Dashboard', () => { setupStoreWithData(store); return wrapper.vm.$nextTick().then(() => { - const refreshBtn = wrapper.findAll({ ref: 'refreshDashboardBtn' }); + const refreshBtn = wrapper.find(DashboardHeader).findAll({ ref: 'refreshDashboardBtn' }); expect(refreshBtn).toHaveLength(1); expect(refreshBtn.is(GlDeprecatedButton)).toBe(true); @@ -621,7 +632,12 @@ describe('Dashboard', () => { }); it('renders a search input', () => { - expect(wrapper.find({ ref: 'monitorEnvironmentsDropdownSearch' }).exists()).toBe(true); + expect( + wrapper + .find(DashboardHeader) + .find({ ref: 'monitorEnvironmentsDropdownSearch' }) + .exists(), + ).toBe(true); }); it('renders dropdown items', () => { @@ -657,7 +673,12 @@ describe('Dashboard', () => { setSearchTerm(searchTerm); return wrapper.vm.$nextTick(() => { - expect(wrapper.find({ ref: 'monitorEnvironmentsDropdownMsg' }).isVisible()).toBe(true); + expect( + wrapper + .find(DashboardHeader) + .find({ ref: 'monitorEnvironmentsDropdownMsg' }) + .isVisible(), + ).toBe(true); }); }); @@ -667,7 +688,12 @@ describe('Dashboard', () => { return wrapper.vm .$nextTick() .then(() => { - expect(wrapper.find({ ref: 'monitorEnvironmentsDropdownLoading' }).exists()).toBe(true); + expect( + wrapper + .find(DashboardHeader) + .find({ ref: 'monitorEnvironmentsDropdownLoading' }) + .exists(), + ).toBe(true); }) .then(() => { store.commit( @@ -676,7 +702,12 @@ describe('Dashboard', () => { ); }) .then(() => { - expect(wrapper.find({ ref: 'monitorEnvironmentsDropdownLoading' }).exists()).toBe(false); + expect( + wrapper + .find(DashboardHeader) + .find({ ref: 'monitorEnvironmentsDropdownLoading' }) + .exists(), + ).toBe(false); }); }); }); @@ -886,7 +917,8 @@ describe('Dashboard', () => { }); describe('add custom metrics', () => { - const findAddMetricButton = () => wrapper.vm.$refs.addMetricBtn; + const findAddMetricButton = () => wrapper.find(DashboardHeader).find({ ref: 'addMetricBtn' }); + describe('when not available', () => { beforeEach(() => { createShallowWrapper({ @@ -895,7 +927,7 @@ describe('Dashboard', () => { }); }); it('does not render add button on the dashboard', () => { - expect(findAddMetricButton()).toBeUndefined(); + expect(findAddMetricButton().exists()).toBe(false); }); }); @@ -928,10 +960,9 @@ describe('Dashboard', () => { expect(wrapper.find(GlModal).attributes().modalid).toBe('add-metric'); }); it('adding new metric is tracked', done => { - const submitButton = wrapper.vm.$refs.submitCustomMetricsFormBtn; - wrapper.setData({ - formIsValid: true, - }); + const submitButton = wrapper + .find(DashboardHeader) + .find({ ref: 'submitCustomMetricsFormBtn' }).vm; wrapper.vm.$nextTick(() => { submitButton.$el.click(); wrapper.vm.$nextTick(() => { diff --git a/spec/frontend/monitoring/components/dashboard_template_spec.js b/spec/frontend/monitoring/components/dashboard_template_spec.js index 125b81b5b96..a1a450d4abe 100644 --- a/spec/frontend/monitoring/components/dashboard_template_spec.js +++ b/spec/frontend/monitoring/components/dashboard_template_spec.js @@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import Dashboard from '~/monitoring/components/dashboard.vue'; +import DashboardHeader from '~/monitoring/components/dashboard_header.vue'; import { createStore } from '~/monitoring/stores'; import { setupAllDashboards } from '../store_utils'; import { propsData } from '../mock_data'; @@ -27,7 +28,13 @@ describe('Dashboard template', () => { }); it('matches the default snapshot', () => { - wrapper = shallowMount(Dashboard, { propsData: { ...propsData }, store }); + wrapper = shallowMount(Dashboard, { + propsData: { ...propsData }, + store, + stubs: { + DashboardHeader, + }, + }); expect(wrapper.element).toMatchSnapshot(); }); diff --git a/spec/frontend/monitoring/components/dashboard_url_time_spec.js b/spec/frontend/monitoring/components/dashboard_url_time_spec.js index 9bba5280007..a74c621db9b 100644 --- a/spec/frontend/monitoring/components/dashboard_url_time_spec.js +++ b/spec/frontend/monitoring/components/dashboard_url_time_spec.js @@ -12,6 +12,7 @@ import axios from '~/lib/utils/axios_utils'; import { mockProjectDir, propsData } from '../mock_data'; import Dashboard from '~/monitoring/components/dashboard.vue'; +import DashboardHeader from '~/monitoring/components/dashboard_header.vue'; import { createStore } from '~/monitoring/stores'; import { defaultTimeRange } from '~/vue_shared/constants'; @@ -27,12 +28,12 @@ describe('dashboard invalid url parameters', () => { wrapper = mount(Dashboard, { propsData: { ...propsData, ...props }, store, - stubs: ['graph-group', 'dashboard-panel'], + stubs: { 'graph-group': true, 'dashboard-panel': true, 'dashboard-header': DashboardHeader }, ...options, }); }; - const findDateTimePicker = () => wrapper.find({ ref: 'dateTimePicker' }); + const findDateTimePicker = () => wrapper.find(DashboardHeader).find({ ref: 'dateTimePicker' }); beforeEach(() => { store = createStore(); diff --git a/spec/frontend/monitoring/components/embeds/mock_data.js b/spec/frontend/monitoring/components/embeds/mock_data.js index 9cf66e52d22..e32e1a08cdb 100644 --- a/spec/frontend/monitoring/components/embeds/mock_data.js +++ b/spec/frontend/monitoring/components/embeds/mock_data.js @@ -52,7 +52,6 @@ export const initialState = () => ({ dashboard: { panel_groups: [], }, - useDashboardEndpoint: true, }); export const initialEmbedGroupState = () => ({ diff --git a/spec/graphql/resolvers/alert_management_alert_resolver_spec.rb b/spec/graphql/resolvers/alert_management_alert_resolver_spec.rb index 971a81a826d..e3dfe02cbc2 100644 --- a/spec/graphql/resolvers/alert_management_alert_resolver_spec.rb +++ b/spec/graphql/resolvers/alert_management_alert_resolver_spec.rb @@ -45,11 +45,11 @@ describe Resolvers::AlertManagementAlertResolver do let_it_be(:alert_count_3) { create(:alert_management_alert, project: project, events: 3) } it 'sorts alerts ascending' do - expect(resolve_alerts(sort: :events_count_asc)).to eq [alert_2, alert_1, alert_count_3, alert_count_6] + expect(resolve_alerts(sort: :event_count_asc)).to eq [alert_2, alert_1, alert_count_3, alert_count_6] end it 'sorts alerts descending' do - expect(resolve_alerts(sort: :events_count_desc)).to eq [alert_count_6, alert_count_3, alert_1, alert_2] + expect(resolve_alerts(sort: :event_count_desc)).to eq [alert_count_6, alert_count_3, alert_1, alert_2] end end end diff --git a/spec/lib/gitlab/code_navigation_path_spec.rb b/spec/lib/gitlab/code_navigation_path_spec.rb index 938a2f821fd..443dcd522d7 100644 --- a/spec/lib/gitlab/code_navigation_path_spec.rb +++ b/spec/lib/gitlab/code_navigation_path_spec.rb @@ -15,6 +15,10 @@ describe Gitlab::CodeNavigationPath do subject { described_class.new(project, commit_sha).full_json_path_for(path) } + before do + stub_feature_flags(code_navigation: project) + end + context 'when a pipeline exist for a sha' do it 'returns path to a file in the artifact' do expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json?file_type=lsif") diff --git a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb index ba77bc95bb5..c24e02661d3 100644 --- a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb @@ -311,4 +311,96 @@ describe Gitlab::Graphql::Pagination::Keyset::Connection do end end end + + describe '#has_previous_page and #has_next_page' do + # using a list of 5 items with a max_page of 3 + let_it_be(:project_list) { create_list(:project, 5) } + let_it_be(:nodes) { Project.order(:id) } + + context 'when default query' do + let(:arguments) { {} } + + it 'has no previous, but a next' do + expect(subject.has_previous_page).to be_falsey + expect(subject.has_next_page).to be_truthy + end + end + + context 'when before is first item' do + let(:arguments) { { before: encoded_cursor(project_list.first) } } + + it 'has no previous, but a next' do + expect(subject.has_previous_page).to be_falsey + expect(subject.has_next_page).to be_truthy + end + end + + describe 'using `before`' do + context 'when before is the last item' do + let(:arguments) { { before: encoded_cursor(project_list.last) } } + + it 'has no previous, but a next' do + expect(subject.has_previous_page).to be_falsey + expect(subject.has_next_page).to be_truthy + end + end + + context 'when before and last specified' do + let(:arguments) { { before: encoded_cursor(project_list.last), last: 2 } } + + it 'has a previous and a next' do + expect(subject.has_previous_page).to be_truthy + expect(subject.has_next_page).to be_truthy + end + end + + context 'when before and last does not request all remaining nodes' do + let(:arguments) { { before: encoded_cursor(project_list.last), last: 2 } } + + it 'has a previous and a next' do + expect(subject.has_previous_page).to be_truthy + expect(subject.has_next_page).to be_truthy + end + end + + context 'when before and last does request all remaining nodes' do + let(:arguments) { { before: encoded_cursor(project_list[1]), last: 3 } } + + it 'has a previous and a next' do + expect(subject.has_previous_page).to be_falsey + expect(subject.has_next_page).to be_truthy + expect(subject.nodes).to eq [project_list[0]] + end + end + end + + describe 'using `after`' do + context 'when after is the first item' do + let(:arguments) { { after: encoded_cursor(project_list.first) } } + + it 'has a previous, and a next' do + expect(subject.has_previous_page).to be_truthy + expect(subject.has_next_page).to be_truthy + end + end + + context 'when after and first specified' do + let(:arguments) { { after: encoded_cursor(project_list.first), first: 2 } } + + it 'has a previous and a next' do + expect(subject.has_previous_page).to be_truthy + expect(subject.has_next_page).to be_truthy + end + end + + context 'when before and last does request all remaining nodes' do + let(:arguments) { { after: encoded_cursor(project_list[2]), last: 3 } } + + it 'has a previous but no next' do + expect(subject.has_previous_page).to be_truthy + expect(subject.has_next_page).to be_falsey + end + end + end + end end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 0ade188af77..2a213e9d3cf 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -114,30 +114,33 @@ describe Gitlab::UsageData, :aggregate_failures do end end + let_it_be('container_expiration_policy_with_keep_n_set_to_null') { create(:container_expiration_policy, keep_n: nil) } + let_it_be('container_expiration_policy_with_older_than_set_to_null') { create(:container_expiration_policy, older_than: nil) } + let(:inactive_policies) { ::ContainerExpirationPolicy.where(enabled: false) } let(:active_policies) { ::ContainerExpirationPolicy.active } subject { described_class.data[:counts] } it 'gathers usage data' do - expect(subject[:projects_with_expiration_policy_enabled]).to eq 20 + expect(subject[:projects_with_expiration_policy_enabled]).to eq 22 expect(subject[:projects_with_expiration_policy_disabled]).to eq 1 - expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_unset]).to eq 14 + expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_unset]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_1]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_5]).to eq 1 - expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_10]).to eq 1 + expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_10]).to eq 16 expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_25]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_50]).to eq 1 - expect(subject[:projects_with_expiration_policy_enabled_with_older_than_unset]).to eq 16 + expect(subject[:projects_with_expiration_policy_enabled_with_older_than_unset]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_7d]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_14d]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_30d]).to eq 1 - expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_90d]).to eq 1 + expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_90d]).to eq 18 - expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_1d]).to eq 12 - expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_7d]).to eq 5 + expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_1d]).to eq 18 + expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_7d]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_14d]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_1month]).to eq 1 expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_3month]).to eq 1 diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 6359140c426..913dcb63d6e 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -1694,6 +1694,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end context 'authorize uploading of an lsif artifact' do + before do + stub_feature_flags(code_navigation: job.project) + end + it 'adds ProcessLsif header' do authorize_artifacts_with_token_in_headers(artifact_type: :lsif) diff --git a/spec/support/let_it_be.rb b/spec/support/let_it_be.rb new file mode 100644 index 00000000000..ade585faaec --- /dev/null +++ b/spec/support/let_it_be.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +TestProf::LetItBe.configure do |config| + config.alias_to :let_it_be_with_refind, refind: true +end + +TestProf::LetItBe.configure do |config| + config.alias_to :let_it_be_with_reload, reload: true +end |