Commit b64af041 authored by Illya Klymov's avatar Illya Klymov

Replace deprecated usage of find/findAll in ee/spec/frontend/approvals

* migrate to proper use of findComponent/findAllComponents
parent 948a862c
...@@ -30,7 +30,7 @@ describe('EE Approvals App', () => { ...@@ -30,7 +30,7 @@ describe('EE Approvals App', () => {
}; };
const findAddButton = () => wrapper.find('[data-testid="add-approval-rule"]'); const findAddButton = () => wrapper.find('[data-testid="add-approval-rule"]');
const findResetButton = () => wrapper.find('[data-testid="reset-to-defaults"]'); const findResetButton = () => wrapper.find('[data-testid="reset-to-defaults"]');
const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findRules = () => wrapper.find(`.${TEST_RULES_CLASS}`); const findRules = () => wrapper.find(`.${TEST_RULES_CLASS}`);
beforeEach(() => { beforeEach(() => {
...@@ -104,7 +104,7 @@ describe('EE Approvals App', () => { ...@@ -104,7 +104,7 @@ describe('EE Approvals App', () => {
it('renders create modal', () => { it('renders create modal', () => {
factory(); factory();
const modal = wrapper.find(ModalRuleCreate); const modal = wrapper.findComponent(ModalRuleCreate);
expect(modal.exists()).toBe(true); expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(`${APP_PREFIX}-approvals-create-modal`); expect(modal.props('modalId')).toBe(`${APP_PREFIX}-approvals-create-modal`);
...@@ -113,7 +113,7 @@ describe('EE Approvals App', () => { ...@@ -113,7 +113,7 @@ describe('EE Approvals App', () => {
it('renders delete modal', () => { it('renders delete modal', () => {
factory(); factory();
const modal = wrapper.find(ModalRuleRemove); const modal = wrapper.findComponent(ModalRuleRemove);
expect(modal.exists()).toBe(true); expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(`${APP_PREFIX}-approvals-remove-modal`); expect(modal.props('modalId')).toBe(`${APP_PREFIX}-approvals-remove-modal`);
......
...@@ -25,24 +25,26 @@ describe('Approval Check Popover', () => { ...@@ -25,24 +25,26 @@ describe('Approval Check Popover', () => {
}); });
it('should render the documentation link', () => { it('should render the documentation link', () => {
expect(wrapper.find(GlPopover).find(GlLink).attributes('href')).toBe(documentationLink); expect(wrapper.findComponent(GlPopover).findComponent(GlLink).attributes('href')).toBe(
documentationLink,
);
}); });
}); });
describe('without a documentation link', () => { describe('without a documentation link', () => {
it('should not render the documentation link', () => { it('should not render the documentation link', () => {
expect(wrapper.find(GlPopover).find(GlLink).exists()).toBeFalsy(); expect(wrapper.findComponent(GlPopover).findComponent(GlLink).exists()).toBeFalsy();
}); });
}); });
it('renders an Icon with an id that matches the Popover target', () => { it('renders an Icon with an id that matches the Popover target', () => {
expect(wrapper.find(GlPopover).props().target).toBe( expect(wrapper.findComponent(GlPopover).props().target).toBe(
wrapper.find(GlIcon).element.getAttribute('id'), wrapper.findComponent(GlIcon).element.getAttribute('id'),
); );
}); });
it('should render gl-popover with correct props', () => { it('should render gl-popover with correct props', () => {
expect(wrapper.find(GlPopover).props()).toMatchObject({ expect(wrapper.findComponent(GlPopover).props()).toMatchObject({
title, title,
target: `reportInfo-${title}`, target: `reportInfo-${title}`,
placement: 'top', placement: 'top',
......
...@@ -37,7 +37,7 @@ describe('ApproversList', () => { ...@@ -37,7 +37,7 @@ describe('ApproversList', () => {
it('renders empty', () => { it('renders empty', () => {
factory(); factory();
expect(wrapper.find(ApproversListEmpty).exists()).toBe(true); expect(wrapper.findComponent(ApproversListEmpty).exists()).toBe(true);
expect(wrapper.find('ul').exists()).toBe(false); expect(wrapper.find('ul').exists()).toBe(false);
}); });
}); });
...@@ -51,7 +51,7 @@ describe('ApproversList', () => { ...@@ -51,7 +51,7 @@ describe('ApproversList', () => {
factory(); factory();
const items = wrapper const items = wrapper
.findAll(ApproversListItem) .findAllComponents(ApproversListItem)
.wrappers.map((item) => item.props('approver')); .wrappers.map((item) => item.props('approver'));
expect(items).toEqual(TEST_APPROVERS); expect(items).toEqual(TEST_APPROVERS);
...@@ -61,7 +61,7 @@ describe('ApproversList', () => { ...@@ -61,7 +61,7 @@ describe('ApproversList', () => {
it(`when remove (${idx}), emits new input`, () => { it(`when remove (${idx}), emits new input`, () => {
factory(); factory();
const item = wrapper.findAll(ApproversListItem).at(idx); const item = wrapper.findAllComponents(ApproversListItem).at(idx);
item.vm.$emit('remove', approver); item.vm.$emit('remove', approver);
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
......
...@@ -29,10 +29,10 @@ describe('Empty Rule Name', () => { ...@@ -29,10 +29,10 @@ describe('Empty Rule Name', () => {
it('renders a "more information" link ', () => { it('renders a "more information" link ', () => {
createComponent(); createComponent();
expect(wrapper.find(GlLink).attributes('href')).toBe( expect(wrapper.findComponent(GlLink).attributes('href')).toBe(
wrapper.props('eligibleApproversDocsPath'), wrapper.props('eligibleApproversDocsPath'),
); );
expect(wrapper.find(GlLink).exists()).toBe(true); expect(wrapper.findComponent(GlLink).exists()).toBe(true);
expect(wrapper.find(GlLink).text()).toBe('More information'); expect(wrapper.findComponent(GlLink).text()).toBe('More information');
}); });
}); });
...@@ -56,10 +56,10 @@ describe('EE Approvals Group Settings App', () => { ...@@ -56,10 +56,10 @@ describe('EE Approvals Group Settings App', () => {
store = null; store = null;
}); });
const findSettingsBlock = () => wrapper.find(SettingsBlock); const findSettingsBlock = () => wrapper.findComponent(SettingsBlock);
const findDescriptionLink = () => wrapper.findByTestId('group-settings-description'); const findDescriptionLink = () => wrapper.findByTestId('group-settings-description');
const findLearnMoreLink = () => wrapper.findByTestId('group-settings-learn-more'); const findLearnMoreLink = () => wrapper.findByTestId('group-settings-learn-more');
const findApprovalSettings = () => wrapper.find(ApprovalSettings); const findApprovalSettings = () => wrapper.findComponent(ApprovalSettings);
it('renders a settings block', () => { it('renders a settings block', () => {
createWrapper(); createWrapper();
......
...@@ -57,7 +57,7 @@ describe('EE Approvals LicenseCompliance', () => { ...@@ -57,7 +57,7 @@ describe('EE Approvals LicenseCompliance', () => {
const findByHrefAttribute = (href) => wrapper.find(`[href="${href}"]`); const findByHrefAttribute = (href) => wrapper.find(`[href="${href}"]`);
const findOpenModalButton = () => wrapper.find('button'); const findOpenModalButton = () => wrapper.find('button');
const findLoadingIndicator = () => wrapper.find('[aria-label="loading"]'); const findLoadingIndicator = () => wrapper.find('[aria-label="loading"]');
const findInformationIcon = () => wrapper.find(GlIcon); const findInformationIcon = () => wrapper.findComponent(GlIcon);
const findLicenseCheckStatus = () => wrapper.find('[data-testid="licenseCheckStatus"]'); const findLicenseCheckStatus = () => wrapper.find('[data-testid="licenseCheckStatus"]');
describe('when created', () => { describe('when created', () => {
......
...@@ -73,8 +73,8 @@ describe('EE Approvals LicenseCompliance Modal', () => { ...@@ -73,8 +73,8 @@ describe('EE Approvals LicenseCompliance Modal', () => {
}); });
const findByHref = (href) => wrapper.find(`[href="${href}"`); const findByHref = (href) => wrapper.find(`[href="${href}"`);
const findModal = () => wrapper.find(GlModalVuex); const findModal = () => wrapper.findComponent(GlModalVuex);
const findRuleForm = () => wrapper.find(mocks.RuleForm); const findRuleForm = () => wrapper.findComponent(mocks.RuleForm);
const findInformationIcon = () => wrapper.find('[name="question"]'); const findInformationIcon = () => wrapper.find('[name="question"]');
const findOkButton = () => wrapper.find('[name="ok"]'); const findOkButton = () => wrapper.find('[name="ok"]');
const findCancelButton = () => wrapper.find('[name="cancel"]'); const findCancelButton = () => wrapper.find('[name="cancel"]');
......
...@@ -56,11 +56,13 @@ describe('EE Approvals MREditApp', () => { ...@@ -56,11 +56,13 @@ describe('EE Approvals MREditApp', () => {
}); });
it('does not render MR rules', () => { it('does not render MR rules', () => {
expect(wrapper.find(MRRules).findAll('.js-name')).toHaveLength(0); expect(wrapper.findComponent(MRRules).findAll('.js-name')).toHaveLength(0);
}); });
it('renders hidden inputs', () => { it('renders hidden inputs', () => {
expect(wrapper.find('.js-approval-rules').find(MRRulesHiddenInputs).exists()).toBe(true); expect(wrapper.find('.js-approval-rules').findComponent(MRRulesHiddenInputs).exists()).toBe(
true,
);
}); });
}); });
...@@ -71,14 +73,16 @@ describe('EE Approvals MREditApp', () => { ...@@ -71,14 +73,16 @@ describe('EE Approvals MREditApp', () => {
store.modules.approvals.state.rules = [{ id: 7, approvers: [] }]; store.modules.approvals.state.rules = [{ id: 7, approvers: [] }];
factory(); factory();
expect(wrapper.find(MRRules).findAll('.js-name')).toHaveLength(1); expect(wrapper.findComponent(MRRules).findAll('.js-name')).toHaveLength(1);
}); });
it('renders hidden inputs', () => { it('renders hidden inputs', () => {
store.modules.approvals.state.rules = [{ id: 7, approvers: [] }]; store.modules.approvals.state.rules = [{ id: 7, approvers: [] }];
factory(); factory();
expect(wrapper.find('.js-approval-rules').find(MRRulesHiddenInputs).exists()).toBe(true); expect(wrapper.find('.js-approval-rules').findComponent(MRRulesHiddenInputs).exists()).toBe(
true,
);
}); });
describe('summary text', () => { describe('summary text', () => {
......
...@@ -25,7 +25,7 @@ describe('Empty Rule', () => { ...@@ -25,7 +25,7 @@ describe('Empty Rule', () => {
allowMultiRule: true, allowMultiRule: true,
canEdit: true, canEdit: true,
}); });
expect(wrapper.find(GlButton).exists()).toBe(false); expect(wrapper.findComponent(GlButton).exists()).toBe(false);
}); });
}); });
...@@ -36,7 +36,7 @@ describe('Empty Rule', () => { ...@@ -36,7 +36,7 @@ describe('Empty Rule', () => {
canEdit: true, canEdit: true,
}); });
expect(wrapper.find(GlButton).exists()).toBe(true); expect(wrapper.findComponent(GlButton).exists()).toBe(true);
}); });
it('does not display "Add approval rule" button if not allowed to edit', () => { it('does not display "Add approval rule" button if not allowed to edit', () => {
...@@ -44,7 +44,7 @@ describe('Empty Rule', () => { ...@@ -44,7 +44,7 @@ describe('Empty Rule', () => {
allowMultiRule: true, allowMultiRule: true,
canEdit: false, canEdit: false,
}); });
expect(wrapper.find(GlButton).exists()).toBe(false); expect(wrapper.findComponent(GlButton).exists()).toBe(false);
}); });
}); });
}); });
...@@ -32,9 +32,9 @@ describe('EE Approvals MRRules', () => { ...@@ -32,9 +32,9 @@ describe('EE Approvals MRRules', () => {
const findHeaders = () => wrapper.findAll('thead th').wrappers.map((x) => x.text()); const findHeaders = () => wrapper.findAll('thead th').wrappers.map((x) => x.text());
const findRuleName = () => wrapper.find('.js-name'); const findRuleName = () => wrapper.find('.js-name');
const findRuleIndicator = () => wrapper.find({ ref: 'indicator' }); const findRuleIndicator = () => wrapper.findComponent({ ref: 'indicator' });
const findAvatarList = () => wrapper.find(UserAvatarList); const findAvatarList = () => wrapper.findComponent(UserAvatarList);
const findRuleControls = () => wrapper.find('td.js-controls').find(RuleControls); const findRuleControls = () => wrapper.find('td.js-controls').findComponent(RuleControls);
const callTargetBranchHandler = (MutationObserverSpy) => { const callTargetBranchHandler = (MutationObserverSpy) => {
const onTargetBranchMutationHandler = MutationObserverSpy.mock.calls[0][0]; const onTargetBranchMutationHandler = MutationObserverSpy.mock.calls[0][0];
return onTargetBranchMutationHandler(); return onTargetBranchMutationHandler();
......
...@@ -14,7 +14,7 @@ describe('ProjectApprovalSettings', () => { ...@@ -14,7 +14,7 @@ describe('ProjectApprovalSettings', () => {
let wrapper; let wrapper;
let store; let store;
const findApprovalSettings = () => wrapper.find(ApprovalSettings); const findApprovalSettings = () => wrapper.findComponent(ApprovalSettings);
const setupStore = (data = {}) => { const setupStore = (data = {}) => {
store = createStore({ store = createStore({
......
...@@ -23,8 +23,8 @@ const getRowData = (tr) => { ...@@ -23,8 +23,8 @@ const getRowData = (tr) => {
const approvalsRequired = findCell(tr, 'approvals-required'); const approvalsRequired = findCell(tr, 'approvals-required');
return { return {
name: name.text(), name: name.text(),
approvers: members.find(UserAvatarList).props('items'), approvers: members.findComponent(UserAvatarList).props('items'),
approvalsRequired: approvalsRequired.find(RuleInput).props('rule').approvalsRequired, approvalsRequired: approvalsRequired.findComponent(RuleInput).props('rule').approvalsRequired,
}; };
}; };
...@@ -71,7 +71,7 @@ describe('Approvals ProjectRules', () => { ...@@ -71,7 +71,7 @@ describe('Approvals ProjectRules', () => {
})), })),
); );
expect(wrapper.findComponent(Rules).findAll(RuleName).length).toBe(rows.length); expect(wrapper.findComponent(Rules).findAllComponents(RuleName).length).toBe(rows.length);
}); });
it('should always have any_approver rule', () => { it('should always have any_approver rule', () => {
...@@ -99,7 +99,7 @@ describe('Approvals ProjectRules', () => { ...@@ -99,7 +99,7 @@ describe('Approvals ProjectRules', () => {
it('does not render name', () => { it('does not render name', () => {
expect(findCell(row, 'name').exists()).toBe(false); expect(findCell(row, 'name').exists()).toBe(false);
expect(wrapper.findComponent(Rules).find(RuleName).exists()).toBe(false); expect(wrapper.findComponent(Rules).findComponent(RuleName).exists()).toBe(false);
}); });
it('should only display 1 rule', () => { it('should only display 1 rule', () => {
...@@ -119,7 +119,7 @@ describe('Approvals ProjectRules', () => { ...@@ -119,7 +119,7 @@ describe('Approvals ProjectRules', () => {
beforeEach(() => { beforeEach(() => {
factory(); factory();
rows = wrapper.find(Rules).findAll('tbody tr'); rows = wrapper.findComponent(Rules).findAll('tbody tr');
}); });
it('should not render the popover for a standard approval group', () => { it('should not render the popover for a standard approval group', () => {
...@@ -130,7 +130,7 @@ describe('Approvals ProjectRules', () => { ...@@ -130,7 +130,7 @@ describe('Approvals ProjectRules', () => {
}); });
it('should render the unconfigured-security-rules component', () => { it('should render the unconfigured-security-rules component', () => {
expect(wrapper.find(UnconfiguredSecurityRules).exists()).toBe(true); expect(wrapper.findComponent(UnconfiguredSecurityRules).exists()).toBe(true);
}); });
}); });
...@@ -145,7 +145,7 @@ describe('Approvals ProjectRules', () => { ...@@ -145,7 +145,7 @@ describe('Approvals ProjectRules', () => {
}); });
it(`should render the unconfigured-security-rules component`, () => { it(`should render the unconfigured-security-rules component`, () => {
expect(wrapper.find(UnconfiguredSecurityRules).exists()).toBe(true); expect(wrapper.findComponent(UnconfiguredSecurityRules).exists()).toBe(true);
}); });
}); });
}); });
...@@ -26,7 +26,7 @@ describe('EE Approvals RuleControls', () => { ...@@ -26,7 +26,7 @@ describe('EE Approvals RuleControls', () => {
store: new Vuex.Store(store), store: new Vuex.Store(store),
}); });
}; };
const findButtons = () => wrapper.findAll(GlButton); const findButtons = () => wrapper.findAllComponents(GlButton);
const findButton = (label) => const findButton = (label) =>
findButtons().filter((button) => hasLabel(button, label)).wrappers[0]; findButtons().filter((button) => hasLabel(button, label)).wrappers[0];
const findEditButton = () => findButton('Edit'); const findEditButton = () => findButton('Edit');
......
...@@ -37,12 +37,12 @@ describe('RuleName component', () => { ...@@ -37,12 +37,12 @@ describe('RuleName component', () => {
}); });
it(`should ${hasTooltip ? '' : 'not'} render the tooltip`, () => { it(`should ${hasTooltip ? '' : 'not'} render the tooltip`, () => {
expect(wrapper.find(GlPopover).exists()).toBe(hasTooltip); expect(wrapper.findComponent(GlPopover).exists()).toBe(hasTooltip);
expect(wrapper.find(GlIcon).exists()).toBe(hasTooltip); expect(wrapper.findComponent(GlIcon).exists()).toBe(hasTooltip);
}); });
it(`should ${hasLink ? '' : 'not'} render the tooltip more info link`, () => { it(`should ${hasLink ? '' : 'not'} render the tooltip more info link`, () => {
expect(wrapper.find(GlLink).exists()).toBe(hasLink); expect(wrapper.findComponent(GlLink).exists()).toBe(hasLink);
}); });
it('should render the name', () => { it('should render the name', () => {
......
...@@ -15,8 +15,8 @@ describe('UnconfiguredSecurityRule component', () => { ...@@ -15,8 +15,8 @@ describe('UnconfiguredSecurityRule component', () => {
let wrapper; let wrapper;
let description; let description;
const findDescription = () => wrapper.find(GlSprintf); const findDescription = () => wrapper.findComponent(GlSprintf);
const findButton = () => wrapper.find(GlButton); const findButton = () => wrapper.findComponent(GlButton);
const vulnCheckRule = { const vulnCheckRule = {
name: VULNERABILITY_CHECK_NAME, name: VULNERABILITY_CHECK_NAME,
......
...@@ -53,7 +53,7 @@ describe('UnconfiguredSecurityRules component', () => { ...@@ -53,7 +53,7 @@ describe('UnconfiguredSecurityRules component', () => {
}); });
it('should render a unconfigured-security-rule component for every security rule ', () => { it('should render a unconfigured-security-rule component for every security rule ', () => {
expect(wrapper.findAll(UnconfiguredSecurityRule).length).toBe(3); expect(wrapper.findAllComponents(UnconfiguredSecurityRule).length).toBe(3);
}); });
}); });
...@@ -73,7 +73,7 @@ describe('UnconfiguredSecurityRules component', () => { ...@@ -73,7 +73,7 @@ describe('UnconfiguredSecurityRules component', () => {
}); });
it(`should ${shouldRender ? '' : 'not'} render the loading skeleton`, () => { it(`should ${shouldRender ? '' : 'not'} render the loading skeleton`, () => {
expect(wrapper.find(GlSkeletonLoading).exists()).toBe(shouldRender); expect(wrapper.findComponent(GlSkeletonLoading).exists()).toBe(shouldRender);
}); });
}, },
); );
......
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