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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 21:06:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-01 21:06:28 +0300
commited3b1698883bd4ac2c4faf6c05c3a8155748bf91 (patch)
treee4725e36aaee9141e9ac4da66faf8a19edd74c2a /spec/frontend/ide
parent05f4b2fb34dbb051b2ce5ddbc801ec42998c019c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide')
-rw-r--r--spec/frontend/ide/components/branches/search_list_spec.js81
-rw-r--r--spec/frontend/ide/mock_data.js228
2 files changed, 309 insertions, 0 deletions
diff --git a/spec/frontend/ide/components/branches/search_list_spec.js b/spec/frontend/ide/components/branches/search_list_spec.js
new file mode 100644
index 00000000000..5cfe1c25c6b
--- /dev/null
+++ b/spec/frontend/ide/components/branches/search_list_spec.js
@@ -0,0 +1,81 @@
+import { shallowMount, createLocalVue } from '@vue/test-utils';
+import Vuex from 'vuex';
+import { __ } from '~/locale';
+import List from '~/ide/components/branches/search_list.vue';
+import Item from '~/ide/components/branches/item.vue';
+import { GlLoadingIcon } from '@gitlab/ui';
+import { branches } from '../../mock_data';
+
+const localVue = createLocalVue();
+localVue.use(Vuex);
+
+describe('IDE branches search list', () => {
+ let wrapper;
+ const fetchBranchesMock = jest.fn();
+
+ const createComponent = (state, currentBranchId = 'branch') => {
+ const fakeStore = new Vuex.Store({
+ state: {
+ currentBranchId,
+ currentProjectId: 'project',
+ },
+ modules: {
+ branches: {
+ namespaced: true,
+ state: { isLoading: false, branches: [], ...state },
+ actions: {
+ fetchBranches: fetchBranchesMock,
+ },
+ },
+ },
+ });
+
+ wrapper = shallowMount(List, {
+ localVue,
+ store: fakeStore,
+ sync: false,
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ it('calls fetch on mounted', () => {
+ createComponent();
+ expect(fetchBranchesMock).toHaveBeenCalled();
+ });
+
+ it('renders loading icon when `isLoading` is true', () => {
+ createComponent({ isLoading: true });
+ expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
+ });
+
+ it('renders branches not found when search is not empty and branches list is empty', () => {
+ createComponent({ branches: [] });
+ wrapper.find('input[type="search"]').setValue('something');
+
+ return wrapper.vm.$nextTick().then(() => {
+ expect(wrapper.text()).toContain(__('No branches found'));
+ });
+ });
+
+ describe('with branches', () => {
+ it('renders list', () => {
+ createComponent({ branches });
+ const items = wrapper.findAll(Item);
+
+ expect(items.length).toBe(branches.length);
+ });
+
+ it('renders check next to active branch', () => {
+ const activeBranch = 'regular';
+ createComponent({ branches }, activeBranch);
+ const items = wrapper.findAll(Item).filter(w => w.props('isActive'));
+
+ expect(items.length).toBe(1);
+ expect(items.at(0).props('item').name).toBe(activeBranch);
+ });
+ });
+});
diff --git a/spec/frontend/ide/mock_data.js b/spec/frontend/ide/mock_data.js
new file mode 100644
index 00000000000..80eb15fe5a6
--- /dev/null
+++ b/spec/frontend/ide/mock_data.js
@@ -0,0 +1,228 @@
+import { TEST_HOST } from 'spec/test_constants';
+
+export const projectData = {
+ id: 1,
+ name: 'abcproject',
+ web_url: '',
+ avatar_url: '',
+ path: '',
+ name_with_namespace: 'namespace/abcproject',
+ branches: {
+ master: {
+ treeId: 'abcproject/master',
+ can_push: true,
+ commit: {
+ id: '123',
+ },
+ },
+ },
+ mergeRequests: {},
+ merge_requests_enabled: true,
+ default_branch: 'master',
+};
+
+export const pipelines = [
+ {
+ id: 1,
+ ref: 'master',
+ sha: '123',
+ details: {
+ status: {
+ icon: 'status_failed',
+ group: 'failed',
+ text: 'Failed',
+ },
+ },
+ commit: { id: '123' },
+ },
+ {
+ id: 2,
+ ref: 'master',
+ sha: '213',
+ details: {
+ status: {
+ icon: 'status_failed',
+ group: 'failed',
+ text: 'Failed',
+ },
+ },
+ commit: { id: '213' },
+ },
+];
+
+export const stages = [
+ {
+ dropdown_path: `${TEST_HOST}/testing`,
+ name: 'build',
+ status: {
+ icon: 'status_failed',
+ group: 'failed',
+ text: 'failed',
+ },
+ },
+ {
+ dropdown_path: 'testing',
+ name: 'test',
+ status: {
+ icon: 'status_failed',
+ group: 'failed',
+ text: 'failed',
+ },
+ },
+];
+
+export const jobs = [
+ {
+ id: 1,
+ name: 'test',
+ path: 'testing',
+ status: {
+ icon: 'status_success',
+ text: 'passed',
+ },
+ stage: 'test',
+ duration: 1,
+ started: new Date(),
+ },
+ {
+ id: 2,
+ name: 'test 2',
+ path: 'testing2',
+ status: {
+ icon: 'status_success',
+ text: 'passed',
+ },
+ stage: 'test',
+ duration: 1,
+ started: new Date(),
+ },
+ {
+ id: 3,
+ name: 'test 3',
+ path: 'testing3',
+ status: {
+ icon: 'status_success',
+ text: 'passed',
+ },
+ stage: 'test',
+ duration: 1,
+ started: new Date(),
+ },
+ {
+ id: 4,
+ name: 'test 4',
+ path: 'testing4',
+ status: {
+ icon: 'status_failed',
+ text: 'failed',
+ },
+ stage: 'build',
+ duration: 1,
+ started: new Date(),
+ },
+];
+
+export const fullPipelinesResponse = {
+ data: {
+ count: {
+ all: 2,
+ },
+ pipelines: [
+ {
+ id: '51',
+ path: 'test',
+ commit: {
+ id: '123',
+ },
+ details: {
+ status: {
+ icon: 'status_failed',
+ text: 'failed',
+ },
+ stages: [...stages],
+ },
+ },
+ {
+ id: '50',
+ commit: {
+ id: 'abc123def456ghi789jkl',
+ },
+ details: {
+ status: {
+ icon: 'status_success',
+ text: 'passed',
+ },
+ stages: [...stages],
+ },
+ },
+ ],
+ },
+};
+
+export const mergeRequests = [
+ {
+ id: 1,
+ iid: 1,
+ title: 'Test merge request',
+ project_id: 1,
+ web_url: `${TEST_HOST}/namespace/project-path/merge_requests/1`,
+ },
+];
+
+export const branches = [
+ {
+ id: 1,
+ name: 'master',
+ commit: {
+ message: 'Update master branch',
+ committed_date: '2018-08-01T00:20:05Z',
+ },
+ can_push: true,
+ protected: true,
+ default: true,
+ },
+ {
+ id: 2,
+ name: 'protected/no-access',
+ commit: {
+ message: 'Update some stuff',
+ committed_date: '2018-08-02T00:00:05Z',
+ },
+ can_push: false,
+ protected: true,
+ default: false,
+ },
+ {
+ id: 3,
+ name: 'protected/access',
+ commit: {
+ message: 'Update some stuff',
+ committed_date: '2018-08-02T00:00:05Z',
+ },
+ can_push: true,
+ protected: true,
+ default: false,
+ },
+ {
+ id: 4,
+ name: 'regular',
+ commit: {
+ message: 'Update some more stuff',
+ committed_date: '2018-06-30T00:20:05Z',
+ },
+ can_push: true,
+ protected: false,
+ default: false,
+ },
+ {
+ id: 5,
+ name: 'regular/no-access',
+ commit: {
+ message: 'Update some more stuff',
+ committed_date: '2018-06-30T00:20:05Z',
+ },
+ can_push: false,
+ protected: false,
+ default: false,
+ },
+];