Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb33
-rw-r--r--spec/features/groups/group_page_with_external_authorization_service_spec.rb6
-rw-r--r--spec/features/groups/navbar_spec.rb3
-rw-r--r--spec/features/groups_spec.rb6
-rw-r--r--spec/frontend/boards/components/board_card_spec.js100
-rw-r--r--spec/frontend/lib/utils/recurrence_spec.js333
-rw-r--r--spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js74
-rw-r--r--spec/frontend/pipeline_editor/pipeline_editor_home_spec.js26
-rw-r--r--spec/graphql/resolvers/metadata_resolver_spec.rb5
-rw-r--r--spec/graphql/types/metadata/kas_type_spec.rb8
-rw-r--r--spec/lib/gitlab/kas_spec.rb40
-rw-r--r--spec/models/instance_metadata/kas_spec.rb33
-rw-r--r--spec/models/instance_metadata_spec.rb3
-rw-r--r--spec/presenters/ci/stage_presenter_spec.rb49
-rw-r--r--spec/requests/api/graphql/metadata_query_spec.rb46
-rw-r--r--spec/support/shared_contexts/navbar_structure_context.rb17
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb22
-rw-r--r--spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb34
18 files changed, 745 insertions, 93 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index 6236a47cde1..2cbc85232b4 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -290,6 +290,39 @@ RSpec.describe Projects::PipelinesController do
end
end
+ describe 'GET #show' do
+ render_views
+
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+
+ subject { get_pipeline_html }
+
+ def get_pipeline_html
+ get :show, params: { namespace_id: project.namespace, project_id: project, id: pipeline }, format: :html
+ end
+
+ def create_build_with_artifacts(stage, stage_idx, name)
+ create(:ci_build, :artifacts, :tags, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name)
+ end
+
+ before do
+ create_build_with_artifacts('build', 0, 'job1')
+ create_build_with_artifacts('build', 0, 'job2')
+ end
+
+ it 'avoids N+1 database queries', :request_store do
+ get_pipeline_html
+
+ control_count = ActiveRecord::QueryRecorder.new { get_pipeline_html }.count
+ expect(response).to have_gitlab_http_status(:ok)
+
+ create_build_with_artifacts('build', 0, 'job3')
+
+ expect { get_pipeline_html }.not_to exceed_query_limit(control_count)
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
+
describe 'GET show.json' do
let(:pipeline) { create(:ci_pipeline, project: project) }
diff --git a/spec/features/groups/group_page_with_external_authorization_service_spec.rb b/spec/features/groups/group_page_with_external_authorization_service_spec.rb
index 187d878472e..59a7feb813b 100644
--- a/spec/features/groups/group_page_with_external_authorization_service_spec.rb
+++ b/spec/features/groups/group_page_with_external_authorization_service_spec.rb
@@ -15,8 +15,7 @@ RSpec.describe 'The group page' do
def expect_all_sidebar_links
within('.nav-sidebar') do
- expect(page).to have_link('Group overview')
- expect(page).to have_link('Details')
+ expect(page).to have_link('Group information')
expect(page).to have_link('Activity')
expect(page).to have_link('Issues')
expect(page).to have_link('Merge requests')
@@ -44,8 +43,7 @@ RSpec.describe 'The group page' do
visit group_path(group)
within('.nav-sidebar') do
- expect(page).to have_link('Group overview')
- expect(page).to have_link('Details')
+ expect(page).to have_link('Group information')
expect(page).not_to have_link('Activity')
expect(page).not_to have_link('Contribution')
diff --git a/spec/features/groups/navbar_spec.rb b/spec/features/groups/navbar_spec.rb
index 021b1af54d4..7f0aef6b300 100644
--- a/spec/features/groups/navbar_spec.rb
+++ b/spec/features/groups/navbar_spec.rb
@@ -14,9 +14,8 @@ RSpec.describe 'Group navbar' do
let(:structure) do
[
{
- nav_item: _('Group overview'),
+ nav_item: _('Group information'),
nav_sub_items: [
- _('Details'),
_('Activity')
]
},
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb
index a43946925bf..0fab5718aa6 100644
--- a/spec/features/groups_spec.rb
+++ b/spec/features/groups_spec.rb
@@ -368,14 +368,14 @@ RSpec.describe 'Group' do
expect(page).to have_content(nested_group.name)
expect(page).to have_content(project.name)
- expect(page).to have_link('Group overview')
+ expect(page).to have_link('Group information')
end
- it 'renders subgroup page with the text "Subgroup overview"' do
+ it 'renders subgroup page with the text "Subgroup information"' do
visit group_path(nested_group)
wait_for_requests
- expect(page).to have_link('Subgroup overview')
+ expect(page).to have_link('Subgroup information')
end
it 'renders project page with the text "Project overview"' do
diff --git a/spec/frontend/boards/components/board_card_spec.js b/spec/frontend/boards/components/board_card_spec.js
index e95cb17ee84..ceafa6ead94 100644
--- a/spec/frontend/boards/components/board_card_spec.js
+++ b/spec/frontend/boards/components/board_card_spec.js
@@ -15,7 +15,7 @@ describe('Board card', () => {
const localVue = createLocalVue();
localVue.use(Vuex);
- const createStore = ({ initialState = {}, isSwimlanesOn = false } = {}) => {
+ const createStore = ({ initialState = {} } = {}) => {
mockActions = {
toggleBoardItem: jest.fn(),
toggleBoardItemMultiSelection: jest.fn(),
@@ -30,7 +30,6 @@ describe('Board card', () => {
},
actions: mockActions,
getters: {
- isSwimlanesOn: () => isSwimlanesOn,
isEpicBoard: () => false,
},
});
@@ -90,72 +89,65 @@ describe('Board card', () => {
});
});
- describe.each`
- isSwimlanesOn
- ${true} | ${false}
- `('when isSwimlanesOn is $isSwimlanesOn', ({ isSwimlanesOn }) => {
- it('should not highlight the card by default', async () => {
- createStore({ isSwimlanesOn });
- mountComponent();
+ it('should not highlight the card by default', async () => {
+ createStore();
+ mountComponent();
+
+ expect(wrapper.classes()).not.toContain('is-active');
+ expect(wrapper.classes()).not.toContain('multi-select');
+ });
- expect(wrapper.classes()).not.toContain('is-active');
- expect(wrapper.classes()).not.toContain('multi-select');
+ it('should highlight the card with a correct style when selected', async () => {
+ createStore({
+ initialState: {
+ activeId: mockIssue.id,
+ },
});
+ mountComponent();
- it('should highlight the card with a correct style when selected', async () => {
- createStore({
- initialState: {
- activeId: mockIssue.id,
- },
- isSwimlanesOn,
- });
- mountComponent();
+ expect(wrapper.classes()).toContain('is-active');
+ expect(wrapper.classes()).not.toContain('multi-select');
+ });
- expect(wrapper.classes()).toContain('is-active');
- expect(wrapper.classes()).not.toContain('multi-select');
+ it('should highlight the card with a correct style when multi-selected', async () => {
+ createStore({
+ initialState: {
+ activeId: inactiveId,
+ selectedBoardItems: [mockIssue],
+ },
});
+ mountComponent();
- it('should highlight the card with a correct style when multi-selected', async () => {
- createStore({
- initialState: {
- activeId: inactiveId,
- selectedBoardItems: [mockIssue],
- },
- isSwimlanesOn,
- });
- mountComponent();
+ expect(wrapper.classes()).toContain('multi-select');
+ expect(wrapper.classes()).not.toContain('is-active');
+ });
- expect(wrapper.classes()).toContain('multi-select');
- expect(wrapper.classes()).not.toContain('is-active');
+ describe('when mouseup event is called on the card', () => {
+ beforeEach(() => {
+ createStore();
+ mountComponent();
});
- describe('when mouseup event is called on the card', () => {
- beforeEach(() => {
- createStore({ isSwimlanesOn });
- mountComponent();
- });
-
- describe('when not using multi-select', () => {
- it('should call vuex action "toggleBoardItem" with correct parameters', async () => {
- await selectCard();
+ describe('when not using multi-select', () => {
+ it('should call vuex action "toggleBoardItem" with correct parameters', async () => {
+ await selectCard();
- expect(mockActions.toggleBoardItem).toHaveBeenCalledTimes(1);
- expect(mockActions.toggleBoardItem).toHaveBeenCalledWith(expect.any(Object), {
- boardItem: mockIssue,
- });
+ expect(mockActions.toggleBoardItem).toHaveBeenCalledTimes(1);
+ expect(mockActions.toggleBoardItem).toHaveBeenCalledWith(expect.any(Object), {
+ boardItem: mockIssue,
});
});
+ });
- describe('when using multi-select', () => {
- it('should call vuex action "multiSelectBoardItem" with correct parameters', async () => {
- await multiSelectCard();
+ describe('when using multi-select', () => {
+ it('should call vuex action "multiSelectBoardItem" with correct parameters', async () => {
+ await multiSelectCard();
- expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledTimes(1);
- expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledWith(
- expect.any(Object),
- mockIssue,
- );
- });
+ expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledTimes(1);
+ expect(mockActions.toggleBoardItemMultiSelection).toHaveBeenCalledWith(
+ expect.any(Object),
+ mockIssue,
+ );
});
});
});
diff --git a/spec/frontend/lib/utils/recurrence_spec.js b/spec/frontend/lib/utils/recurrence_spec.js
new file mode 100644
index 00000000000..fc22529dffc
--- /dev/null
+++ b/spec/frontend/lib/utils/recurrence_spec.js
@@ -0,0 +1,333 @@
+import { create, free, recall } from '~/lib/utils/recurrence';
+
+const HEX = /[a-f0-9]/i;
+const HEX_RE = HEX.source;
+const UUIDV4 = new RegExp(
+ `${HEX_RE}{8}-${HEX_RE}{4}-4${HEX_RE}{3}-[89ab]${HEX_RE}{3}-${HEX_RE}{12}`,
+ 'i',
+);
+
+describe('recurrence', () => {
+ let recurInstance;
+ let id;
+
+ beforeEach(() => {
+ recurInstance = create();
+ id = recurInstance.id;
+ });
+
+ afterEach(() => {
+ id = null;
+ recurInstance.free();
+ });
+
+ describe('create', () => {
+ it('returns an object with the correct external api', () => {
+ expect(recurInstance).toMatchObject(
+ expect.objectContaining({
+ id: expect.stringMatching(UUIDV4),
+ count: 0,
+ handlers: {},
+ free: expect.any(Function),
+ handle: expect.any(Function),
+ eject: expect.any(Function),
+ occur: expect.any(Function),
+ reset: expect.any(Function),
+ }),
+ );
+ });
+ });
+
+ describe('recall', () => {
+ it('returns a previously created RecurInstance', () => {
+ expect(recall(id).id).toBe(id);
+ });
+
+ it("returns undefined if the provided UUID doesn't refer to a stored RecurInstance", () => {
+ expect(recall('1234')).toBeUndefined();
+ });
+ });
+
+ describe('free', () => {
+ it('returns true when the RecurInstance exists', () => {
+ expect(free(id)).toBe(true);
+ });
+
+ it("returns false when the ID doesn't refer to a known RecurInstance", () => {
+ expect(free('1234')).toBe(false);
+ });
+
+ it('removes the correct RecurInstance from the list of references', () => {
+ const anotherInstance = create();
+
+ expect(recall(id)).toEqual(recurInstance);
+ expect(recall(anotherInstance.id)).toEqual(anotherInstance);
+
+ free(id);
+
+ expect(recall(id)).toBeUndefined();
+ expect(recall(anotherInstance.id)).toEqual(anotherInstance);
+
+ anotherInstance.free();
+ });
+ });
+
+ describe('RecurInstance (`create()` return value)', () => {
+ it.each`
+ property | value | alias
+ ${'id'} | ${expect.stringMatching(UUIDV4)} | ${'[a string matching the UUIDv4 specification]'}
+ ${'count'} | ${0} | ${0}
+ ${'handlers'} | ${{}} | ${{}}
+ `(
+ 'has the correct primitive value $alias for the member `$property` to start',
+ ({ property, value }) => {
+ expect(recurInstance[property]).toEqual(value);
+ },
+ );
+
+ describe('id', () => {
+ it('cannot be changed manually', () => {
+ expect(() => {
+ recurInstance.id = 'new-id';
+ }).toThrow(TypeError);
+
+ expect(recurInstance.id).toBe(id);
+ });
+
+ it.each`
+ method
+ ${'free'}
+ ${'handle'}
+ ${'eject'}
+ ${'occur'}
+ ${'reset'}
+ `('does not change across any method call - like after `$method`', ({ method }) => {
+ recurInstance[method]();
+
+ expect(recurInstance.id).toBe(id);
+ });
+ });
+
+ describe('count', () => {
+ it('cannot be changed manually', () => {
+ expect(() => {
+ recurInstance.count = 9999;
+ }).toThrow(TypeError);
+
+ expect(recurInstance.count).toBe(0);
+ });
+
+ it.each`
+ method
+ ${'free'}
+ ${'handle'}
+ ${'eject'}
+ ${'reset'}
+ `("doesn't change in unexpected scenarios - like after a call to `$method`", ({ method }) => {
+ recurInstance[method]();
+
+ expect(recurInstance.count).toBe(0);
+ });
+
+ it('increments by one each time `.occur()` is called', () => {
+ expect(recurInstance.count).toBe(0);
+ recurInstance.occur();
+ expect(recurInstance.count).toBe(1);
+ recurInstance.occur();
+ expect(recurInstance.count).toBe(2);
+ });
+ });
+
+ describe('handlers', () => {
+ it('cannot be changed manually', () => {
+ const fn = jest.fn();
+
+ recurInstance.handle(1, fn);
+ expect(() => {
+ recurInstance.handlers = {};
+ }).toThrow(TypeError);
+
+ expect(recurInstance.handlers).toStrictEqual({
+ 1: fn,
+ });
+ });
+
+ it.each`
+ method
+ ${'free'}
+ ${'occur'}
+ ${'eject'}
+ ${'reset'}
+ `("doesn't change in unexpected scenarios - like after a call to `$method`", ({ method }) => {
+ recurInstance[method]();
+
+ expect(recurInstance.handlers).toEqual({});
+ });
+
+ it('adds handlers to the correct slots', () => {
+ const fn1 = jest.fn();
+ const fn2 = jest.fn();
+
+ recurInstance.handle(100, fn1);
+ recurInstance.handle(1000, fn2);
+
+ expect(recurInstance.handlers).toMatchObject({
+ 100: fn1,
+ 1000: fn2,
+ });
+ });
+ });
+
+ describe('free', () => {
+ it('removes itself from recallable memory', () => {
+ expect(recall(id)).toEqual(recurInstance);
+
+ recurInstance.free();
+
+ expect(recall(id)).toBeUndefined();
+ });
+ });
+
+ describe('handle', () => {
+ it('adds a handler for the provided count', () => {
+ const fn = jest.fn();
+
+ recurInstance.handle(5, fn);
+
+ expect(recurInstance.handlers[5]).toEqual(fn);
+ });
+
+ it("doesn't add any handlers if either the count or behavior aren't provided", () => {
+ const fn = jest.fn();
+
+ recurInstance.handle(null, fn);
+ // Note that it's not possible to react to something not happening (without timers)
+ recurInstance.handle(0, fn);
+ recurInstance.handle(5, null);
+
+ expect(recurInstance.handlers).toEqual({});
+ });
+ });
+
+ describe('eject', () => {
+ it('removes the handler assigned to the particular count slot', () => {
+ recurInstance.handle(1, jest.fn());
+
+ expect(recurInstance.handlers[1]).toBeTruthy();
+
+ recurInstance.eject(1);
+
+ expect(recurInstance.handlers).toEqual({});
+ });
+
+ it("succeeds (or fails gracefully) when the count provided doesn't have a handler assigned", () => {
+ recurInstance.eject('abc');
+ recurInstance.eject(1);
+
+ expect(recurInstance.handlers).toEqual({});
+ });
+
+ it('makes no changes if no count is provided', () => {
+ const fn = jest.fn();
+
+ recurInstance.handle(1, fn);
+
+ recurInstance.eject();
+
+ expect(recurInstance.handlers[1]).toStrictEqual(fn);
+ });
+ });
+
+ describe('occur', () => {
+ it('increments the .count property by 1', () => {
+ expect(recurInstance.count).toBe(0);
+
+ recurInstance.occur();
+
+ expect(recurInstance.count).toBe(1);
+ });
+
+ it('calls the appropriate handlers', () => {
+ const fn1 = jest.fn();
+ const fn5 = jest.fn();
+ const fn10 = jest.fn();
+
+ recurInstance.handle(1, fn1);
+ recurInstance.handle(5, fn5);
+ recurInstance.handle(10, fn10);
+
+ expect(fn1).not.toHaveBeenCalled();
+ expect(fn5).not.toHaveBeenCalled();
+ expect(fn10).not.toHaveBeenCalled();
+
+ recurInstance.occur();
+
+ expect(fn1).toHaveBeenCalledTimes(1);
+ expect(fn5).not.toHaveBeenCalled();
+ expect(fn10).not.toHaveBeenCalled();
+
+ recurInstance.occur();
+ recurInstance.occur();
+ recurInstance.occur();
+ recurInstance.occur();
+
+ expect(fn1).toHaveBeenCalledTimes(1);
+ expect(fn5).toHaveBeenCalledTimes(1);
+ expect(fn10).not.toHaveBeenCalled();
+
+ recurInstance.occur();
+ recurInstance.occur();
+ recurInstance.occur();
+ recurInstance.occur();
+ recurInstance.occur();
+
+ expect(fn1).toHaveBeenCalledTimes(1);
+ expect(fn5).toHaveBeenCalledTimes(1);
+ expect(fn10).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ describe('reset', () => {
+ it('resets the count only, by default', () => {
+ const fn = jest.fn();
+
+ recurInstance.handle(3, fn);
+ recurInstance.occur();
+ recurInstance.occur();
+
+ expect(recurInstance.count).toBe(2);
+
+ recurInstance.reset();
+
+ expect(recurInstance.count).toBe(0);
+ expect(recurInstance.handlers).toEqual({ 3: fn });
+ });
+
+ it('also resets the handlers, by specific request', () => {
+ const fn = jest.fn();
+
+ recurInstance.handle(3, fn);
+ recurInstance.occur();
+ recurInstance.occur();
+
+ expect(recurInstance.count).toBe(2);
+
+ recurInstance.reset({ handlersList: true });
+
+ expect(recurInstance.count).toBe(0);
+ expect(recurInstance.handlers).toEqual({});
+ });
+
+ it('leaves the count in place, by request', () => {
+ recurInstance.occur();
+ recurInstance.occur();
+
+ expect(recurInstance.count).toBe(2);
+
+ recurInstance.reset({ currentCount: false });
+
+ expect(recurInstance.count).toBe(2);
+ });
+ });
+ });
+});
diff --git a/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js b/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js
new file mode 100644
index 00000000000..587373c99b4
--- /dev/null
+++ b/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js
@@ -0,0 +1,74 @@
+import { shallowMount } from '@vue/test-utils';
+import PipelineEditorDrawer from '~/pipeline_editor/components/drawer/pipeline_editor_drawer.vue';
+
+describe('Pipeline editor drawer', () => {
+ let wrapper;
+
+ const createComponent = () => {
+ wrapper = shallowMount(PipelineEditorDrawer);
+ };
+
+ const findToggleBtn = () => wrapper.find('[data-testid="toggleBtn"]');
+ const findArrowIcon = () => wrapper.find('[data-testid="toggle-icon"]');
+ const findCollapseText = () => wrapper.find('[data-testid="collapse-text"]');
+ const findDrawerContent = () => wrapper.find('[data-testid="drawer-content"]');
+
+ const clickToggleBtn = async () => findToggleBtn().vm.$emit('click');
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('when the drawer is collapsed', () => {
+ beforeEach(() => {
+ createComponent();
+ });
+
+ it('show the left facing arrow icon', () => {
+ expect(findArrowIcon().props('name')).toBe('chevron-double-lg-left');
+ });
+
+ it('does not show the collapse text', () => {
+ expect(findCollapseText().exists()).toBe(false);
+ });
+
+ it('does not show the drawer content', () => {
+ expect(findDrawerContent().exists()).toBe(false);
+ });
+
+ it('can open the drawer by clicking on the toggle button', async () => {
+ expect(findDrawerContent().exists()).toBe(false);
+
+ await clickToggleBtn();
+
+ expect(findDrawerContent().exists()).toBe(true);
+ });
+ });
+
+ describe('when the drawer is expanded', () => {
+ beforeEach(async () => {
+ createComponent();
+ await clickToggleBtn();
+ });
+
+ it('show the right facing arrow icon', () => {
+ expect(findArrowIcon().props('name')).toBe('chevron-double-lg-right');
+ });
+
+ it('shows the collapse text', () => {
+ expect(findCollapseText().exists()).toBe(true);
+ });
+
+ it('show the drawer content', () => {
+ expect(findDrawerContent().exists()).toBe(true);
+ });
+
+ it('can close the drawer by clicking on the toggle button', async () => {
+ expect(findDrawerContent().exists()).toBe(true);
+
+ await clickToggleBtn();
+
+ expect(findDrawerContent().exists()).toBe(false);
+ });
+ });
+});
diff --git a/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js b/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js
index a1e3d24acfa..7aba336b8e8 100644
--- a/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js
+++ b/spec/frontend/pipeline_editor/pipeline_editor_home_spec.js
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import CommitSection from '~/pipeline_editor/components/commit/commit_section.vue';
+import PipelineEditorDrawer from '~/pipeline_editor/components/drawer/pipeline_editor_drawer.vue';
import PipelineEditorFileNav from '~/pipeline_editor/components/file_nav/pipeline_editor_file_nav.vue';
import PipelineEditorHeader from '~/pipeline_editor/components/header/pipeline_editor_header.vue';
import PipelineEditorTabs from '~/pipeline_editor/components/pipeline_editor_tabs.vue';
@@ -13,7 +14,7 @@ import { mockLintResponse, mockCiYml } from './mock_data';
describe('Pipeline editor home wrapper', () => {
let wrapper;
- const createComponent = ({ props = {} } = {}) => {
+ const createComponent = ({ props = {}, glFeatures = {} } = {}) => {
wrapper = shallowMount(PipelineEditorHome, {
propsData: {
ciConfigData: mockLintResponse,
@@ -22,13 +23,20 @@ describe('Pipeline editor home wrapper', () => {
isNewCiConfigFile: false,
...props,
},
+ provide: {
+ glFeatures: {
+ pipelineEditorDrawer: true,
+ ...glFeatures,
+ },
+ },
});
};
- const findPipelineEditorHeader = () => wrapper.findComponent(PipelineEditorHeader);
- const findPipelineEditorTabs = () => wrapper.findComponent(PipelineEditorTabs);
const findCommitSection = () => wrapper.findComponent(CommitSection);
const findFileNav = () => wrapper.findComponent(PipelineEditorFileNav);
+ const findPipelineEditorDrawer = () => wrapper.findComponent(PipelineEditorDrawer);
+ const findPipelineEditorHeader = () => wrapper.findComponent(PipelineEditorHeader);
+ const findPipelineEditorTabs = () => wrapper.findComponent(PipelineEditorTabs);
afterEach(() => {
wrapper.destroy();
@@ -55,6 +63,10 @@ describe('Pipeline editor home wrapper', () => {
it('shows the commit section by default', () => {
expect(findCommitSection().exists()).toBe(true);
});
+
+ it('show the pipeline drawer', () => {
+ expect(findPipelineEditorDrawer().exists()).toBe(true);
+ });
});
describe('commit form toggle', () => {
@@ -82,4 +94,12 @@ describe('Pipeline editor home wrapper', () => {
expect(findCommitSection().exists()).toBe(true);
});
});
+
+ describe('Pipeline drawer', () => {
+ it('hides the drawer when the feature flag is off', () => {
+ createComponent({ glFeatures: { pipelineEditorDrawer: false } });
+
+ expect(findPipelineEditorDrawer().exists()).toBe(false);
+ });
+ });
});
diff --git a/spec/graphql/resolvers/metadata_resolver_spec.rb b/spec/graphql/resolvers/metadata_resolver_spec.rb
index f8c01f9d531..56875e185e7 100644
--- a/spec/graphql/resolvers/metadata_resolver_spec.rb
+++ b/spec/graphql/resolvers/metadata_resolver_spec.rb
@@ -7,7 +7,10 @@ RSpec.describe Resolvers::MetadataResolver do
describe '#resolve' do
it 'returns version and revision' do
- expect(resolve(described_class)).to have_attributes(version: Gitlab::VERSION, revision: Gitlab.revision)
+ expect(resolve(described_class)).to have_attributes(
+ version: Gitlab::VERSION,
+ revision: Gitlab.revision,
+ kas: kind_of(InstanceMetadata::Kas))
end
end
end
diff --git a/spec/graphql/types/metadata/kas_type_spec.rb b/spec/graphql/types/metadata/kas_type_spec.rb
new file mode 100644
index 00000000000..f90c64f0068
--- /dev/null
+++ b/spec/graphql/types/metadata/kas_type_spec.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GitlabSchema.types['Kas'] do
+ specify { expect(described_class.graphql_name).to eq('Kas') }
+ specify { expect(described_class).to require_graphql_authorizations(:read_instance_metadata) }
+end
diff --git a/spec/lib/gitlab/kas_spec.rb b/spec/lib/gitlab/kas_spec.rb
index 01ced407883..e323f76b42e 100644
--- a/spec/lib/gitlab/kas_spec.rb
+++ b/spec/lib/gitlab/kas_spec.rb
@@ -33,6 +33,46 @@ RSpec.describe Gitlab::Kas do
end
end
+ describe '.enabled?' do
+ before do
+ allow(Gitlab).to receive(:config).and_return(gitlab_config)
+ end
+
+ subject { described_class.enabled? }
+
+ context 'gitlab_config is not enabled' do
+ let(:gitlab_config) { { 'gitlab_kas' => { 'enabled' => false } } }
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'gitlab_config is enabled' do
+ let(:gitlab_config) { { 'gitlab_kas' => { 'enabled' => true } } }
+
+ it { is_expected.to be_truthy }
+ end
+
+ context 'enabled is unset' do
+ let(:gitlab_config) { { 'gitlab_kas' => {} } }
+
+ it { is_expected.to be_falsey }
+ end
+ end
+
+ describe '.external_url' do
+ it 'returns gitlab_kas external_url config' do
+ expect(described_class.external_url).to eq(Gitlab.config.gitlab_kas.external_url)
+ end
+ end
+
+ describe '.version' do
+ it 'returns gitlab_kas version config' do
+ version_file = Rails.root.join(described_class::VERSION_FILE)
+
+ expect(described_class.version).to eq(version_file.read.chomp)
+ end
+ end
+
describe '.ensure_secret!' do
context 'secret file exists' do
before do
diff --git a/spec/models/instance_metadata/kas_spec.rb b/spec/models/instance_metadata/kas_spec.rb
new file mode 100644
index 00000000000..f8cc34fa8d3
--- /dev/null
+++ b/spec/models/instance_metadata/kas_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe ::InstanceMetadata::Kas do
+ it 'has InstanceMetadataPolicy as declarative policy' do
+ expect(described_class.declarative_policy_class).to eq("InstanceMetadataPolicy")
+ end
+
+ context 'when KAS is enabled' do
+ it 'has the correct properties' do
+ allow(Gitlab::Kas).to receive(:enabled?).and_return(true)
+
+ expect(subject).to have_attributes(
+ enabled: Gitlab::Kas.enabled?,
+ version: Gitlab::Kas.version,
+ external_url: Gitlab::Kas.external_url
+ )
+ end
+ end
+
+ context 'when KAS is disabled' do
+ it 'has the correct properties' do
+ allow(Gitlab::Kas).to receive(:enabled?).and_return(false)
+
+ expect(subject).to have_attributes(
+ enabled: Gitlab::Kas.enabled?,
+ version: nil,
+ external_url: nil
+ )
+ end
+ end
+end
diff --git a/spec/models/instance_metadata_spec.rb b/spec/models/instance_metadata_spec.rb
index 1835dc8a9af..e3a9167620b 100644
--- a/spec/models/instance_metadata_spec.rb
+++ b/spec/models/instance_metadata_spec.rb
@@ -6,7 +6,8 @@ RSpec.describe InstanceMetadata do
it 'has the correct properties' do
expect(subject).to have_attributes(
version: Gitlab::VERSION,
- revision: Gitlab.revision
+ revision: Gitlab.revision,
+ kas: kind_of(::InstanceMetadata::Kas)
)
end
end
diff --git a/spec/presenters/ci/stage_presenter_spec.rb b/spec/presenters/ci/stage_presenter_spec.rb
new file mode 100644
index 00000000000..368f03b0150
--- /dev/null
+++ b/spec/presenters/ci/stage_presenter_spec.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::StagePresenter do
+ let(:stage) { create(:ci_stage) }
+ let(:presenter) { described_class.new(stage) }
+
+ let!(:build) { create(:ci_build, :tags, :artifacts, pipeline: stage.pipeline, stage: stage.name) }
+ let!(:retried_build) { create(:ci_build, :tags, :artifacts, :retried, pipeline: stage.pipeline, stage: stage.name) }
+
+ before do
+ create(:generic_commit_status, pipeline: stage.pipeline, stage: stage.name)
+ end
+
+ shared_examples 'preloaded associations for CI status' do
+ it 'preloads project' do
+ expect(presented_stage.association(:project)).to be_loaded
+ end
+
+ it 'preloads build pipeline' do
+ expect(presented_stage.association(:pipeline)).to be_loaded
+ end
+
+ it 'preloads build tags' do
+ expect(presented_stage.association(:tags)).to be_loaded
+ end
+
+ it 'preloads build artifacts archive' do
+ expect(presented_stage.association(:job_artifacts_archive)).to be_loaded
+ end
+
+ it 'preloads build artifacts metadata' do
+ expect(presented_stage.association(:metadata)).to be_loaded
+ end
+ end
+
+ describe '#latest_ordered_statuses' do
+ subject(:presented_stage) { presenter.latest_ordered_statuses.second }
+
+ it_behaves_like 'preloaded associations for CI status'
+ end
+
+ describe '#retried_ordered_statuses' do
+ subject(:presented_stage) { presenter.retried_ordered_statuses.first }
+
+ it_behaves_like 'preloaded associations for CI status'
+ end
+end
diff --git a/spec/requests/api/graphql/metadata_query_spec.rb b/spec/requests/api/graphql/metadata_query_spec.rb
index 6344ec371c8..840bd7c018c 100644
--- a/spec/requests/api/graphql/metadata_query_spec.rb
+++ b/spec/requests/api/graphql/metadata_query_spec.rb
@@ -8,16 +8,48 @@ RSpec.describe 'getting project information' do
let(:query) { graphql_query_for('metadata', {}, all_graphql_fields_for('Metadata')) }
context 'logged in' do
- it 'returns version and revision' do
- post_graphql(query, current_user: create(:user))
-
- expect(graphql_errors).to be_nil
- expect(graphql_data).to eq(
+ let(:expected_data) do
+ {
'metadata' => {
'version' => Gitlab::VERSION,
- 'revision' => Gitlab.revision
+ 'revision' => Gitlab.revision,
+ 'kas' => {
+ 'enabled' => Gitlab::Kas.enabled?,
+ 'version' => expected_kas_version,
+ 'externalUrl' => expected_kas_external_url
+ }
}
- )
+ }
+ end
+
+ context 'kas is enabled' do
+ let(:expected_kas_version) { Gitlab::Kas.version }
+ let(:expected_kas_external_url) { Gitlab::Kas.external_url }
+
+ before do
+ allow(Gitlab::Kas).to receive(:enabled?).and_return(true)
+ post_graphql(query, current_user: create(:user))
+ end
+
+ it 'returns version, revision, kas_enabled, kas_version, kas_external_url' do
+ expect(graphql_errors).to be_nil
+ expect(graphql_data).to eq(expected_data)
+ end
+ end
+
+ context 'kas is disabled' do
+ let(:expected_kas_version) { nil }
+ let(:expected_kas_external_url) { nil }
+
+ before do
+ allow(Gitlab::Kas).to receive(:enabled?).and_return(false)
+ post_graphql(query, current_user: create(:user))
+ end
+
+ it 'returns version and revision' do
+ expect(graphql_errors).to be_nil
+ expect(graphql_data).to eq(expected_data)
+ end
end
end
diff --git a/spec/support/shared_contexts/navbar_structure_context.rb b/spec/support/shared_contexts/navbar_structure_context.rb
index 51aa52a28f7..65528f3900f 100644
--- a/spec/support/shared_contexts/navbar_structure_context.rb
+++ b/spec/support/shared_contexts/navbar_structure_context.rb
@@ -170,15 +170,18 @@ RSpec.shared_context 'group navbar structure' do
}
end
+ let(:group_information_nav_item) do
+ {
+ nav_item: _('Group information'),
+ nav_sub_items: [
+ _('Activity')
+ ]
+ }
+ end
+
let(:structure) do
[
- {
- nav_item: _('Group overview'),
- nav_sub_items: [
- _('Details'),
- _('Activity')
- ]
- },
+ group_information_nav_item,
{
nav_item: _('Issues'),
nav_sub_items: [
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index 1392bae055a..c4623061944 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -298,15 +298,15 @@ RSpec.describe 'gitlab:db namespace rake task' do
end
describe '#migrate_with_instrumentation' do
- subject { run_rake_task('gitlab:db:migration_testing', "[#{filename}]") }
+ subject { run_rake_task('gitlab:db:migration_testing') }
let(:ctx) { double('ctx', migrations: all_migrations, schema_migration: double, get_all_versions: existing_versions) }
let(:instrumentation) { instance_double(Gitlab::Database::Migrations::Instrumentation, observations: observations) }
let(:existing_versions) { [1] }
let(:all_migrations) { [double('migration1', version: 1), pending_migration] }
let(:pending_migration) { double('migration2', version: 2) }
- let(:filename) { 'results-file.json'}
- let(:buffer) { StringIO.new }
+ let(:filename) { Gitlab::Database::Migrations::Instrumentation::STATS_FILENAME }
+ let!(:directory) { Dir.mktmpdir }
let(:observations) { %w[some data] }
before do
@@ -316,17 +316,19 @@ RSpec.describe 'gitlab:db namespace rake task' do
allow(instrumentation).to receive(:observe).and_yield
- allow(File).to receive(:open).with(filename, 'wb+').and_yield(buffer)
+ allow(Dir).to receive(:mkdir)
+ allow(File).to receive(:exist?).with(directory).and_return(false)
+ stub_const('Gitlab::Database::Migrations::Instrumentation::RESULT_DIR', directory)
end
- it 'fails when given no filename argument' do
- expect { run_rake_task('gitlab:db:migration_testing') }.to raise_error(/specify result_file/)
+ after do
+ FileUtils.rm_rf([directory])
end
- it 'fails when the given file already exists' do
- expect(File).to receive(:exist?).with(filename).and_return(true)
+ it 'fails when the directory already exists' do
+ expect(File).to receive(:exist?).with(directory).and_return(true)
- expect { subject }.to raise_error(/File exists/)
+ expect { subject }.to raise_error(/Directory exists/)
end
it 'instruments the pending migration' do
@@ -344,7 +346,7 @@ RSpec.describe 'gitlab:db namespace rake task' do
it 'writes observations out to JSON file' do
subject
- expect(buffer.string).to eq(observations.to_json)
+ expect(File.read(File.join(directory, filename))).to eq(observations.to_json)
end
end
diff --git a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
index 640f463b45d..d46ba86a22e 100644
--- a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_group' do
- let(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
before do
assign(:group, group)
@@ -11,4 +11,36 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
it_behaves_like 'has nav sidebar'
it_behaves_like 'sidebar includes snowplow attributes', 'render', 'groups_side_navigation', 'groups_side_navigation'
+
+ describe 'Group information' do
+ it 'has a link to the group path' do
+ render
+
+ expect(rendered).to have_link('Group information', href: group_path(group))
+ end
+
+ it 'does not have a link to the details menu item' do
+ render
+
+ expect(rendered).not_to have_link('Details', href: details_group_path(group))
+ end
+
+ context 'when feature flag :sidebar_refactor is disabled' do
+ before do
+ stub_feature_flags(sidebar_refactor: false)
+ end
+
+ it 'has a link to the group path with the "Group overview" title' do
+ render
+
+ expect(rendered).to have_link('Group overview', href: group_path(group))
+ end
+
+ it 'has a link to the details menu item' do
+ render
+
+ expect(rendered).to have_link('Details', href: details_group_path(group))
+ end
+ end
+ end
end