Commit 5e9b6c84 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ce-to-ee-2018-01-26' into 'master'

CE upstream - 2018-01-26 12:23 UTC

Closes #4698

See merge request gitlab-org/gitlab-ee!4280
parents bb9a9b7b e410f077
......@@ -22,3 +22,11 @@ axios.interceptors.response.use((config) => {
});
export default axios;
/**
* @return The adapter that axios uses for dispatching requests. This may be overwritten in tests.
*
* @see https://github.com/axios/axios/tree/master/lib/adapters
* @see https://github.com/ctimmerm/axios-mock-adapter/blob/v1.12.0/src/index.js#L39
*/
export const getDefaultAdapter = () => axios.defaults.adapter;
......@@ -84,9 +84,9 @@
<div class="media-body">
<h4 class="flex-container-block">
<span class="append-right-10">
Set by
{{ s__("mrWidget|Set by") }}
<mr-widget-author :author="mr.setToMWPSBy" />
to be merged automatically when the pipeline succeeds
{{ s__("mrWidget|to be merged automatically when the pipeline succeeds") }}
</span>
<a
v-if="mr.canCancelAutomaticMerge"
......
......@@ -107,6 +107,12 @@ module QA
module Project
autoload :New, 'qa/page/project/new'
autoload :Show, 'qa/page/project/show'
autoload :Activity, 'qa/page/project/activity'
module Pipeline
autoload :Index, 'qa/page/project/pipeline/index'
autoload :Show, 'qa/page/project/pipeline/show'
end
module Pipeline
autoload :Index, 'qa/page/project/pipeline/index'
......
......@@ -8,6 +8,7 @@ module QA
element :repository_link, "title: 'Repository'"
element :pipelines_settings_link, "title: 'CI / CD'"
element :top_level_items, '.sidebar-top-level-items'
element :activity_link, "title: 'Activity'"
end
view 'app/assets/javascripts/fly_out_nav.js' do
......@@ -58,6 +59,12 @@ module QA
end
end
def go_to_activity
within_sidebar do
click_on 'Activity'
end
end
def within_submenu
page.within('.fly-out-list') do
yield
......
module QA
module Page
module Project
class Activity < Page::Base
view 'app/views/shared/_event_filter.html.haml' do
element :push_events, "event_filter_link EventFilter.push, _('Push events')"
end
def go_to_push_events
click_on 'Push events'
end
end
end
end
end
module QA
feature 'activity page', :core do
scenario 'push creates an event in the activity page' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Factory::Repository::Push.fabricate! do |push|
push.file_name = 'README.md'
push.file_content = '# This is a test project'
push.commit_message = 'Add README.md'
end
Page::Menu::Side.act { go_to_activity }
Page::Project::Activity.act { go_to_push_events }
expect(page).to have_content('pushed new branch master')
end
end
end
......@@ -51,9 +51,18 @@ describe('AppComponent', () => {
});
describe('methods', () => {
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
});
afterEach(() => {
mock.restore();
});
describe('fetchGeoNodes', () => {
it('calls service.getGeoNodes and sets response to the store on success', (done) => {
const mock = new MockAdapter(axios);
mock.onGet(vm.store.geoNodesPath).reply(200, mockNodes);
spyOn(vm.store, 'setNodes');
......@@ -68,7 +77,6 @@ describe('AppComponent', () => {
it('sets error flag and message on failure', (done) => {
const err = 'Something went wrong';
const mock = new MockAdapter(axios);
mock.onGet(vm.store.geoNodesPath).reply(500, err);
vm.fetchGeoNodes();
......@@ -83,7 +91,6 @@ describe('AppComponent', () => {
describe('fetchNodeDetails', () => {
it('calls service.getGeoNodeDetails and sets response to the store on success', (done) => {
const mock = new MockAdapter(axios);
mock.onGet(`${vm.service.geoNodeDetailsBasePath}/2/status.json`).reply(200, rawMockNodeDetails);
spyOn(vm.store, 'setNodeDetails');
......@@ -96,7 +103,6 @@ describe('AppComponent', () => {
it('emits `nodeDetailsLoadFailed` event on failure', (done) => {
const err = 'Something went wrong';
const mock = new MockAdapter(axios);
spyOn(eventHub, '$emit');
mock.onGet(`${vm.service.geoNodeDetailsBasePath}/2/status.json`).reply(500, err);
......
......@@ -5,6 +5,8 @@ import '~/commons';
import Vue from 'vue';
import VueResource from 'vue-resource';
import { getDefaultAdapter } from '~/lib/utils/axios_utils';
const isHeadlessChrome = /\bHeadlessChrome\//.test(navigator.userAgent);
Vue.config.devtools = !isHeadlessChrome;
Vue.config.productionTip = false;
......@@ -58,6 +60,8 @@ beforeEach(() => {
Vue.http.interceptors = builtinVueHttpInterceptors.slice();
});
const axiosDefaultAdapter = getDefaultAdapter();
// render all of our tests
const testsContext = require.context('.', true, /_spec$/);
testsContext.keys().forEach(function (path) {
......@@ -93,6 +97,12 @@ describe('test errors', () => {
it('has no Vue error', () => {
expect(hasVueErrors).toBe(false);
});
it('restores axios adapter after mocking', () => {
if (getDefaultAdapter() !== axiosDefaultAdapter) {
fail('axios adapter is not restored! Did you forget a restore() on MockAdapter?');
}
});
});
// if we're generating coverage reports, make sure to include all files so
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment