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:
authorSimon Knox <psimyn@gmail.com>2019-06-14 17:53:34 +0300
committerSimon Knox <psimyn@gmail.com>2019-06-14 17:53:34 +0300
commitdfc2d02cc6f848b65849525b6213574714855040 (patch)
treef1ae76ce0fb487d60c1862588c0a3079e038f874 /spec
parent14f27102b696672f02b5d1b2ab45688b711f4024 (diff)
parentae853dba6b9e5f45aea0d14965c9691840db78f7 (diff)
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into 62966-embed-zoom-call-in-issue-mvc
Diffstat (limited to 'spec')
-rw-r--r--spec/features/dashboard/groups_list_spec.rb4
-rw-r--r--spec/features/issues/markdown_toolbar_spec.rb2
-rw-r--r--spec/features/merge_request/user_posts_notes_spec.rb2
-rw-r--r--spec/features/merge_request/user_suggests_changes_on_diff_spec.rb12
-rw-r--r--spec/frontend/vue_shared/components/pagination_links_spec.js66
-rw-r--r--spec/javascripts/diffs/components/app_spec.js2
-rw-r--r--spec/javascripts/diffs/store/actions_spec.js40
-rw-r--r--spec/javascripts/diffs/store/mutations_spec.js10
-rw-r--r--spec/javascripts/vue_shared/components/markdown/header_spec.js2
9 files changed, 108 insertions, 32 deletions
diff --git a/spec/features/dashboard/groups_list_spec.rb b/spec/features/dashboard/groups_list_spec.rb
index e75c43d5338..fb76e2b0014 100644
--- a/spec/features/dashboard/groups_list_spec.rb
+++ b/spec/features/dashboard/groups_list_spec.rb
@@ -125,7 +125,7 @@ describe 'Dashboard Groups page', :js do
end
it 'loads results for next page' do
- expect(page).to have_selector('.gl-pagination .page-item a[role=menuitemradio]', count: 2)
+ expect(page).to have_selector('.gl-pagination .page-item a.page-link', count: 3)
# Check first page
expect(page).to have_content(group2.full_name)
@@ -134,7 +134,7 @@ describe 'Dashboard Groups page', :js do
expect(page).not_to have_selector("#group-#{group.id}")
# Go to next page
- find('.gl-pagination .page-item:not(.active) a[role=menuitemradio]').click
+ find('.gl-pagination .page-item:last-of-type a.page-link').click
wait_for_requests
diff --git a/spec/features/issues/markdown_toolbar_spec.rb b/spec/features/issues/markdown_toolbar_spec.rb
index 042ecdb172a..94bd7c53bb5 100644
--- a/spec/features/issues/markdown_toolbar_spec.rb
+++ b/spec/features/issues/markdown_toolbar_spec.rb
@@ -32,7 +32,7 @@ describe 'Issue markdown toolbar', :js do
find('.js-main-target-form #note-body')
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 50)')
- find('.toolbar-btn:nth-child(2)').click
+ all('.toolbar-btn')[1].click
expect(find('#note-body')[:value]).to eq("test\n*underline*\n")
end
diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb
index e5770905dbd..8ff24449b39 100644
--- a/spec/features/merge_request/user_posts_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_notes_spec.rb
@@ -141,7 +141,7 @@ describe 'Merge request > User posts notes', :js do
page.within('.current-note-edit-form') do
expect(find('#note_note').value).to eq('This is the new content')
- find('.js-md:first-child').click
+ first('.js-md').click
expect(find('#note_note').value).to eq('This is the new content****')
end
end
diff --git a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
index 780de76d2c5..e8b4fc8f160 100644
--- a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
+++ b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
@@ -28,6 +28,18 @@ describe 'User comments on a diff', :js do
end
context 'single suggestion note' do
+ it 'hides suggestion popover' do
+ click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
+
+ expect(page).to have_selector('.diff-suggest-popover')
+
+ page.within('.diff-suggest-popover') do
+ click_button 'Got it'
+ end
+
+ expect(page).not_to have_selector('.diff-suggest-popover')
+ end
+
it 'suggestion is presented' do
click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
diff --git a/spec/frontend/vue_shared/components/pagination_links_spec.js b/spec/frontend/vue_shared/components/pagination_links_spec.js
index d0cb3731050..efa5825d92f 100644
--- a/spec/frontend/vue_shared/components/pagination_links_spec.js
+++ b/spec/frontend/vue_shared/components/pagination_links_spec.js
@@ -1,59 +1,77 @@
-import Vue from 'vue';
+import { mount, createLocalVue } from '@vue/test-utils';
+import { GlPagination } from '@gitlab/ui';
import PaginationLinks from '~/vue_shared/components/pagination_links.vue';
-import { s__ } from '~/locale';
-import mountComponent from '../../helpers/vue_mount_component_helper';
+import {
+ PREV,
+ NEXT,
+ LABEL_FIRST_PAGE,
+ LABEL_PREV_PAGE,
+ LABEL_NEXT_PAGE,
+ LABEL_LAST_PAGE,
+} from '~/vue_shared/components/pagination/constants';
+
+const localVue = createLocalVue();
describe('Pagination links component', () => {
- const paginationLinksComponent = Vue.extend(PaginationLinks);
- const change = page => page;
const pageInfo = {
page: 3,
perPage: 5,
total: 30,
};
const translations = {
- firstText: s__('Pagination|« First'),
- prevText: s__('Pagination|Prev'),
- nextText: s__('Pagination|Next'),
- lastText: s__('Pagination|Last »'),
+ prevText: PREV,
+ nextText: NEXT,
+ labelFirstPage: LABEL_FIRST_PAGE,
+ labelPrevPage: LABEL_PREV_PAGE,
+ labelNextPage: LABEL_NEXT_PAGE,
+ labelLastPage: LABEL_LAST_PAGE,
};
- let paginationLinks;
+ let wrapper;
let glPagination;
- let destinationComponent;
+ let changeMock;
- beforeEach(() => {
- paginationLinks = mountComponent(paginationLinksComponent, {
- change,
- pageInfo,
+ const createComponent = () => {
+ changeMock = jest.fn();
+ wrapper = mount(PaginationLinks, {
+ propsData: {
+ change: changeMock,
+ pageInfo,
+ },
+ localVue,
+ sync: false,
});
- [glPagination] = paginationLinks.$children;
- [destinationComponent] = glPagination.$children;
+ };
+
+ beforeEach(() => {
+ createComponent();
+ glPagination = wrapper.find(GlPagination);
});
afterEach(() => {
- paginationLinks.$destroy();
+ wrapper.destroy();
});
it('should provide translated text to GitLab UI pagination', () => {
Object.entries(translations).forEach(entry => {
- expect(destinationComponent[entry[0]]).toBe(entry[1]);
+ expect(glPagination.vm[entry[0]]).toBe(entry[1]);
});
});
- it('should pass change to GitLab UI pagination', () => {
- expect(Object.is(glPagination.change, change)).toBe(true);
+ it('should call change when page changes', () => {
+ wrapper.find('a').trigger('click');
+ expect(changeMock).toHaveBeenCalled();
});
it('should pass page from pageInfo to GitLab UI pagination', () => {
- expect(destinationComponent.value).toBe(pageInfo.page);
+ expect(glPagination.vm.value).toBe(pageInfo.page);
});
it('should pass per page from pageInfo to GitLab UI pagination', () => {
- expect(destinationComponent.perPage).toBe(pageInfo.perPage);
+ expect(glPagination.vm.perPage).toBe(pageInfo.perPage);
});
it('should pass total items from pageInfo to GitLab UI pagination', () => {
- expect(destinationComponent.totalRows).toBe(pageInfo.total);
+ expect(glPagination.vm.totalItems).toBe(pageInfo.total);
});
});
diff --git a/spec/javascripts/diffs/components/app_spec.js b/spec/javascripts/diffs/components/app_spec.js
index 1aabf3c2132..fdf8bcee756 100644
--- a/spec/javascripts/diffs/components/app_spec.js
+++ b/spec/javascripts/diffs/components/app_spec.js
@@ -37,6 +37,8 @@ describe('diffs/components/app', () => {
projectPath: 'namespace/project',
currentUser: {},
changesEmptyStateIllustration: '',
+ dismissEndpoint: '',
+ showSuggestPopover: true,
...props,
},
store,
diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js
index f129fbb57a3..f973728cfe1 100644
--- a/spec/javascripts/diffs/store/actions_spec.js
+++ b/spec/javascripts/diffs/store/actions_spec.js
@@ -37,6 +37,7 @@ import actions, {
toggleFullDiff,
setFileCollapsed,
setExpandedDiffLines,
+ setSuggestPopoverDismissed,
} from '~/diffs/store/actions';
import eventHub from '~/notes/event_hub';
import * as types from '~/diffs/store/mutation_types';
@@ -68,12 +69,19 @@ describe('DiffsStoreActions', () => {
it('should set given endpoint and project path', done => {
const endpoint = '/diffs/set/endpoint';
const projectPath = '/root/project';
+ const dismissEndpoint = '/-/user_callouts';
+ const showSuggestPopover = false;
testAction(
setBaseConfig,
- { endpoint, projectPath },
- { endpoint: '', projectPath: '' },
- [{ type: types.SET_BASE_CONFIG, payload: { endpoint, projectPath } }],
+ { endpoint, projectPath, dismissEndpoint, showSuggestPopover },
+ { endpoint: '', projectPath: '', dismissEndpoint: '', showSuggestPopover: true },
+ [
+ {
+ type: types.SET_BASE_CONFIG,
+ payload: { endpoint, projectPath, dismissEndpoint, showSuggestPopover },
+ },
+ ],
[],
done,
);
@@ -1080,4 +1088,30 @@ describe('DiffsStoreActions', () => {
);
});
});
+
+ describe('setSuggestPopoverDismissed', () => {
+ it('commits SET_SHOW_SUGGEST_POPOVER', done => {
+ const state = { dismissEndpoint: `${gl.TEST_HOST}/-/user_callouts` };
+ const mock = new MockAdapter(axios);
+ mock.onPost(state.dismissEndpoint).reply(200, {});
+
+ spyOn(axios, 'post').and.callThrough();
+
+ testAction(
+ setSuggestPopoverDismissed,
+ null,
+ state,
+ [{ type: types.SET_SHOW_SUGGEST_POPOVER }],
+ [],
+ () => {
+ expect(axios.post).toHaveBeenCalledWith(state.dismissEndpoint, {
+ feature_name: 'suggest_popover_dismissed',
+ });
+
+ mock.restore();
+ done();
+ },
+ );
+ });
+ });
});
diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js
index fa193e1d3b9..9c13c7ceb7a 100644
--- a/spec/javascripts/diffs/store/mutations_spec.js
+++ b/spec/javascripts/diffs/store/mutations_spec.js
@@ -850,4 +850,14 @@ describe('DiffsStoreMutations', () => {
expect(file.renderingLines).toBe(false);
});
});
+
+ describe('SET_SHOW_SUGGEST_POPOVER', () => {
+ it('sets showSuggestPopover to false', () => {
+ const state = { showSuggestPopover: true };
+
+ mutations[types.SET_SHOW_SUGGEST_POPOVER](state);
+
+ expect(state.showSuggestPopover).toBe(false);
+ });
+ });
});
diff --git a/spec/javascripts/vue_shared/components/markdown/header_spec.js b/spec/javascripts/vue_shared/components/markdown/header_spec.js
index d4be2451f0b..af92e5f5ae2 100644
--- a/spec/javascripts/vue_shared/components/markdown/header_spec.js
+++ b/spec/javascripts/vue_shared/components/markdown/header_spec.js
@@ -22,13 +22,13 @@ describe('Markdown field header component', () => {
'Add bold text',
'Add italic text',
'Insert a quote',
+ 'Insert suggestion',
'Insert code',
'Add a link',
'Add a bullet list',
'Add a numbered list',
'Add a task list',
'Add a table',
- 'Insert suggestion',
'Go full screen',
];
const elements = vm.$el.querySelectorAll('.toolbar-btn');