Commit 323f8776 authored by Zack Cuddy's avatar Zack Cuddy

Geo Node Status 2.0 - Tests Cleanup

This change does a few spec cleanup
tasks including:

1. Removing wrapper = null
2. Using findComponent
3. Using findByTestId
4. Using .toBe
5. Using better conditional naming
parent 3ca18ac9
......@@ -51,15 +51,14 @@ describe('GeoNodesBetaApp', () => {
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const findGeoNodesBetaContainer = () => wrapper.find('section');
const findGeoLearnMoreLink = () => wrapper.find(GlLink);
const findGeoAddSiteButton = () => wrapper.find(GlButton);
const findGlLoadingIcon = () => wrapper.find(GlLoadingIcon);
const findGeoEmptyState = () => wrapper.find(GeoNodesEmptyState);
const findGeoNodes = () => wrapper.findAll(GeoNodes);
const findGeoLearnMoreLink = () => wrapper.findComponent(GlLink);
const findGeoAddSiteButton = () => wrapper.findComponent(GlButton);
const findGlLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findGeoEmptyState = () => wrapper.findComponent(GeoNodesEmptyState);
const findGeoNodes = () => wrapper.findAllComponents(GeoNodes);
describe('template', () => {
describe('always', () => {
......@@ -91,19 +90,19 @@ describe('GeoNodesBetaApp', () => {
});
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);
});
it(`does ${!showNodes ? 'not ' : ''}render GeoNodes`, () => {
it(`does ${showNodes ? '' : 'not '}render GeoNodes`, () => {
expect(findGeoNodes().exists()).toBe(showNodes);
});
it(`does ${!showEmptyState ? 'not ' : ''}render EmptyState`, () => {
it(`does ${showEmptyState ? '' : 'not '}render EmptyState`, () => {
expect(findGeoEmptyState().exists()).toBe(showEmptyState);
});
it(`does ${!showAddButton ? 'not ' : ''}render AddSiteButton`, () => {
it(`does ${showAddButton ? '' : 'not '}render AddSiteButton`, () => {
expect(findGeoAddSiteButton().exists()).toBe(showAddButton);
});
});
......
......@@ -37,10 +37,9 @@ describe('GeoNodesEmptyState', () => {
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const findGeoEmptyState = () => wrapper.find(GlEmptyState);
const findGeoEmptyState = () => wrapper.findComponent(GlEmptyState);
describe('template', () => {
beforeEach(() => {
......
......@@ -22,7 +22,6 @@ describe('GeoNodes', () => {
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const findGeoNodesContainer = () => wrapper.find('div');
......
......@@ -7,6 +7,7 @@ import {
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue();
localVue.use(Vuex);
......@@ -28,23 +29,24 @@ describe('GeoNodeActionsDesktop', () => {
},
});
wrapper = shallowMount(GeoNodeActionsDesktop, {
localVue,
store,
propsData: {
...defaultProps,
...props,
},
});
wrapper = extendedWrapper(
shallowMount(GeoNodeActionsDesktop, {
localVue,
store,
propsData: {
...defaultProps,
...props,
},
}),
);
};
afterEach(() => {
wrapper.destroy();
});
const findGeoDesktopActionsButtons = () => wrapper.findAll(GlButton);
const findGeoDesktopActionsRemoveButton = () =>
wrapper.find('[data-testid="geo-desktop-remove-action"]');
const findGeoDesktopActionsButtons = () => wrapper.findAllComponents(GlButton);
const findGeoDesktopActionsRemoveButton = () => wrapper.findByTestId('geo-desktop-remove-action');
describe('template', () => {
describe('always', () => {
......
......@@ -7,6 +7,7 @@ import {
MOCK_PRIMARY_VERSION,
MOCK_REPLICABLE_TYPES,
} from 'ee_jest/geo_nodes_beta/mock_data';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue();
localVue.use(Vuex);
......@@ -28,24 +29,26 @@ describe('GeoNodeActionsMobile', () => {
},
});
wrapper = shallowMount(GeoNodeActionsMobile, {
localVue,
store,
propsData: {
...defaultProps,
...props,
},
});
wrapper = extendedWrapper(
shallowMount(GeoNodeActionsMobile, {
localVue,
store,
propsData: {
...defaultProps,
...props,
},
}),
);
};
afterEach(() => {
wrapper.destroy();
});
const findGeoMobileActionsDropdown = () => wrapper.find(GlDropdown);
const findGeoMobileActionsDropdownItems = () => wrapper.findAll(GlDropdownItem);
const findGeoMobileActionsDropdown = () => wrapper.findComponent(GlDropdown);
const findGeoMobileActionsDropdownItems = () => wrapper.findAllComponents(GlDropdownItem);
const findGeoMobileActionsRemoveDropdownItem = () =>
wrapper.find('[data-testid="geo-mobile-remove-action"]');
wrapper.findByTestId('geo-mobile-remove-action');
describe('template', () => {
describe('always', () => {
......
......@@ -43,8 +43,8 @@ describe('GeoNodeActions', () => {
wrapper.destroy();
});
const findGeoMobileActions = () => wrapper.find(GeoNodeActionsMobile);
const findGeoDesktopActions = () => wrapper.find(GeoNodeActionsDesktop);
const findGeoMobileActions = () => wrapper.findComponent(GeoNodeActionsMobile);
const findGeoDesktopActions = () => wrapper.findComponent(GeoNodeActionsDesktop);
describe('template', () => {
beforeEach(() => {
......
......@@ -46,11 +46,11 @@ describe('GeoNodeHeader', () => {
wrapper.destroy();
});
const findHeaderCollapseButton = () => wrapper.find(GlButton);
const findCurrentNodeBadge = () => wrapper.find(GlBadge);
const findGeoNodeHealthStatus = () => wrapper.find(GeoNodeHealthStatus);
const findGeoNodeLastUpdated = () => wrapper.find(GeoNodeLastUpdated);
const findGeoNodeActions = () => wrapper.find(GeoNodeActions);
const findHeaderCollapseButton = () => wrapper.findComponent(GlButton);
const findCurrentNodeBadge = () => wrapper.findComponent(GlBadge);
const findGeoNodeHealthStatus = () => wrapper.findComponent(GeoNodeHealthStatus);
const findGeoNodeLastUpdated = () => wrapper.findComponent(GeoNodeLastUpdated);
const findGeoNodeActions = () => wrapper.findComponent(GeoNodeActions);
describe('template', () => {
describe('always', () => {
......
......@@ -39,8 +39,8 @@ describe('GeoNodeHealthStatus', () => {
wrapper.destroy();
});
const findGeoStatusBadge = () => wrapper.find(GlBadge);
const findGeoStatusIcon = () => wrapper.find(GlIcon);
const findGeoStatusBadge = () => wrapper.findComponent(GlBadge);
const findGeoStatusIcon = () => wrapper.findComponent(GlIcon);
const findGeoStatusText = () => wrapper.find('span');
describe.each`
......
......@@ -8,6 +8,7 @@ import {
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();
......@@ -34,25 +35,27 @@ describe('GeoNodeLastUpdated', () => {
},
});
wrapper = shallowMount(GeoNodeLastUpdated, {
localVue,
store,
propsData: {
...defaultProps,
...props,
},
});
wrapper = extendedWrapper(
shallowMount(GeoNodeLastUpdated, {
localVue,
store,
propsData: {
...defaultProps,
...props,
},
}),
);
};
afterEach(() => {
wrapper.destroy();
});
const findMainText = () => wrapper.find('[data-testid="last-updated-main-text"]');
const findGlIcon = () => wrapper.find(GlIcon);
const findGlPopover = () => wrapper.find(GlPopover);
const findMainText = () => wrapper.findByTestId('last-updated-main-text');
const findGlIcon = () => wrapper.findComponent(GlIcon);
const findGlPopover = () => wrapper.findComponent(GlPopover);
const findPopoverText = () => findGlPopover().find('p');
const findPopoverLink = () => findGlPopover().find(GlLink);
const findPopoverLink = () => findGlPopover().findComponent(GlLink);
describe('template', () => {
describe('always', () => {
......@@ -75,12 +78,12 @@ describe('GeoNodeLastUpdated', () => {
});
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.");
});
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