Commit 9ea6a83a authored by Savas Vedova's avatar Savas Vedova

Merge branch 'find-migrate-ee-approvals' into 'master'

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

See merge request gitlab-org/gitlab!78632
parents 6566e279 b64af041
......@@ -30,7 +30,7 @@ describe('EE Approvals App', () => {
};
const findAddButton = () => wrapper.find('[data-testid="add-approval-rule"]');
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}`);
beforeEach(() => {
......@@ -104,7 +104,7 @@ describe('EE Approvals App', () => {
it('renders create modal', () => {
factory();
const modal = wrapper.find(ModalRuleCreate);
const modal = wrapper.findComponent(ModalRuleCreate);
expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(`${APP_PREFIX}-approvals-create-modal`);
......@@ -113,7 +113,7 @@ describe('EE Approvals App', () => {
it('renders delete modal', () => {
factory();
const modal = wrapper.find(ModalRuleRemove);
const modal = wrapper.findComponent(ModalRuleRemove);
expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(`${APP_PREFIX}-approvals-remove-modal`);
......
......@@ -25,24 +25,26 @@ describe('Approval Check Popover', () => {
});
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', () => {
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', () => {
expect(wrapper.find(GlPopover).props().target).toBe(
wrapper.find(GlIcon).element.getAttribute('id'),
expect(wrapper.findComponent(GlPopover).props().target).toBe(
wrapper.findComponent(GlIcon).element.getAttribute('id'),
);
});
it('should render gl-popover with correct props', () => {
expect(wrapper.find(GlPopover).props()).toMatchObject({
expect(wrapper.findComponent(GlPopover).props()).toMatchObject({
title,
target: `reportInfo-${title}`,
placement: 'top',
......
......@@ -38,7 +38,7 @@ describe('ApproversList', () => {
it('renders empty', () => {
factory();
expect(wrapper.find(ApproversListEmpty).exists()).toBe(true);
expect(wrapper.findComponent(ApproversListEmpty).exists()).toBe(true);
expect(wrapper.find('ul').exists()).toBe(false);
});
});
......@@ -52,7 +52,7 @@ describe('ApproversList', () => {
factory();
const items = wrapper
.findAll(ApproversListItem)
.findAllComponents(ApproversListItem)
.wrappers.map((item) => item.props('approver'));
expect(items).toEqual(TEST_APPROVERS);
......@@ -62,7 +62,7 @@ describe('ApproversList', () => {
it(`when remove (${idx}), emits new input`, async () => {
factory();
const item = wrapper.findAll(ApproversListItem).at(idx);
const item = wrapper.findAllComponents(ApproversListItem).at(idx);
item.vm.$emit('remove', approver);
await nextTick();
......
......@@ -29,10 +29,10 @@ describe('Empty Rule Name', () => {
it('renders a "more information" link ', () => {
createComponent();
expect(wrapper.find(GlLink).attributes('href')).toBe(
expect(wrapper.findComponent(GlLink).attributes('href')).toBe(
wrapper.props('eligibleApproversDocsPath'),
);
expect(wrapper.find(GlLink).exists()).toBe(true);
expect(wrapper.find(GlLink).text()).toBe('More information');
expect(wrapper.findComponent(GlLink).exists()).toBe(true);
expect(wrapper.findComponent(GlLink).text()).toBe('More information');
});
});
......@@ -56,10 +56,10 @@ describe('EE Approvals Group Settings App', () => {
store = null;
});
const findSettingsBlock = () => wrapper.find(SettingsBlock);
const findSettingsBlock = () => wrapper.findComponent(SettingsBlock);
const findDescriptionLink = () => wrapper.findByTestId('group-settings-description');
const findLearnMoreLink = () => wrapper.findByTestId('group-settings-learn-more');
const findApprovalSettings = () => wrapper.find(ApprovalSettings);
const findApprovalSettings = () => wrapper.findComponent(ApprovalSettings);
it('renders a settings block', () => {
createWrapper();
......
......@@ -57,7 +57,7 @@ describe('EE Approvals LicenseCompliance', () => {
const findByHrefAttribute = (href) => wrapper.find(`[href="${href}"]`);
const findOpenModalButton = () => wrapper.find('button');
const findLoadingIndicator = () => wrapper.find('[aria-label="loading"]');
const findInformationIcon = () => wrapper.find(GlIcon);
const findInformationIcon = () => wrapper.findComponent(GlIcon);
const findLicenseCheckStatus = () => wrapper.find('[data-testid="licenseCheckStatus"]');
describe('when created', () => {
......
......@@ -73,8 +73,8 @@ describe('EE Approvals LicenseCompliance Modal', () => {
});
const findByHref = (href) => wrapper.find(`[href="${href}"`);
const findModal = () => wrapper.find(GlModalVuex);
const findRuleForm = () => wrapper.find(mocks.RuleForm);
const findModal = () => wrapper.findComponent(GlModalVuex);
const findRuleForm = () => wrapper.findComponent(mocks.RuleForm);
const findInformationIcon = () => wrapper.find('[name="question"]');
const findOkButton = () => wrapper.find('[name="ok"]');
const findCancelButton = () => wrapper.find('[name="cancel"]');
......
......@@ -56,11 +56,13 @@ describe('EE Approvals MREditApp', () => {
});
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', () => {
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', () => {
store.modules.approvals.state.rules = [{ id: 7, approvers: [] }];
factory();
expect(wrapper.find(MRRules).findAll('.js-name')).toHaveLength(1);
expect(wrapper.findComponent(MRRules).findAll('.js-name')).toHaveLength(1);
});
it('renders hidden inputs', () => {
store.modules.approvals.state.rules = [{ id: 7, approvers: [] }];
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', () => {
......
......@@ -25,7 +25,7 @@ describe('Empty Rule', () => {
allowMultiRule: true,
canEdit: true,
});
expect(wrapper.find(GlButton).exists()).toBe(false);
expect(wrapper.findComponent(GlButton).exists()).toBe(false);
});
});
......@@ -36,7 +36,7 @@ describe('Empty Rule', () => {
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', () => {
......@@ -44,7 +44,7 @@ describe('Empty Rule', () => {
allowMultiRule: true,
canEdit: false,
});
expect(wrapper.find(GlButton).exists()).toBe(false);
expect(wrapper.findComponent(GlButton).exists()).toBe(false);
});
});
});
......@@ -32,9 +32,9 @@ describe('EE Approvals MRRules', () => {
const findHeaders = () => wrapper.findAll('thead th').wrappers.map((x) => x.text());
const findRuleName = () => wrapper.find('.js-name');
const findRuleIndicator = () => wrapper.find({ ref: 'indicator' });
const findAvatarList = () => wrapper.find(UserAvatarList);
const findRuleControls = () => wrapper.find('td.js-controls').find(RuleControls);
const findRuleIndicator = () => wrapper.findComponent({ ref: 'indicator' });
const findAvatarList = () => wrapper.findComponent(UserAvatarList);
const findRuleControls = () => wrapper.find('td.js-controls').findComponent(RuleControls);
const callTargetBranchHandler = (MutationObserverSpy) => {
const onTargetBranchMutationHandler = MutationObserverSpy.mock.calls[0][0];
return onTargetBranchMutationHandler();
......
......@@ -14,7 +14,7 @@ describe('ProjectApprovalSettings', () => {
let wrapper;
let store;
const findApprovalSettings = () => wrapper.find(ApprovalSettings);
const findApprovalSettings = () => wrapper.findComponent(ApprovalSettings);
const setupStore = (data = {}) => {
store = createStore({
......
......@@ -23,8 +23,8 @@ const getRowData = (tr) => {
const approvalsRequired = findCell(tr, 'approvals-required');
return {
name: name.text(),
approvers: members.find(UserAvatarList).props('items'),
approvalsRequired: approvalsRequired.find(RuleInput).props('rule').approvalsRequired,
approvers: members.findComponent(UserAvatarList).props('items'),
approvalsRequired: approvalsRequired.findComponent(RuleInput).props('rule').approvalsRequired,
};
};
......@@ -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', () => {
......@@ -99,7 +99,7 @@ describe('Approvals ProjectRules', () => {
it('does not render name', () => {
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', () => {
......@@ -119,7 +119,7 @@ describe('Approvals ProjectRules', () => {
beforeEach(() => {
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', () => {
......@@ -130,7 +130,7 @@ describe('Approvals ProjectRules', () => {
});
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', () => {
});
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', () => {
store: new Vuex.Store(store),
});
};
const findButtons = () => wrapper.findAll(GlButton);
const findButtons = () => wrapper.findAllComponents(GlButton);
const findButton = (label) =>
findButtons().filter((button) => hasLabel(button, label)).wrappers[0];
const findEditButton = () => findButton('Edit');
......
......@@ -37,12 +37,12 @@ describe('RuleName component', () => {
});
it(`should ${hasTooltip ? '' : 'not'} render the tooltip`, () => {
expect(wrapper.find(GlPopover).exists()).toBe(hasTooltip);
expect(wrapper.find(GlIcon).exists()).toBe(hasTooltip);
expect(wrapper.findComponent(GlPopover).exists()).toBe(hasTooltip);
expect(wrapper.findComponent(GlIcon).exists()).toBe(hasTooltip);
});
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', () => {
......
......@@ -15,8 +15,8 @@ describe('UnconfiguredSecurityRule component', () => {
let wrapper;
let description;
const findDescription = () => wrapper.find(GlSprintf);
const findButton = () => wrapper.find(GlButton);
const findDescription = () => wrapper.findComponent(GlSprintf);
const findButton = () => wrapper.findComponent(GlButton);
const vulnCheckRule = {
name: VULNERABILITY_CHECK_NAME,
......
......@@ -53,7 +53,7 @@ describe('UnconfiguredSecurityRules component', () => {
});
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', () => {
});
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