Commit 0052257c authored by Frédéric Caplette's avatar Frédéric Caplette

Merge branch '325182_01_vuex_in_specs' into 'master'

Geo Node Status 2.0 - Vuex Spec Cleanup

See merge request gitlab-org/gitlab!60151
parents 065153e6 14031b82
import { GlLink, GlButton, GlLoadingIcon, GlModal } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import GeoNodesBetaApp from 'ee/geo_nodes_beta/components/app.vue';
import GeoNodes from 'ee/geo_nodes_beta/components/geo_nodes.vue';
import GeoNodesEmptyState from 'ee/geo_nodes_beta/components/geo_nodes_empty_state.vue';
import { GEO_INFO_URL } from 'ee/geo_nodes_beta/constants';
import {
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
MOCK_NODES,
MOCK_NEW_NODE_URL,
MOCK_EMPTY_STATE_SVG,
} from '../mock_data';
import { MOCK_NODES, MOCK_NEW_NODE_URL, MOCK_EMPTY_STATE_SVG } from '../mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('GeoNodesBetaApp', () => {
let wrapper;
......@@ -33,16 +27,12 @@ describe('GeoNodesBetaApp', () => {
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
actions: actionSpies,
});
wrapper = shallowMount(GeoNodesBetaApp, {
localVue,
store,
propsData: {
...defaultProps,
......
import { GlEmptyState } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import GeoNodesEmptyState from 'ee/geo_nodes_beta/components/geo_nodes_empty_state.vue';
import { GEO_FEATURE_URL } from 'ee/geo_nodes_beta/constants';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES, MOCK_EMPTY_STATE_SVG } from '../mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
import { MOCK_EMPTY_STATE_SVG } from '../mock_data';
describe('GeoNodesEmptyState', () => {
let wrapper;
......@@ -15,19 +11,8 @@ describe('GeoNodesEmptyState', () => {
svgPath: MOCK_EMPTY_STATE_SVG,
};
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
});
const createComponent = (props) => {
wrapper = shallowMount(GeoNodesEmptyState, {
localVue,
store,
propsData: {
...defaultProps,
...props,
......
import { GlButton } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import GeoNodeActionsDesktop from 'ee/geo_nodes_beta/components/header/geo_node_actions_desktop.vue';
import {
MOCK_NODES,
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
import { MOCK_NODES } from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('GeoNodeActionsDesktop', () => {
let wrapper;
......@@ -19,20 +11,9 @@ describe('GeoNodeActionsDesktop', () => {
node: MOCK_NODES[0],
};
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
});
const createComponent = (props) => {
wrapper = extendedWrapper(
shallowMount(GeoNodeActionsDesktop, {
localVue,
store,
propsData: {
...defaultProps,
...props,
......@@ -80,7 +61,7 @@ describe('GeoNodeActionsDesktop', () => {
${false} | ${undefined}
`(`conditionally`, ({ primary, disabled }) => {
beforeEach(() => {
createComponent(null, { node: { primary } });
createComponent({ node: { primary } });
});
describe(`when primary is ${primary}`, () => {
......
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import GeoNodeActionsMobile from 'ee/geo_nodes_beta/components/header/geo_node_actions_mobile.vue';
import {
MOCK_NODES,
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
import { MOCK_NODES } from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('GeoNodeActionsMobile', () => {
let wrapper;
......@@ -19,20 +11,9 @@ describe('GeoNodeActionsMobile', () => {
node: MOCK_NODES[0],
};
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
});
const createComponent = (props) => {
wrapper = extendedWrapper(
shallowMount(GeoNodeActionsMobile, {
localVue,
store,
propsData: {
...defaultProps,
...props,
......@@ -86,7 +67,7 @@ describe('GeoNodeActionsMobile', () => {
${false} | ${undefined} | ${'gl-text-red-500'}
`(`conditionally`, ({ primary, disabled, dropdownClass }) => {
beforeEach(() => {
createComponent(null, { node: { primary } });
createComponent({ node: { primary } });
});
describe(`when primary is ${primary}`, () => {
......
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import GeoNodeActions from 'ee/geo_nodes_beta/components/header/geo_node_actions.vue';
import GeoNodeActionsDesktop from 'ee/geo_nodes_beta/components/header/geo_node_actions_desktop.vue';
import GeoNodeActionsMobile from 'ee/geo_nodes_beta/components/header/geo_node_actions_mobile.vue';
import { REMOVE_NODE_MODAL_ID } from 'ee/geo_nodes_beta/constants';
import {
MOCK_NODES,
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
import { MOCK_NODES } from 'ee_jest/geo_nodes_beta/mock_data';
import waitForPromises from 'helpers/wait_for_promises';
import { BV_SHOW_MODAL } from '~/lib/utils/constants';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('GeoNodeActions', () => {
let wrapper;
......@@ -26,19 +22,12 @@ describe('GeoNodeActions', () => {
node: MOCK_NODES[0],
};
const createComponent = (initialState, props) => {
const createComponent = (props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
actions: actionSpies,
});
wrapper = shallowMount(GeoNodeActions, {
localVue,
store,
propsData: {
...defaultProps,
......
import { GlButton, GlBadge } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import GeoNodeActions from 'ee/geo_nodes_beta/components/header/geo_node_actions.vue';
import GeoNodeHeader from 'ee/geo_nodes_beta/components/header/geo_node_header.vue';
import GeoNodeHealthStatus from 'ee/geo_nodes_beta/components/header/geo_node_health_status.vue';
import GeoNodeLastUpdated from 'ee/geo_nodes_beta/components/header/geo_node_last_updated.vue';
import {
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
MOCK_NODES,
} from 'ee_jest/geo_nodes_beta/mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
import { MOCK_NODES } from 'ee_jest/geo_nodes_beta/mock_data';
describe('GeoNodeHeader', () => {
let wrapper;
......@@ -22,19 +14,8 @@ describe('GeoNodeHeader', () => {
collapsed: false,
};
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
});
const createComponent = (props) => {
wrapper = shallowMount(GeoNodeHeader, {
localVue,
store,
propsData: {
...defaultProps,
...props,
......@@ -84,7 +65,7 @@ describe('GeoNodeHeader', () => {
describe('when collapsed', () => {
beforeEach(() => {
createComponent(null, { collapsed: true });
createComponent({ collapsed: true });
});
it('renders the chevron-right icon', () => {
......@@ -118,7 +99,7 @@ describe('GeoNodeHeader', () => {
describe('when current node is false', () => {
beforeEach(() => {
createComponent(null, { node: MOCK_NODES[1] });
createComponent({ node: MOCK_NODES[1] });
});
it('does not render', () => {
......
import { GlIcon, GlBadge } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import GeoNodeHealthStatus from 'ee/geo_nodes_beta/components/header/geo_node_health_status.vue';
import { HEALTH_STATUS_UI } from 'ee/geo_nodes_beta/constants';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES } from 'ee_jest/geo_nodes_beta/mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('GeoNodeHealthStatus', () => {
let wrapper;
......@@ -15,19 +10,8 @@ describe('GeoNodeHealthStatus', () => {
status: 'Healthy',
};
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
});
const createComponent = (props) => {
wrapper = shallowMount(GeoNodeHealthStatus, {
localVue,
store,
propsData: {
...defaultProps,
...props,
......@@ -52,7 +36,7 @@ describe('GeoNodeHealthStatus', () => {
${'Offline'} | ${HEALTH_STATUS_UI.offline}
`(`template`, ({ status, uiData }) => {
beforeEach(() => {
createComponent(null, { status });
createComponent({ status });
});
describe(`when status is ${status}`, () => {
......
import { GlPopover, GlLink, GlIcon } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { shallowMount } from '@vue/test-utils';
import GeoNodeLastUpdated from 'ee/geo_nodes_beta/components/header/geo_node_last_updated.vue';
import {
HELP_NODE_HEALTH_URL,
GEO_TROUBLESHOOTING_URL,
STATUS_DELAY_THRESHOLD_MS,
} from 'ee/geo_nodes_beta/constants';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES } from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import { differenceInMilliseconds } from '~/lib/utils/datetime_utility';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('GeoNodeLastUpdated', () => {
let wrapper;
......@@ -25,20 +20,9 @@ describe('GeoNodeLastUpdated', () => {
statusCheckTimestamp: staleStatusTime,
};
const createComponent = (initialState, props) => {
const store = new Vuex.Store({
state: {
primaryVersion: MOCK_PRIMARY_VERSION.version,
primaryRevision: MOCK_PRIMARY_VERSION.revision,
replicableTypes: MOCK_REPLICABLE_TYPES,
...initialState,
},
});
const createComponent = (props) => {
wrapper = extendedWrapper(
shallowMount(GeoNodeLastUpdated, {
localVue,
store,
propsData: {
...defaultProps,
...props,
......@@ -95,7 +79,7 @@ describe('GeoNodeLastUpdated', () => {
});
it('when sync is not stale popover link renders correctly', () => {
createComponent(null, { statusCheckTimestamp: nonStaleStatusTime });
createComponent({ statusCheckTimestamp: nonStaleStatusTime });
expect(findPopoverLink().text()).toBe('Learn more about Geo node statuses');
expect(findPopoverLink().attributes('href')).toBe(HELP_NODE_HEALTH_URL);
......
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