Commit 665d5bea authored by Illya Klymov's avatar Illya Klymov

Replace usage of find/findAll in related_items_tree

* migrate to proper use of findComponent/findAllComponents
parent 68755b38
...@@ -114,7 +114,7 @@ describe('RelatedItemsTree', () => { ...@@ -114,7 +114,7 @@ describe('RelatedItemsTree', () => {
describe('onFormSubmit', () => { describe('onFormSubmit', () => {
it('emits `createEpicFormSubmit` event on component with input value as param', () => { it('emits `createEpicFormSubmit` event on component with input value as param', () => {
const value = 'foo'; const value = 'foo';
wrapper.find(GlFormInput).vm.$emit('input', value); wrapper.findComponent(GlFormInput).vm.$emit('input', value);
wrapper.vm.onFormSubmit(); wrapper.vm.onFormSubmit();
expect(wrapper.emitted().createEpicFormSubmit).toBeTruthy(); expect(wrapper.emitted().createEpicFormSubmit).toBeTruthy();
...@@ -153,20 +153,20 @@ describe('RelatedItemsTree', () => { ...@@ -153,20 +153,20 @@ describe('RelatedItemsTree', () => {
describe('template', () => { describe('template', () => {
it('renders input element within form', () => { it('renders input element within form', () => {
const inputEl = wrapper.find(GlFormInput); const inputEl = wrapper.findComponent(GlFormInput);
expect(inputEl.attributes('placeholder')).toBe('New epic title'); expect(inputEl.attributes('placeholder')).toBe('New epic title');
}); });
it('renders form action buttons', () => { it('renders form action buttons', () => {
const actionButtons = wrapper.findAll(GlButton); const actionButtons = wrapper.findAllComponents(GlButton);
expect(actionButtons.at(0).text()).toBe('Create epic'); expect(actionButtons.at(0).text()).toBe('Create epic');
expect(actionButtons.at(1).text()).toBe('Cancel'); expect(actionButtons.at(1).text()).toBe('Cancel');
}); });
it('renders parent group item as the first dropdown item', () => { it('renders parent group item as the first dropdown item', () => {
const items = wrapper.findAll(GlDropdownItem); const items = wrapper.findAllComponents(GlDropdownItem);
expect(items.at(0).text()).toContain(mockParentItem.groupName); expect(items.at(0).text()).toContain(mockParentItem.groupName);
}); });
......
...@@ -205,7 +205,9 @@ describe('CreateIssueForm', () => { ...@@ -205,7 +205,9 @@ describe('CreateIssueForm', () => {
const content = projectsDropdownButton.find('[data-testid="recent-items-content"]'); const content = projectsDropdownButton.find('[data-testid="recent-items-content"]');
expect(content.exists()).toBe(true); expect(content.exists()).toBe(true);
expect(content.findAll(GlDropdownItem)).toHaveLength(mockFrequentlyUsedProjects.length); expect(content.findAllComponents(GlDropdownItem)).toHaveLength(
mockFrequentlyUsedProjects.length,
);
removeLocalstorageFrequentItems(); removeLocalstorageFrequentItems();
}); });
...@@ -220,7 +222,9 @@ describe('CreateIssueForm', () => { ...@@ -220,7 +222,9 @@ describe('CreateIssueForm', () => {
const projectsDropdownButton = wrapper.findComponent(GlDropdown); const projectsDropdownButton = wrapper.findComponent(GlDropdown);
expect( expect(
projectsDropdownButton.find('[data-testid="recent-items-content"]').findAll(GlDropdownItem), projectsDropdownButton
.find('[data-testid="recent-items-content"]')
.findAllComponents(GlDropdownItem),
).toHaveLength(mockMixedFrequentlyUsedProjects.length - 1); ).toHaveLength(mockMixedFrequentlyUsedProjects.length - 1);
removeLocalstorageFrequentItems(); removeLocalstorageFrequentItems();
......
...@@ -49,7 +49,7 @@ describe('EpicHealthStatus', () => { ...@@ -49,7 +49,7 @@ describe('EpicHealthStatus', () => {
}); });
it('renders tooltip', () => { it('renders tooltip', () => {
const tooltip = wrapper.find(GlTooltip); const tooltip = wrapper.findComponent(GlTooltip);
expect(tooltip.exists()).toBe(true); expect(tooltip.exists()).toBe(true);
}); });
......
...@@ -41,8 +41,8 @@ describe('RelatedItemsTreeApp', () => { ...@@ -41,8 +41,8 @@ describe('RelatedItemsTreeApp', () => {
let axiosMock; let axiosMock;
let wrapper; let wrapper;
const findCreateIssueForm = () => wrapper.find(CreateIssueForm); const findCreateIssueForm = () => wrapper.findComponent(CreateIssueForm);
const findAddItemForm = () => wrapper.find(AddIssuableForm); const findAddItemForm = () => wrapper.findComponent(AddIssuableForm);
beforeEach(() => { beforeEach(() => {
axiosMock = new AxiosMockAdapter(axios); axiosMock = new AxiosMockAdapter(axios);
...@@ -209,7 +209,7 @@ describe('RelatedItemsTreeApp', () => { ...@@ -209,7 +209,7 @@ describe('RelatedItemsTreeApp', () => {
}); });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlLoadingIcon).isVisible()).toBe(true); expect(wrapper.findComponent(GlLoadingIcon).isVisible()).toBe(true);
}); });
}); });
...@@ -228,7 +228,7 @@ describe('RelatedItemsTreeApp', () => { ...@@ -228,7 +228,7 @@ describe('RelatedItemsTreeApp', () => {
it('renders tree header component', () => it('renders tree header component', () =>
wrapper.vm.$nextTick().then(() => { wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(RelatedItemsTreeHeader).isVisible()).toBe(true); expect(wrapper.findComponent(RelatedItemsTreeHeader).isVisible()).toBe(true);
})); }));
it('renders item add/create form container element', () => { it('renders item add/create form container element', () => {
......
...@@ -47,7 +47,7 @@ describe('RelatedItemsTree', () => { ...@@ -47,7 +47,7 @@ describe('RelatedItemsTree', () => {
describe('RelatedItemsTreeHeader', () => { describe('RelatedItemsTreeHeader', () => {
let wrapper; let wrapper;
const findEpicsIssuesSplitButton = () => wrapper.find(EpicActionsSplitButton); const findEpicsIssuesSplitButton = () => wrapper.findComponent(EpicActionsSplitButton);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -59,12 +59,12 @@ describe('RelatedItemsTree', () => { ...@@ -59,12 +59,12 @@ describe('RelatedItemsTree', () => {
}); });
it('returns string containing epic count based on available direct children within state', () => { it('returns string containing epic count based on available direct children within state', () => {
expect(wrapper.find(GlTooltip).text()).toContain(`Epics • expect(wrapper.findComponent(GlTooltip).text()).toContain(`Epics •
1 open, 1 closed`); 1 open, 1 closed`);
}); });
it('returns string containing issue count based on available direct children within state', () => { it('returns string containing issue count based on available direct children within state', () => {
expect(wrapper.find(GlTooltip).text()).toContain(`Issues • expect(wrapper.findComponent(GlTooltip).text()).toContain(`Issues •
2 open, 1 closed`); 2 open, 1 closed`);
}); });
}); });
...@@ -85,7 +85,7 @@ describe('RelatedItemsTree', () => { ...@@ -85,7 +85,7 @@ describe('RelatedItemsTree', () => {
}); });
it('toggle labels component is visible', () => { it('toggle labels component is visible', () => {
expect(wrapper.find(ToggleLabels).isVisible()).toBe(true); expect(wrapper.findComponent(ToggleLabels).isVisible()).toBe(true);
}); });
}); });
...@@ -211,7 +211,7 @@ describe('RelatedItemsTree', () => { ...@@ -211,7 +211,7 @@ describe('RelatedItemsTree', () => {
it('renders epics count and gl-icon', () => { it('renders epics count and gl-icon', () => {
const epicsEl = wrapper.findAll('.issue-count-badge > span').at(0); const epicsEl = wrapper.findAll('.issue-count-badge > span').at(0);
const epicIcon = epicsEl.find(GlIcon); const epicIcon = epicsEl.findComponent(GlIcon);
expect(epicsEl.text().trim()).toContain('2'); expect(epicsEl.text().trim()).toContain('2');
expect(epicIcon.isVisible()).toBe(true); expect(epicIcon.isVisible()).toBe(true);
...@@ -233,7 +233,7 @@ describe('RelatedItemsTree', () => { ...@@ -233,7 +233,7 @@ describe('RelatedItemsTree', () => {
}); });
it('does not render health status', () => { it('does not render health status', () => {
expect(wrapper.find(EpicHealthStatus).exists()).toBe(false); expect(wrapper.findComponent(EpicHealthStatus).exists()).toBe(false);
}); });
}); });
...@@ -248,13 +248,13 @@ describe('RelatedItemsTree', () => { ...@@ -248,13 +248,13 @@ describe('RelatedItemsTree', () => {
}); });
it('does not render health status', () => { it('does not render health status', () => {
expect(wrapper.find(EpicHealthStatus).exists()).toBe(true); expect(wrapper.findComponent(EpicHealthStatus).exists()).toBe(true);
}); });
}); });
it('renders issues count and gl-icon', () => { it('renders issues count and gl-icon', () => {
const issuesEl = wrapper.findAll('.issue-count-badge > span').at(1); const issuesEl = wrapper.findAll('.issue-count-badge > span').at(1);
const issueIcon = issuesEl.find(GlIcon); const issueIcon = issuesEl.findComponent(GlIcon);
expect(issuesEl.text().trim()).toContain('3'); expect(issuesEl.text().trim()).toContain('3');
expect(issueIcon.isVisible()).toBe(true); expect(issueIcon.isVisible()).toBe(true);
...@@ -263,7 +263,7 @@ describe('RelatedItemsTree', () => { ...@@ -263,7 +263,7 @@ describe('RelatedItemsTree', () => {
it('renders totalWeight count and gl-icon', () => { it('renders totalWeight count and gl-icon', () => {
const weightEl = wrapper.findAll('.issue-count-badge > span').at(2); const weightEl = wrapper.findAll('.issue-count-badge > span').at(2);
const weightIcon = weightEl.find(GlIcon); const weightIcon = weightEl.findComponent(GlIcon);
expect(weightEl.text().trim()).toContain('15'); expect(weightEl.text().trim()).toContain('15');
expect(weightIcon.isVisible()).toBe(true); expect(weightIcon.isVisible()).toBe(true);
......
...@@ -154,15 +154,15 @@ describe('RelatedItemsTree', () => { ...@@ -154,15 +154,15 @@ describe('RelatedItemsTree', () => {
describe('template', () => { describe('template', () => {
it('renders gl-tooltip as container element', () => { it('renders gl-tooltip as container element', () => {
expect(wrapper.find(GlTooltip).isVisible()).toBe(true); expect(wrapper.findComponent(GlTooltip).isVisible()).toBe(true);
}); });
it('renders path in bold', () => { it('renders path in bold', () => {
expect(wrapper.find({ ref: 'statePath' }).text().trim()).toBe('/foo/bar#1'); expect(wrapper.findComponent({ ref: 'statePath' }).text().trim()).toBe('/foo/bar#1');
}); });
it('renders stateText in bold', () => { it('renders stateText in bold', () => {
expect(wrapper.find({ ref: 'stateText' }).text().trim()).toBe('Closed'); expect(wrapper.findComponent({ ref: 'stateText' }).text().trim()).toBe('Closed');
}); });
it('renders stateTimeInWords', () => { it('renders stateTimeInWords', () => {
...@@ -170,7 +170,9 @@ describe('RelatedItemsTree', () => { ...@@ -170,7 +170,9 @@ describe('RelatedItemsTree', () => {
}); });
it('renders stateTimestamp in muted', () => { it('renders stateTimestamp in muted', () => {
expect(wrapper.find({ ref: 'stateTimestamp' }).text().trim()).toContain(mockClosedAtYear); expect(wrapper.findComponent({ ref: 'stateTimestamp' }).text().trim()).toContain(
mockClosedAtYear,
);
}); });
}); });
}); });
......
...@@ -82,11 +82,11 @@ describe('RelatedItemsTree', () => { ...@@ -82,11 +82,11 @@ describe('RelatedItemsTree', () => {
describe('TreeItemBody', () => { describe('TreeItemBody', () => {
let wrapper; let wrapper;
const findChildLabels = () => wrapper.findAll(GlLabel); const findChildLabels = () => wrapper.findAllComponents(GlLabel);
const findCountBadge = () => wrapper.find({ ref: 'countBadge' }); const findCountBadge = () => wrapper.findComponent({ ref: 'countBadge' });
const findEpicHealthStatus = () => wrapper.find('[data-testid="epic-health-status"]'); const findEpicHealthStatus = () => wrapper.find('[data-testid="epic-health-status"]');
const findIssueHealthStatus = () => wrapper.find('[data-testid="issue-health-status"]'); const findIssueHealthStatus = () => wrapper.find('[data-testid="issue-health-status"]');
const findIssueIcon = () => wrapper.find({ ref: 'stateIconMd' }); const findIssueIcon = () => wrapper.findComponent({ ref: 'stateIconMd' });
const findLink = () => wrapper.findComponent(GlLink); const findLink = () => wrapper.findComponent(GlLink);
const enableHealthStatus = () => { const enableHealthStatus = () => {
wrapper.vm.$store.commit('SET_INITIAL_CONFIG', { wrapper.vm.$store.commit('SET_INITIAL_CONFIG', {
...@@ -278,7 +278,7 @@ describe('RelatedItemsTree', () => { ...@@ -278,7 +278,7 @@ describe('RelatedItemsTree', () => {
describe('itemHierarchy', () => { describe('itemHierarchy', () => {
it('returns string containing item id and item path', () => { it('returns string containing item id and item path', () => {
const stateTooltip = wrapper.findAll(StateTooltip).at(0); const stateTooltip = wrapper.findAllComponents(StateTooltip).at(0);
expect(stateTooltip.props('path')).toBe('gitlab-org/gitlab-shell#8'); expect(stateTooltip.props('path')).toBe('gitlab-org/gitlab-shell#8');
}); });
}); });
...@@ -381,19 +381,19 @@ describe('RelatedItemsTree', () => { ...@@ -381,19 +381,19 @@ describe('RelatedItemsTree', () => {
}); });
it('renders item state icon for large screens', () => { it('renders item state icon for large screens', () => {
const statusIcon = wrapper.findAll(GlIcon).at(0); const statusIcon = wrapper.findAllComponents(GlIcon).at(0);
expect(statusIcon.props('name')).toBe('issues'); expect(statusIcon.props('name')).toBe('issues');
}); });
it('renders item state tooltip for large screens', () => { it('renders item state tooltip for large screens', () => {
const stateTooltip = wrapper.findAll(StateTooltip).at(0); const stateTooltip = wrapper.findAllComponents(StateTooltip).at(0);
expect(stateTooltip.props('state')).toBe(mockItem.state); expect(stateTooltip.props('state')).toBe(mockItem.state);
}); });
it('renders item path in tooltip for large screens', () => { it('renders item path in tooltip for large screens', () => {
const stateTooltip = wrapper.findAll(StateTooltip).at(0); const stateTooltip = wrapper.findAllComponents(StateTooltip).at(0);
const { itemPath, itemId } = wrapper.vm; const { itemPath, itemId } = wrapper.vm;
const path = itemPath + mockItem.pathIdSeparator + itemId; const path = itemPath + mockItem.pathIdSeparator + itemId;
...@@ -403,7 +403,7 @@ describe('RelatedItemsTree', () => { ...@@ -403,7 +403,7 @@ describe('RelatedItemsTree', () => {
}); });
it('renders confidential icon when `item.confidential` is true', () => { it('renders confidential icon when `item.confidential` is true', () => {
const confidentialIcon = wrapper.findAll(GlIcon).at(1); const confidentialIcon = wrapper.findAllComponents(GlIcon).at(1);
expect(confidentialIcon.isVisible()).toBe(true); expect(confidentialIcon.isVisible()).toBe(true);
expect(confidentialIcon.props('name')).toBe('eye-slash'); expect(confidentialIcon.props('name')).toBe('eye-slash');
...@@ -415,7 +415,7 @@ describe('RelatedItemsTree', () => { ...@@ -415,7 +415,7 @@ describe('RelatedItemsTree', () => {
}); });
it('renders item state tooltip for medium and small screens', () => { it('renders item state tooltip for medium and small screens', () => {
const stateTooltip = wrapper.findAll(StateTooltip).at(0); const stateTooltip = wrapper.findAllComponents(StateTooltip).at(0);
expect(stateTooltip.props('state')).toBe(mockItem.state); expect(stateTooltip.props('state')).toBe(mockItem.state);
}); });
......
...@@ -120,7 +120,7 @@ describe('RelatedItemsTree', () => { ...@@ -120,7 +120,7 @@ describe('RelatedItemsTree', () => {
describe('template', () => { describe('template', () => {
it('renders modal component', () => { it('renders modal component', () => {
const modal = wrapper.find(GlModal); const modal = wrapper.findComponent(GlModal);
expect(modal.isVisible()).toBe(true); expect(modal.isVisible()).toBe(true);
expect(modal.attributes('modalid')).toBe('item-remove-confirmation'); expect(modal.attributes('modalid')).toBe('item-remove-confirmation');
......
...@@ -132,21 +132,21 @@ describe('RelatedItemsTree', () => { ...@@ -132,21 +132,21 @@ describe('RelatedItemsTree', () => {
}); });
it('renders expand/collapse button', () => { it('renders expand/collapse button', () => {
const chevronButton = wrapper.find(GlButton); const chevronButton = wrapper.findComponent(GlButton);
expect(chevronButton.isVisible()).toBe(true); expect(chevronButton.isVisible()).toBe(true);
expect(chevronButton.attributes('title')).toBe('Collapse'); expect(chevronButton.attributes('title')).toBe('Collapse');
}); });
it('has the proper class on the expand/collapse button to avoid dragging', () => { it('has the proper class on the expand/collapse button to avoid dragging', () => {
const chevronButton = wrapper.find(GlButton); const chevronButton = wrapper.findComponent(GlButton);
expect(chevronButton.attributes('class')).toContain(treeItemChevronBtnClassName); expect(chevronButton.attributes('class')).toContain(treeItemChevronBtnClassName);
}); });
it('renders expand/collapse icon', () => { it('renders expand/collapse icon', () => {
const expandedIcon = wrapperExpanded.find(GlIcon); const expandedIcon = wrapperExpanded.findComponent(GlIcon);
const collapsedIcon = wrapperCollapsed.find(GlIcon); const collapsedIcon = wrapperCollapsed.findComponent(GlIcon);
expect(expandedIcon.isVisible()).toBe(true); expect(expandedIcon.isVisible()).toBe(true);
expect(expandedIcon.props('name')).toBe('chevron-down'); expect(expandedIcon.props('name')).toBe('chevron-down');
...@@ -161,14 +161,14 @@ describe('RelatedItemsTree', () => { ...@@ -161,14 +161,14 @@ describe('RelatedItemsTree', () => {
}); });
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
const loadingIcon = wrapper.find(GlLoadingIcon); const loadingIcon = wrapper.findComponent(GlLoadingIcon);
expect(loadingIcon.isVisible()).toBe(true); expect(loadingIcon.isVisible()).toBe(true);
}); });
}); });
it('renders tree item body component', () => { it('renders tree item body component', () => {
const itemBody = wrapper.find(TreeItemBody); const itemBody = wrapper.findComponent(TreeItemBody);
expect(itemBody.isVisible()).toBe(true); expect(itemBody.isVisible()).toBe(true);
}); });
......
...@@ -452,13 +452,13 @@ describe('RelatedItemsTree', () => { ...@@ -452,13 +452,13 @@ describe('RelatedItemsTree', () => {
}); });
it('renders `Show more` link', () => { it('renders `Show more` link', () => {
expect(wrapper.find(GlButton).text()).toBe('Show more'); expect(wrapper.findComponent(GlButton).text()).toBe('Show more');
}); });
it('calls `handleShowMoreClick` when `Show more` link is clicked', () => { it('calls `handleShowMoreClick` when `Show more` link is clicked', () => {
jest.spyOn(wrapper.vm, 'handleShowMoreClick').mockImplementation(() => {}); jest.spyOn(wrapper.vm, 'handleShowMoreClick').mockImplementation(() => {});
wrapper.find(GlButton).vm.$emit('click'); wrapper.findComponent(GlButton).vm.$emit('click');
expect(wrapper.vm.handleShowMoreClick).toHaveBeenCalled(); expect(wrapper.vm.handleShowMoreClick).toHaveBeenCalled();
}); });
......
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