Commit b1c95d46 authored by Mike Greiling's avatar Mike Greiling

Merge branch '325182_04_test_cleanup' into 'master'

Geo Node Status 2.0 - Tests Cleanup

See merge request gitlab-org/gitlab!60167
parents c7a5964b 323f8776
...@@ -51,15 +51,14 @@ describe('GeoNodesBetaApp', () => { ...@@ -51,15 +51,14 @@ describe('GeoNodesBetaApp', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findGeoNodesBetaContainer = () => wrapper.find('section'); const findGeoNodesBetaContainer = () => wrapper.find('section');
const findGeoLearnMoreLink = () => wrapper.find(GlLink); const findGeoLearnMoreLink = () => wrapper.findComponent(GlLink);
const findGeoAddSiteButton = () => wrapper.find(GlButton); const findGeoAddSiteButton = () => wrapper.findComponent(GlButton);
const findGlLoadingIcon = () => wrapper.find(GlLoadingIcon); const findGlLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findGeoEmptyState = () => wrapper.find(GeoNodesEmptyState); const findGeoEmptyState = () => wrapper.findComponent(GeoNodesEmptyState);
const findGeoNodes = () => wrapper.findAll(GeoNodes); const findGeoNodes = () => wrapper.findAllComponents(GeoNodes);
describe('template', () => { describe('template', () => {
describe('always', () => { describe('always', () => {
...@@ -91,19 +90,19 @@ describe('GeoNodesBetaApp', () => { ...@@ -91,19 +90,19 @@ describe('GeoNodesBetaApp', () => {
}); });
describe(`when isLoading is ${isLoading} & nodes length ${nodes.length}`, () => { describe(`when isLoading is ${isLoading} & nodes length ${nodes.length}`, () => {
it(`does ${!showLoadingIcon ? 'not ' : ''}render GlLoadingIcon`, () => { it(`does ${showLoadingIcon ? '' : 'not '}render GlLoadingIcon`, () => {
expect(findGlLoadingIcon().exists()).toBe(showLoadingIcon); expect(findGlLoadingIcon().exists()).toBe(showLoadingIcon);
}); });
it(`does ${!showNodes ? 'not ' : ''}render GeoNodes`, () => { it(`does ${showNodes ? '' : 'not '}render GeoNodes`, () => {
expect(findGeoNodes().exists()).toBe(showNodes); expect(findGeoNodes().exists()).toBe(showNodes);
}); });
it(`does ${!showEmptyState ? 'not ' : ''}render EmptyState`, () => { it(`does ${showEmptyState ? '' : 'not '}render EmptyState`, () => {
expect(findGeoEmptyState().exists()).toBe(showEmptyState); expect(findGeoEmptyState().exists()).toBe(showEmptyState);
}); });
it(`does ${!showAddButton ? 'not ' : ''}render AddSiteButton`, () => { it(`does ${showAddButton ? '' : 'not '}render AddSiteButton`, () => {
expect(findGeoAddSiteButton().exists()).toBe(showAddButton); expect(findGeoAddSiteButton().exists()).toBe(showAddButton);
}); });
}); });
......
...@@ -37,10 +37,9 @@ describe('GeoNodesEmptyState', () => { ...@@ -37,10 +37,9 @@ describe('GeoNodesEmptyState', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findGeoEmptyState = () => wrapper.find(GlEmptyState); const findGeoEmptyState = () => wrapper.findComponent(GlEmptyState);
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -22,7 +22,6 @@ describe('GeoNodes', () => { ...@@ -22,7 +22,6 @@ describe('GeoNodes', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findGeoNodesContainer = () => wrapper.find('div'); const findGeoNodesContainer = () => wrapper.find('div');
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
MOCK_PRIMARY_VERSION, MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES, MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data'; } from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -28,23 +29,24 @@ describe('GeoNodeActionsDesktop', () => { ...@@ -28,23 +29,24 @@ describe('GeoNodeActionsDesktop', () => {
}, },
}); });
wrapper = shallowMount(GeoNodeActionsDesktop, { wrapper = extendedWrapper(
localVue, shallowMount(GeoNodeActionsDesktop, {
store, localVue,
propsData: { store,
...defaultProps, propsData: {
...props, ...defaultProps,
}, ...props,
}); },
}),
);
}; };
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoDesktopActionsButtons = () => wrapper.findAll(GlButton); const findGeoDesktopActionsButtons = () => wrapper.findAllComponents(GlButton);
const findGeoDesktopActionsRemoveButton = () => const findGeoDesktopActionsRemoveButton = () => wrapper.findByTestId('geo-desktop-remove-action');
wrapper.find('[data-testid="geo-desktop-remove-action"]');
describe('template', () => { describe('template', () => {
describe('always', () => { describe('always', () => {
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
MOCK_PRIMARY_VERSION, MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES, MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data'; } from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -28,24 +29,26 @@ describe('GeoNodeActionsMobile', () => { ...@@ -28,24 +29,26 @@ describe('GeoNodeActionsMobile', () => {
}, },
}); });
wrapper = shallowMount(GeoNodeActionsMobile, { wrapper = extendedWrapper(
localVue, shallowMount(GeoNodeActionsMobile, {
store, localVue,
propsData: { store,
...defaultProps, propsData: {
...props, ...defaultProps,
}, ...props,
}); },
}),
);
}; };
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoMobileActionsDropdown = () => wrapper.find(GlDropdown); const findGeoMobileActionsDropdown = () => wrapper.findComponent(GlDropdown);
const findGeoMobileActionsDropdownItems = () => wrapper.findAll(GlDropdownItem); const findGeoMobileActionsDropdownItems = () => wrapper.findAllComponents(GlDropdownItem);
const findGeoMobileActionsRemoveDropdownItem = () => const findGeoMobileActionsRemoveDropdownItem = () =>
wrapper.find('[data-testid="geo-mobile-remove-action"]'); wrapper.findByTestId('geo-mobile-remove-action');
describe('template', () => { describe('template', () => {
describe('always', () => { describe('always', () => {
......
...@@ -43,8 +43,8 @@ describe('GeoNodeActions', () => { ...@@ -43,8 +43,8 @@ describe('GeoNodeActions', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoMobileActions = () => wrapper.find(GeoNodeActionsMobile); const findGeoMobileActions = () => wrapper.findComponent(GeoNodeActionsMobile);
const findGeoDesktopActions = () => wrapper.find(GeoNodeActionsDesktop); const findGeoDesktopActions = () => wrapper.findComponent(GeoNodeActionsDesktop);
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -46,11 +46,11 @@ describe('GeoNodeHeader', () => { ...@@ -46,11 +46,11 @@ describe('GeoNodeHeader', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findHeaderCollapseButton = () => wrapper.find(GlButton); const findHeaderCollapseButton = () => wrapper.findComponent(GlButton);
const findCurrentNodeBadge = () => wrapper.find(GlBadge); const findCurrentNodeBadge = () => wrapper.findComponent(GlBadge);
const findGeoNodeHealthStatus = () => wrapper.find(GeoNodeHealthStatus); const findGeoNodeHealthStatus = () => wrapper.findComponent(GeoNodeHealthStatus);
const findGeoNodeLastUpdated = () => wrapper.find(GeoNodeLastUpdated); const findGeoNodeLastUpdated = () => wrapper.findComponent(GeoNodeLastUpdated);
const findGeoNodeActions = () => wrapper.find(GeoNodeActions); const findGeoNodeActions = () => wrapper.findComponent(GeoNodeActions);
describe('template', () => { describe('template', () => {
describe('always', () => { describe('always', () => {
......
...@@ -39,8 +39,8 @@ describe('GeoNodeHealthStatus', () => { ...@@ -39,8 +39,8 @@ describe('GeoNodeHealthStatus', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGeoStatusBadge = () => wrapper.find(GlBadge); const findGeoStatusBadge = () => wrapper.findComponent(GlBadge);
const findGeoStatusIcon = () => wrapper.find(GlIcon); const findGeoStatusIcon = () => wrapper.findComponent(GlIcon);
const findGeoStatusText = () => wrapper.find('span'); const findGeoStatusText = () => wrapper.find('span');
describe.each` describe.each`
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
STATUS_DELAY_THRESHOLD_MS, STATUS_DELAY_THRESHOLD_MS,
} from 'ee/geo_nodes_beta/constants'; } from 'ee/geo_nodes_beta/constants';
import { MOCK_PRIMARY_VERSION, MOCK_REPLICABLE_TYPES } from 'ee_jest/geo_nodes_beta/mock_data'; 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'; import { differenceInMilliseconds } from '~/lib/utils/datetime_utility';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -34,25 +35,27 @@ describe('GeoNodeLastUpdated', () => { ...@@ -34,25 +35,27 @@ describe('GeoNodeLastUpdated', () => {
}, },
}); });
wrapper = shallowMount(GeoNodeLastUpdated, { wrapper = extendedWrapper(
localVue, shallowMount(GeoNodeLastUpdated, {
store, localVue,
propsData: { store,
...defaultProps, propsData: {
...props, ...defaultProps,
}, ...props,
}); },
}),
);
}; };
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
const findMainText = () => wrapper.find('[data-testid="last-updated-main-text"]'); const findMainText = () => wrapper.findByTestId('last-updated-main-text');
const findGlIcon = () => wrapper.find(GlIcon); const findGlIcon = () => wrapper.findComponent(GlIcon);
const findGlPopover = () => wrapper.find(GlPopover); const findGlPopover = () => wrapper.findComponent(GlPopover);
const findPopoverText = () => findGlPopover().find('p'); const findPopoverText = () => findGlPopover().find('p');
const findPopoverLink = () => findGlPopover().find(GlLink); const findPopoverLink = () => findGlPopover().findComponent(GlLink);
describe('template', () => { describe('template', () => {
describe('always', () => { describe('always', () => {
...@@ -75,12 +78,12 @@ describe('GeoNodeLastUpdated', () => { ...@@ -75,12 +78,12 @@ describe('GeoNodeLastUpdated', () => {
}); });
it('renders the popover text correctly', () => { it('renders the popover text correctly', () => {
expect(findPopoverText().exists()).toBeTruthy(); expect(findPopoverText().exists()).toBe(true);
expect(findPopoverText().text()).toBe("Node's status was updated 10 minutes ago."); expect(findPopoverText().text()).toBe("Node's status was updated 10 minutes ago.");
}); });
it('renders the popover link always', () => { it('renders the popover link always', () => {
expect(findPopoverLink().exists()).toBeTruthy(); expect(findPopoverLink().exists()).toBe(true);
}); });
}); });
......
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