Commit dc59334b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '208470_05-rename-vue-components' into 'master'

Geo Replication - Rename Files and Cleanup

See merge request gitlab-org/gitlab!27541
parents c46f75fe 9e00489d
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import GeoDesignsFilterBar from './geo_designs_filter_bar.vue'; import GeoReplicableFilterBar from './geo_replicable_filter_bar.vue';
import GeoDesigns from './geo_designs.vue'; import GeoReplicable from './geo_replicable.vue';
import GeoDesignsEmptyState from './geo_designs_empty_state.vue'; import GeoReplicableEmptyState from './geo_replicable_empty_state.vue';
export default { export default {
name: 'GeoDesignsApp', name: 'GeoReplicableApp',
components: { components: {
GlLoadingIcon, GlLoadingIcon,
GeoDesignsFilterBar, GeoReplicableFilterBar,
GeoDesigns, GeoReplicable,
GeoDesignsEmptyState, GeoReplicableEmptyState,
}, },
props: { props: {
geoSvgPath: { geoSvgPath: {
...@@ -43,12 +43,12 @@ export default { ...@@ -43,12 +43,12 @@ export default {
</script> </script>
<template> <template>
<article class="geo-designs-container"> <article class="geo-replicable-container">
<geo-designs-filter-bar /> <geo-replicable-filter-bar />
<gl-loading-icon v-if="isLoading" size="xl" /> <gl-loading-icon v-if="isLoading" size="xl" />
<template v-else> <template v-else>
<geo-designs v-if="hasReplicableItems" /> <geo-replicable v-if="hasReplicableItems" />
<geo-designs-empty-state <geo-replicable-empty-state
v-else v-else
:issues-svg-path="issuesSvgPath" :issues-svg-path="issuesSvgPath"
:geo-troubleshooting-link="geoTroubleshootingLink" :geo-troubleshooting-link="geoTroubleshootingLink"
......
<script> <script>
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { GlPagination } from '@gitlab/ui'; import { GlPagination } from '@gitlab/ui';
import GeoDesign from './geo_design.vue'; import GeoReplicableItem from './geo_replicable_item.vue';
export default { export default {
name: 'GeoDesigns', name: 'GeoReplicable',
components: { components: {
GlPagination, GlPagination,
GeoDesign, GeoReplicableItem,
}, },
computed: { computed: {
...mapState(['replicableItems', 'currentPage', 'pageSize', 'totalReplicableItems']), ...mapState(['replicableItems', 'currentPage', 'pageSize', 'totalReplicableItems']),
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
<template> <template>
<section> <section>
<geo-design <geo-replicable-item
v-for="item in replicableItems" v-for="item in replicableItems"
:key="item.id" :key="item.id"
:name="item.name" :name="item.name"
......
...@@ -4,7 +4,7 @@ import { GlEmptyState } from '@gitlab/ui'; ...@@ -4,7 +4,7 @@ import { GlEmptyState } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
export default { export default {
name: 'GeoEmptyState', name: 'GeoReplicableEmptyState',
components: { components: {
GlEmptyState, GlEmptyState,
}, },
......
...@@ -7,7 +7,7 @@ import Icon from '~/vue_shared/components/icon.vue'; ...@@ -7,7 +7,7 @@ import Icon from '~/vue_shared/components/icon.vue';
import { DEFAULT_SEARCH_DELAY, ACTION_TYPES } from '../store/constants'; import { DEFAULT_SEARCH_DELAY, ACTION_TYPES } from '../store/constants';
export default { export default {
name: 'GeoDesignsFilterBar', name: 'GeoReplicableFilterBar',
components: { components: {
GlTabs, GlTabs,
GlTab, GlTab,
......
...@@ -3,16 +3,16 @@ import { mapActions } from 'vuex'; ...@@ -3,16 +3,16 @@ import { mapActions } from 'vuex';
import { GlLink, GlDeprecatedButton } from '@gitlab/ui'; import { GlLink, GlDeprecatedButton } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { ACTION_TYPES } from '../store/constants'; import { ACTION_TYPES } from '../store/constants';
import GeoDesignStatus from './geo_design_status.vue'; import GeoReplicableStatus from './geo_replicable_status.vue';
import GeoDesignTimeAgo from './geo_design_time_ago.vue'; import GeoReplicableTimeAgo from './geo_replicable_time_ago.vue';
export default { export default {
name: 'GeoDesign', name: 'GeoReplicableItem',
components: { components: {
GlLink, GlLink,
GlDeprecatedButton, GlDeprecatedButton,
GeoDesignTimeAgo, GeoReplicableTimeAgo,
GeoDesignStatus, GeoReplicableStatus,
}, },
props: { props: {
name: { name: {
...@@ -87,9 +87,9 @@ export default { ...@@ -87,9 +87,9 @@ export default {
<div class="d-flex flex-column flex-md-row"> <div class="d-flex flex-column flex-md-row">
<div class="flex-grow-1"> <div class="flex-grow-1">
<label class="text-muted">{{ __('Status') }}</label> <label class="text-muted">{{ __('Status') }}</label>
<geo-design-status :status="syncStatus" /> <geo-replicable-status :status="syncStatus" />
</div> </div>
<geo-design-time-ago <geo-replicable-time-ago
v-for="(timeAgo, index) in timeAgoArray" v-for="(timeAgo, index) in timeAgoArray"
:key="index" :key="index"
class="flex-grow-1" class="flex-grow-1"
......
...@@ -3,7 +3,7 @@ import { STATUS_ICON_NAMES, STATUS_ICON_CLASS, DEFAULT_STATUS } from '../store/c ...@@ -3,7 +3,7 @@ import { STATUS_ICON_NAMES, STATUS_ICON_CLASS, DEFAULT_STATUS } from '../store/c
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
export default { export default {
name: 'GeoDesignStatus', name: 'GeoReplicableStatus',
components: { components: {
Icon, Icon,
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
export default { export default {
name: 'GeoDesignTimeAgo', name: 'GeoReplicableTimeAgo',
components: { components: {
TimeAgo, TimeAgo,
}, },
......
import Vue from 'vue'; import Vue from 'vue';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import createStore from './store'; import createStore from './store';
import GeoDesignsApp from './components/app.vue'; import GeoReplicableApp from './components/app.vue';
Vue.use(Translate); Vue.use(Translate);
export default () => { export default () => {
const el = document.getElementById('js-geo-designs'); const el = document.getElementById('js-geo-replicable');
const { replicableType } = el.dataset; const { replicableType } = el.dataset;
return new Vue({ return new Vue({
el, el,
store: createStore(replicableType), store: createStore(replicableType),
components: { components: {
GeoDesignsApp, GeoReplicableApp,
}, },
data() { data() {
const { const {
...@@ -28,7 +28,7 @@ export default () => { ...@@ -28,7 +28,7 @@ export default () => {
}, },
render(createElement) { render(createElement) {
return createElement('geo-designs-app', { return createElement('geo-replicable-app', {
props: { props: {
geoSvgPath: this.geoSvgPath, geoSvgPath: this.geoSvgPath,
issuesSvgPath: this.issuesSvgPath, issuesSvgPath: this.issuesSvgPath,
......
import initGeoDesigns from 'ee/geo_designs'; import initGeoReplicable from 'ee/geo_replicable';
document.addEventListener('DOMContentLoaded', initGeoDesigns); document.addEventListener('DOMContentLoaded', initGeoReplicable);
- page_title _('Geo Designs') - page_title _('Geo Designs')
#js-geo-designs{ data: { "geo-svg-path" => image_path('illustrations/empty-state/geo-empty.svg'), #js-geo-replicable{ data: { "geo-svg-path" => image_path('illustrations/empty-state/geo-empty.svg'),
"issues-svg-path" => image_path('illustrations/issues.svg'), "issues-svg-path" => image_path('illustrations/issues.svg'),
"geo-troubleshooting-link" => help_page_path('administration/geo/replication/troubleshooting.html'), "geo-troubleshooting-link" => help_page_path('administration/geo/replication/troubleshooting.html'),
"replicable-type" => 'designs' } } "replicable-type" => 'designs' } }
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GeoDesignTimeAgo template when dateString exists TimeAgo sets innerHTML as 09-23-1994 1`] = `"<time title=\\"Sep 23, 1994 12:00am GMT+0000\\" class=\\"\\">25 years ago</time>"`;
exports[`GeoDesignTimeAgo template when dateString is null DefaultText sets innerHTML as props.defaultText 1`] = `"<span>Default Text</span>"`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GeoReplicableTimeAgo template when dateString exists TimeAgo sets innerHTML as 09-23-1994 1`] = `"<time title=\\"Sep 23, 1994 12:00am GMT+0000\\" class=\\"\\">25 years ago</time>"`;
exports[`GeoReplicableTimeAgo template when dateString is null DefaultText sets innerHTML as props.defaultText 1`] = `"<span>Default Text</span>"`;
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import GeoDesignsApp from 'ee/geo_designs/components/app.vue'; import GeoReplicableApp from 'ee/geo_replicable/components/app.vue';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import GeoDesigns from 'ee/geo_designs/components/geo_designs.vue'; import GeoReplicable from 'ee/geo_replicable/components/geo_replicable.vue';
import GeoDesignsEmptyState from 'ee/geo_designs/components/geo_designs_empty_state.vue'; import GeoReplicableEmptyState from 'ee/geo_replicable/components/geo_replicable_empty_state.vue';
import GeoDesignsFilterBar from 'ee/geo_designs/components/geo_designs_filter_bar.vue'; import GeoReplicableFilterBar from 'ee/geo_replicable/components/geo_replicable_filter_bar.vue';
import { import {
MOCK_GEO_SVG_PATH, MOCK_GEO_SVG_PATH,
MOCK_ISSUES_SVG_PATH, MOCK_ISSUES_SVG_PATH,
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesignsApp', () => { describe('GeoReplicableApp', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
...@@ -31,7 +31,7 @@ describe('GeoDesignsApp', () => { ...@@ -31,7 +31,7 @@ describe('GeoDesignsApp', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = shallowMount(GeoDesignsApp, { wrapper = shallowMount(GeoReplicableApp, {
localVue, localVue,
store, store,
propsData, propsData,
...@@ -45,23 +45,25 @@ describe('GeoDesignsApp', () => { ...@@ -45,23 +45,25 @@ describe('GeoDesignsApp', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoDesignsContainer = () => wrapper.find('.geo-designs-container'); const findGeoReplicableContainer = () => wrapper.find('.geo-replicable-container');
const findGlLoadingIcon = () => findGeoDesignsContainer().find(GlLoadingIcon); const findGlLoadingIcon = () => findGeoReplicableContainer().find(GlLoadingIcon);
const findGeoDesigns = () => findGeoDesignsContainer().find(GeoDesigns); const findGeoReplicable = () => findGeoReplicableContainer().find(GeoReplicable);
const findGeoDesignsEmptyState = () => findGeoDesignsContainer().find(GeoDesignsEmptyState); const findGeoReplicableEmptyState = () =>
const findGeoDesignsFilterBar = () => findGeoDesignsContainer().find(GeoDesignsFilterBar); findGeoReplicableContainer().find(GeoReplicableEmptyState);
const findGeoReplicableFilterBar = () =>
findGeoReplicableContainer().find(GeoReplicableFilterBar);
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
}); });
it('renders the design container', () => { it('renders the replicable container', () => {
expect(findGeoDesignsContainer().exists()).toBe(true); expect(findGeoReplicableContainer().exists()).toBe(true);
}); });
it('renders the filter bar', () => { it('renders the filter bar', () => {
expect(findGeoDesignsFilterBar().exists()).toBe(true); expect(findGeoReplicableFilterBar().exists()).toBe(true);
}); });
describe('when isLoading = true', () => { describe('when isLoading = true', () => {
...@@ -69,12 +71,12 @@ describe('GeoDesignsApp', () => { ...@@ -69,12 +71,12 @@ describe('GeoDesignsApp', () => {
wrapper.vm.$store.state.isLoading = true; wrapper.vm.$store.state.isLoading = true;
}); });
it('hides designs', () => { it('hides replicable items', () => {
expect(findGeoDesigns().exists()).toBe(false); expect(findGeoReplicable().exists()).toBe(false);
}); });
it('hides empty state', () => { it('hides empty state', () => {
expect(findGeoDesignsEmptyState().exists()).toBe(false); expect(findGeoReplicableEmptyState().exists()).toBe(false);
}); });
it('shows loader', () => { it('shows loader', () => {
...@@ -93,12 +95,12 @@ describe('GeoDesignsApp', () => { ...@@ -93,12 +95,12 @@ describe('GeoDesignsApp', () => {
wrapper.vm.$store.state.totalReplicableItems = MOCK_BASIC_FETCH_DATA_MAP.total; wrapper.vm.$store.state.totalReplicableItems = MOCK_BASIC_FETCH_DATA_MAP.total;
}); });
it('shows designs', () => { it('shows replicable items', () => {
expect(findGeoDesigns().exists()).toBe(true); expect(findGeoReplicable().exists()).toBe(true);
}); });
it('hides empty state', () => { it('hides empty state', () => {
expect(findGeoDesignsEmptyState().exists()).toBe(false); expect(findGeoReplicableEmptyState().exists()).toBe(false);
}); });
it('hides loader', () => { it('hides loader', () => {
...@@ -112,12 +114,12 @@ describe('GeoDesignsApp', () => { ...@@ -112,12 +114,12 @@ describe('GeoDesignsApp', () => {
wrapper.vm.$store.state.totalReplicableItems = 0; wrapper.vm.$store.state.totalReplicableItems = 0;
}); });
it('hides designs', () => { it('hides replicable items', () => {
expect(findGeoDesigns().exists()).toBe(false); expect(findGeoReplicable().exists()).toBe(false);
}); });
it('shows empty state', () => { it('shows empty state', () => {
expect(findGeoDesignsEmptyState().exists()).toBe(true); expect(findGeoReplicableEmptyState().exists()).toBe(true);
}); });
it('hides loader', () => { it('hides loader', () => {
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import { GlEmptyState } from '@gitlab/ui'; import { GlEmptyState } from '@gitlab/ui';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import GeoDesignsEmptyState from 'ee/geo_designs/components/geo_designs_empty_state.vue'; import GeoReplicableEmptyState from 'ee/geo_replicable/components/geo_replicable_empty_state.vue';
import { MOCK_ISSUES_SVG_PATH, MOCK_GEO_TROUBLESHOOTING_LINK } from '../mock_data'; import { MOCK_ISSUES_SVG_PATH, MOCK_GEO_TROUBLESHOOTING_LINK } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesignsEmptyState', () => { describe('GeoReplicableEmptyState', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
...@@ -17,7 +17,7 @@ describe('GeoDesignsEmptyState', () => { ...@@ -17,7 +17,7 @@ describe('GeoDesignsEmptyState', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(GeoDesignsEmptyState, { wrapper = mount(GeoReplicableEmptyState, {
localVue, localVue,
store, store,
propsData, propsData,
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import { GlTabs, GlTab, GlFormInput, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlTabs, GlTab, GlFormInput, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import GeoDesignsFilterBar from 'ee/geo_designs/components/geo_designs_filter_bar.vue'; import GeoReplicableFilterBar from 'ee/geo_replicable/components/geo_replicable_filter_bar.vue';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import { DEFAULT_SEARCH_DELAY } from 'ee/geo_designs/store/constants'; import { DEFAULT_SEARCH_DELAY } from 'ee/geo_replicable/store/constants';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesignsFilterBar', () => { describe('GeoReplicableFilterBar', () => {
let wrapper; let wrapper;
const actionSpies = { const actionSpies = {
...@@ -19,7 +19,7 @@ describe('GeoDesignsFilterBar', () => { ...@@ -19,7 +19,7 @@ describe('GeoDesignsFilterBar', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(GeoDesignsFilterBar, { wrapper = mount(GeoReplicableFilterBar, {
localVue, localVue,
store, store,
methods: { methods: {
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import { GlLink, GlDeprecatedButton } from '@gitlab/ui'; import { GlLink, GlDeprecatedButton } from '@gitlab/ui';
import GeoDesign from 'ee/geo_designs/components/geo_design.vue'; import GeoReplicableItem from 'ee/geo_replicable/components/geo_replicable_item.vue';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import { ACTION_TYPES } from 'ee/geo_designs/store/constants'; import { ACTION_TYPES } from 'ee/geo_replicable/store/constants';
import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data'; import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesignsApp', () => { describe('GeoReplicableItem', () => {
let wrapper; let wrapper;
const mockDesign = MOCK_BASIC_FETCH_DATA_MAP.data[0]; const mockReplicable = MOCK_BASIC_FETCH_DATA_MAP.data[0];
const actionSpies = { const actionSpies = {
initiateReplicableSync: jest.fn(), initiateReplicableSync: jest.fn(),
}; };
const propsData = { const propsData = {
name: mockDesign.name, name: mockReplicable.name,
projectId: mockDesign.projectId, projectId: mockReplicable.projectId,
syncStatus: mockDesign.state, syncStatus: mockReplicable.state,
lastSynced: mockDesign.lastSyncedAt, lastSynced: mockReplicable.lastSyncedAt,
lastVerified: null, lastVerified: null,
lastChecked: null, lastChecked: null,
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(GeoDesign, { wrapper = mount(GeoReplicableItem, {
localVue, localVue,
store, store,
propsData, propsData,
...@@ -73,7 +73,7 @@ describe('GeoDesignsApp', () => { ...@@ -73,7 +73,7 @@ describe('GeoDesignsApp', () => {
expect(findGlButton().exists()).toBe(true); expect(findGlButton().exists()).toBe(true);
}); });
it('calls initiateDesignSyncs when clicked', () => { it('calls initiateReplicableSync when clicked', () => {
findGlButton().trigger('click'); findGlButton().trigger('click');
expect(actionSpies.initiateReplicableSync).toHaveBeenCalledWith({ expect(actionSpies.initiateReplicableSync).toHaveBeenCalledWith({
projectId: propsData.projectId, projectId: propsData.projectId,
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import { GlPagination } from '@gitlab/ui'; import { GlPagination } from '@gitlab/ui';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import GeoDesigns from 'ee/geo_designs/components/geo_designs.vue'; import GeoReplicable from 'ee/geo_replicable/components/geo_replicable.vue';
import GeoDesign from 'ee/geo_designs/components/geo_design.vue'; import GeoReplicableItem from 'ee/geo_replicable/components/geo_replicable_item.vue';
import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data'; import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesigns', () => { describe('GeoReplicable', () => {
let wrapper; let wrapper;
const actionSpies = { const actionSpies = {
...@@ -18,7 +18,7 @@ describe('GeoDesigns', () => { ...@@ -18,7 +18,7 @@ describe('GeoDesigns', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(GeoDesigns, { wrapper = mount(GeoReplicable, {
localVue, localVue,
store, store,
methods: { methods: {
...@@ -31,17 +31,17 @@ describe('GeoDesigns', () => { ...@@ -31,17 +31,17 @@ describe('GeoDesigns', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoDesignsContainer = () => wrapper.find('section'); const findGeoReplicableContainer = () => wrapper.find('section');
const findGlPagination = () => findGeoDesignsContainer().find(GlPagination); const findGlPagination = () => findGeoReplicableContainer().find(GlPagination);
const findGeoDesign = () => findGeoDesignsContainer().findAll(GeoDesign); const findGeoReplicableItem = () => findGeoReplicableContainer().findAll(GeoReplicableItem);
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
}); });
it('renders the designs container', () => { it('renders the replicable container', () => {
expect(findGeoDesignsContainer().exists()).toBe(true); expect(findGeoReplicableContainer().exists()).toBe(true);
}); });
describe('GlPagination', () => { describe('GlPagination', () => {
...@@ -68,17 +68,17 @@ describe('GeoDesigns', () => { ...@@ -68,17 +68,17 @@ describe('GeoDesigns', () => {
}); });
}); });
describe('GeoDesign', () => { describe('GeoReplicableItem', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.$store.state.replicableItems = MOCK_BASIC_FETCH_DATA_MAP.data; wrapper.vm.$store.state.replicableItems = MOCK_BASIC_FETCH_DATA_MAP.data;
}); });
it('renders an instance for each design in the store', () => { it('renders an instance for each replicableItem in the store', () => {
const designWrappers = findGeoDesign(); const replicableItemWrappers = findGeoReplicableItem();
const replicableItems = [...wrapper.vm.$store.state.replicableItems]; const replicableItems = [...wrapper.vm.$store.state.replicableItems];
for (let i = 0; i < designWrappers.length; i += 1) { for (let i = 0; i < replicableItemWrappers.length; i += 1) {
expect(designWrappers.at(i).props().projectId).toBe(replicableItems[i].projectId); expect(replicableItemWrappers.at(i).props().projectId).toBe(replicableItems[i].projectId);
} }
}); });
}); });
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import GeoDesignStatus from 'ee/geo_designs/components/geo_design_status.vue'; import GeoReplicableStatus from 'ee/geo_replicable/components/geo_replicable_status.vue';
import { import {
FILTER_STATES, FILTER_STATES,
STATUS_ICON_NAMES, STATUS_ICON_NAMES,
STATUS_ICON_CLASS, STATUS_ICON_CLASS,
DEFAULT_STATUS, DEFAULT_STATUS,
} from 'ee/geo_designs/store/constants'; } from 'ee/geo_replicable/store/constants';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesignStatus', () => { describe('GeoReplicableStatus', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
...@@ -21,7 +21,7 @@ describe('GeoDesignStatus', () => { ...@@ -21,7 +21,7 @@ describe('GeoDesignStatus', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(GeoDesignStatus, { wrapper = mount(GeoReplicableStatus, {
localVue, localVue,
store, store,
propsData, propsData,
...@@ -32,8 +32,8 @@ describe('GeoDesignStatus', () => { ...@@ -32,8 +32,8 @@ describe('GeoDesignStatus', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoDesignStatusContainer = () => wrapper.find('div'); const findGeoReplicableStatusContainer = () => wrapper.find('div');
const findIcon = () => findGeoDesignStatusContainer().find(Icon); const findIcon = () => findGeoReplicableStatusContainer().find(Icon);
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(() => {
...@@ -41,7 +41,7 @@ describe('GeoDesignStatus', () => { ...@@ -41,7 +41,7 @@ describe('GeoDesignStatus', () => {
}); });
it('renders status container', () => { it('renders status container', () => {
expect(findGeoDesignStatusContainer().exists()).toBe(true); expect(findGeoReplicableStatusContainer().exists()).toBe(true);
}); });
}); });
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { createLocalVue, mount } from '@vue/test-utils'; import { createLocalVue, mount } from '@vue/test-utils';
import store from 'ee/geo_designs/store'; import store from 'ee/geo_replicable/store';
import GeoDesignTimeAgo from 'ee/geo_designs/components/geo_design_time_ago.vue'; import GeoReplicableTimeAgo from 'ee/geo_replicable/components/geo_replicable_time_ago.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
describe('GeoDesignTimeAgo', () => { describe('GeoReplicableTimeAgo', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
...@@ -17,7 +17,7 @@ describe('GeoDesignTimeAgo', () => { ...@@ -17,7 +17,7 @@ describe('GeoDesignTimeAgo', () => {
}; };
const createComponent = () => { const createComponent = () => {
wrapper = mount(GeoDesignTimeAgo, { wrapper = mount(GeoReplicableTimeAgo, {
localVue, localVue,
store, store,
propsData, propsData,
...@@ -28,17 +28,17 @@ describe('GeoDesignTimeAgo', () => { ...@@ -28,17 +28,17 @@ describe('GeoDesignTimeAgo', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoDesignTimeAgo = () => wrapper.find(GeoDesignTimeAgo); const findGeoReplicableTimeAgo = () => wrapper.find(GeoReplicableTimeAgo);
const findTimeAgo = () => findGeoDesignTimeAgo().find(TimeAgo); const findTimeAgo = () => findGeoReplicableTimeAgo().find(TimeAgo);
const findDefaultText = () => findGeoDesignTimeAgo().find('span'); const findDefaultText = () => findGeoReplicableTimeAgo().find('span');
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
}); });
it('renders GeoDesignTimeAgo container', () => { it('renders GeoReplicableTimeAgo container', () => {
expect(findGeoDesignTimeAgo().exists()).toBe(true); expect(findGeoReplicableTimeAgo().exists()).toBe(true);
}); });
describe('when dateString exists', () => { describe('when dateString exists', () => {
......
...@@ -2,10 +2,10 @@ import testAction from 'helpers/vuex_action_helper'; ...@@ -2,10 +2,10 @@ import testAction from 'helpers/vuex_action_helper';
import flash from '~/flash'; import flash from '~/flash';
import toast from '~/vue_shared/plugins/global_toast'; import toast from '~/vue_shared/plugins/global_toast';
import Api from 'ee/api'; import Api from 'ee/api';
import * as actions from 'ee/geo_designs/store/actions'; import * as actions from 'ee/geo_replicable/store/actions';
import * as types from 'ee/geo_designs/store/mutation_types'; import * as types from 'ee/geo_replicable/store/mutation_types';
import createState from 'ee/geo_designs/store/state'; import createState from 'ee/geo_replicable/store/state';
import { ACTION_TYPES } from 'ee/geo_designs/store/constants'; import { ACTION_TYPES } from 'ee/geo_replicable/store/constants';
import { import {
MOCK_BASIC_FETCH_DATA_MAP, MOCK_BASIC_FETCH_DATA_MAP,
MOCK_BASIC_FETCH_RESPONSE, MOCK_BASIC_FETCH_RESPONSE,
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
jest.mock('~/flash'); jest.mock('~/flash');
jest.mock('~/vue_shared/plugins/global_toast'); jest.mock('~/vue_shared/plugins/global_toast');
describe('GeoDesigns Store Actions', () => { describe('GeoReplicable Store Actions', () => {
let state; let state;
beforeEach(() => { beforeEach(() => {
......
import mutations from 'ee/geo_designs/store/mutations'; import mutations from 'ee/geo_replicable/store/mutations';
import createState from 'ee/geo_designs/store/state'; import createState from 'ee/geo_replicable/store/state';
import * as types from 'ee/geo_designs/store/mutation_types'; import * as types from 'ee/geo_replicable/store/mutation_types';
import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data'; import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data';
describe('GeoReplicable Store Mutations', () => { describe('GeoReplicable Store Mutations', () => {
...@@ -76,12 +76,12 @@ describe('GeoReplicable Store Mutations', () => { ...@@ -76,12 +76,12 @@ describe('GeoReplicable Store Mutations', () => {
expect(state.isLoading).toEqual(false); expect(state.isLoading).toEqual(false);
}); });
it('sets designs array with data', () => { it('sets replicableItems array with data', () => {
mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.replicableItems).toBe(mockData.data); expect(state.replicableItems).toBe(mockData.data);
}); });
it('sets pageSize and totalDesigns', () => { it('sets pageSize and totalReplicableItems', () => {
mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.pageSize).toEqual(mockData.perPage); expect(state.pageSize).toEqual(mockData.perPage);
expect(state.totalReplicableItems).toEqual(mockData.total); expect(state.totalReplicableItems).toEqual(mockData.total);
...@@ -102,7 +102,7 @@ describe('GeoReplicable Store Mutations', () => { ...@@ -102,7 +102,7 @@ describe('GeoReplicable Store Mutations', () => {
expect(state.isLoading).toEqual(false); expect(state.isLoading).toEqual(false);
}); });
it('resets designs array', () => { it('resets replicableItems array', () => {
state.replicableItems = mockData.data; state.replicableItems = mockData.data;
mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state); mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state);
......
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