Commit 6d0438a4 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'find-migrate-ee-misc-v3' into 'master'

Replace usage of find/findAll in misc ee components (3/5)

See merge request gitlab-org/gitlab!78652
parents 453d8240 920afc5c
......@@ -47,6 +47,6 @@ describe('RelatedIssuableItem', () => {
});
it('renders weight component with correct weight', () => {
expect(wrapper.find(IssueWeight).props('weight')).toBe(props.weight);
expect(wrapper.findComponent(IssueWeight).props('weight')).toBe(props.weight);
});
});
......@@ -29,7 +29,7 @@ describe('RelatedIssuesList', () => {
});
it('shows weight', () => {
expect(wrapper.find(IssueWeight).find('.board-card-info-text').text()).toBe(
expect(wrapper.findComponent(IssueWeight).find('.board-card-info-text').text()).toBe(
issuable1.weight.toString(),
);
});
......
......@@ -33,7 +33,7 @@ describe('Incident SLA', () => {
}
});
const findSLA = () => wrapper.find(ServiceLevelAgreement);
const findSLA = () => wrapper.findComponent(ServiceLevelAgreement);
it('renders a blank component when there is no data', () => {
mountComponent({
......
......@@ -47,10 +47,10 @@ describe('Metrics upload item', () => {
}
});
const findImageLink = () => wrapper.find(GlLink);
const findImageLink = () => wrapper.findComponent(GlLink);
const findCollapseButton = () => wrapper.find('[data-testid="collapse-button"]');
const findMetricImageBody = () => wrapper.find('[data-testid="metric-image-body"]');
const findModal = () => wrapper.find(GlModal);
const findModal = () => wrapper.findComponent(GlModal);
const findDeleteButton = () => wrapper.find('[data-testid="delete-button"]');
const closeModal = () => findModal().vm.$emit('hidden');
......
......@@ -54,9 +54,9 @@ describe('Metrics tab', () => {
}
});
const findUploadDropzone = () => wrapper.find(UploadDropzone);
const findImages = () => wrapper.findAll(MetricsImage);
const findModal = () => wrapper.find(GlModal);
const findUploadDropzone = () => wrapper.findComponent(UploadDropzone);
const findImages = () => wrapper.findAllComponents(MetricsImage);
const findModal = () => wrapper.findComponent(GlModal);
const submitModal = () => findModal().vm.$emit('primary', mockEvent);
const cancelModal = () => findModal().vm.$emit('hidden');
......@@ -145,7 +145,7 @@ describe('Metrics tab', () => {
});
it('should display the url field', () => {
expect(wrapper.find(GlFormInput).attributes('value')).toBe(testUrl);
expect(wrapper.findComponent(GlFormInput).attributes('value')).toBe(testUrl);
});
it('should clear url when cancelled', async () => {
......@@ -153,7 +153,7 @@ describe('Metrics tab', () => {
await waitForPromises();
expect(wrapper.find(GlFormInput).attributes('value')).toBe('');
expect(wrapper.findComponent(GlFormInput).attributes('value')).toBe('');
});
it('should clear url when submitted', async () => {
......@@ -161,7 +161,7 @@ describe('Metrics tab', () => {
await waitForPromises();
expect(wrapper.find(GlFormInput).attributes('value')).toBe('');
expect(wrapper.findComponent(GlFormInput).attributes('value')).toBe('');
});
});
});
......
......@@ -59,9 +59,9 @@ describe('Issue Analytics component', () => {
axiosMock.restore();
});
const findLoadingIcon = () => wrapper.find(GlLoadingIcon);
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findChartContainer = () => wrapper.find('.issues-analytics-chart');
const findEmptyState = () => wrapper.find(GlEmptyState);
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
it('fetches chart data when mounted', () => {
expect(store.dispatch).toHaveBeenCalledWith('issueAnalytics/fetchChartData', TEST_HOST);
......@@ -113,6 +113,6 @@ describe('Issue Analytics component', () => {
});
it('renders the issues table', () => {
expect(wrapper.find(IssuesAnalyticsTable).exists()).toBe(true);
expect(wrapper.findComponent(IssuesAnalyticsTable).exists()).toBe(true);
});
});
......@@ -54,7 +54,7 @@ describe('IssuesAnalyticsTable', () => {
});
it('displays a loading icon', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
});
it('does not display the table', () => {
......@@ -64,7 +64,7 @@ describe('IssuesAnalyticsTable', () => {
describe('fetching data completed', () => {
it('hides the loading state', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(false);
});
it('displays the table', () => {
......
......@@ -39,7 +39,7 @@ describe('Shared Runner Limit Block', () => {
});
it('renders call to action gl-button with the right href', () => {
const glButton = wrapper.find(GlButton);
const glButton = wrapper.findComponent(GlButton);
expect(glButton.isVisible()).toBe(true);
expect(glButton.attributes('variant')).toBe('danger');
......
......@@ -114,24 +114,24 @@ describe('Project Licenses', () => {
});
it('shows the loading component', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
});
it('does not show the empty state component', () => {
expect(wrapper.find(GlEmptyState).exists()).toBe(false);
expect(wrapper.findComponent(GlEmptyState).exists()).toBe(false);
});
it('does not show the list of detected in project licenses', () => {
expect(wrapper.find(DetectedLicensesTable).exists()).toBe(false);
expect(wrapper.findComponent(DetectedLicensesTable).exists()).toBe(false);
});
it('does not show the list of license policies', () => {
expect(wrapper.find(LicenseManagement).exists()).toBe(false);
expect(wrapper.findComponent(LicenseManagement).exists()).toBe(false);
});
it('does not render any tabs', () => {
expect(wrapper.find(GlTabs).exists()).toBe(false);
expect(wrapper.find(GlTab).exists()).toBe(false);
expect(wrapper.findComponent(GlTabs).exists()).toBe(false);
expect(wrapper.findComponent(GlTab).exists()).toBe(false);
});
});
......@@ -150,24 +150,24 @@ describe('Project Licenses', () => {
});
it('shows the empty state component', () => {
expect(wrapper.find(GlEmptyState).exists()).toBe(true);
expect(wrapper.findComponent(GlEmptyState).exists()).toBe(true);
});
it('does not show the loading component', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(false);
});
it('does not show the list of detected in project licenses', () => {
expect(wrapper.find(DetectedLicensesTable).exists()).toBe(false);
expect(wrapper.findComponent(DetectedLicensesTable).exists()).toBe(false);
});
it('does not show the list of license policies', () => {
expect(wrapper.find(LicenseManagement).exists()).toBe(false);
expect(wrapper.findComponent(LicenseManagement).exists()).toBe(false);
});
it('does not render any tabs', () => {
expect(wrapper.find(GlTabs).exists()).toBe(false);
expect(wrapper.find(GlTab).exists()).toBe(false);
expect(wrapper.findComponent(GlTabs).exists()).toBe(false);
expect(wrapper.findComponent(GlTab).exists()).toBe(false);
});
});
......@@ -186,7 +186,7 @@ describe('Project Licenses', () => {
});
it('does not render a policy violations alert', () => {
expect(wrapper.find(GlAlert).exists()).toBe(false);
expect(wrapper.findComponent(GlAlert).exists()).toBe(false);
});
it('renders the SbomBannercomponent with the right props', () => {
......@@ -196,21 +196,21 @@ describe('Project Licenses', () => {
});
it('renders a "Detected in project" tab and a "Policies" tab', () => {
expect(wrapper.find(GlTabs).exists()).toBe(true);
expect(wrapper.find(GlTab).exists()).toBe(true);
expect(wrapper.findComponent(GlTabs).exists()).toBe(true);
expect(wrapper.findComponent(GlTab).exists()).toBe(true);
expect(wrapper.findAllComponents(GlTab)).toHaveLength(2);
});
it('it renders the "Detected in project" table', () => {
expect(wrapper.find(DetectedLicensesTable).exists()).toBe(true);
expect(wrapper.findComponent(DetectedLicensesTable).exists()).toBe(true);
});
it('it renders the "Policies" table', () => {
expect(wrapper.find(LicenseManagement).exists()).toBe(true);
expect(wrapper.findComponent(LicenseManagement).exists()).toBe(true);
});
it('renders the pipeline info', () => {
expect(wrapper.find(PipelineInfo).exists()).toBe(true);
expect(wrapper.findComponent(PipelineInfo).exists()).toBe(true);
});
describe.each`
......@@ -329,8 +329,8 @@ describe('Project Licenses', () => {
});
it('renders a policy violations alert', () => {
expect(wrapper.find(GlAlert).exists()).toBe(true);
expect(wrapper.find(GlAlert).text()).toContain(
expect(wrapper.findComponent(GlAlert).exists()).toBe(true);
expect(wrapper.findComponent(GlAlert).text()).toContain(
"Detected licenses that are out-of-compliance with the project's assigned policies",
);
});
......
......@@ -24,7 +24,7 @@ describe('DetectedLicenesTable component', () => {
};
const expectComponentWithProps = (Component, props = {}) => {
const componentWrapper = wrapper.find(Component);
const componentWrapper = wrapper.findComponent(Component);
expect(componentWrapper.isVisible()).toBe(true);
expect(componentWrapper.props()).toEqual(expect.objectContaining(props));
};
......@@ -102,7 +102,7 @@ describe('DetectedLicenesTable component', () => {
});
it('does not render pagination', () => {
expect(wrapper.find(Pagination).exists()).toBe(false);
expect(wrapper.findComponent(Pagination).exists()).toBe(false);
});
});
});
......@@ -35,7 +35,7 @@ describe('LicenseComponentLinks component', () => {
// query helpers
const findComponentsList = () => wrapper.find('.js-component-links-component-list');
const findComponentListItems = () => wrapper.findAll('.js-component-links-component-list-item');
const findModal = () => wrapper.find(GlModal);
const findModal = () => wrapper.findComponent(GlModal);
const findModalItem = () => wrapper.findAll('.js-component-links-modal-item');
const findModalTrigger = () => wrapper.find('.js-component-links-modal-trigger');
......@@ -55,7 +55,7 @@ describe('LicenseComponentLinks component', () => {
it('intersperses the list of licenses correctly', () => {
factory();
const intersperseInstance = wrapper.find(GlIntersperse);
const intersperseInstance = wrapper.findComponent(GlIntersperse);
expect(intersperseInstance.exists()).toBe(true);
expect(intersperseInstance.attributes('lastseparator')).toBe(' and ');
......@@ -80,11 +80,11 @@ describe('LicenseComponentLinks component', () => {
({ numComponents, numComponentsWithUrl, expectedNumVisibleLinks, expectedNumModalLinks }) => {
factory({ numComponents, numComponentsWithUrl });
expect(findComponentsList().findAll(GlLink)).toHaveLength(expectedNumVisibleLinks);
expect(findComponentsList().findAllComponents(GlLink)).toHaveLength(expectedNumVisibleLinks);
// findModal() is an empty wrapper if we have less than VISIBLE_COMPONENT_COUNT
if (numComponents > VISIBLE_COMPONENT_COUNT) {
expect(findModal().findAll(GlLink)).toHaveLength(expectedNumModalLinks);
expect(findModal().findAllComponents(GlLink)).toHaveLength(expectedNumModalLinks);
} else {
expect(findModal().exists()).toBe(false);
}
......@@ -94,7 +94,7 @@ describe('LicenseComponentLinks component', () => {
it('sets all links to open in new windows/tabs', () => {
factory({ numComponents: 8, numComponentsWithUrl: 8 });
const links = wrapper.findAll(GlLink);
const links = wrapper.findAllComponents(GlLink);
links.wrappers.forEach((link) => {
expect(link.attributes('target')).toBe('_blank');
......@@ -128,13 +128,13 @@ describe('LicenseComponentLinks component', () => {
({ numComponents, expectedNumModals }) => {
factory({ numComponents, expectedNumModals });
expect(wrapper.findAll(GlModal)).toHaveLength(expectedNumModals);
expect(wrapper.findAllComponents(GlModal)).toHaveLength(expectedNumModals);
},
);
it('opens the modal when the trigger gets clicked', () => {
factory({ numComponents: 3 });
const modalId = wrapper.find(GlModal).props('modalId');
const modalId = wrapper.findComponent(GlModal).props('modalId');
const modalTrigger = findModalTrigger();
const rootEmit = jest.spyOn(wrapper.vm.$root, '$emit');
......@@ -149,7 +149,7 @@ describe('LicenseComponentLinks component', () => {
while (usedModalIds.length < 10) {
factory({ numComponents });
const modalId = wrapper.find(GlModal).props('modalId');
const modalId = wrapper.findComponent(GlModal).props('modalId');
expect(usedModalIds).not.toContain(modalId);
usedModalIds.push(modalId);
......@@ -160,13 +160,13 @@ describe('LicenseComponentLinks component', () => {
const title = 'test-component';
factory({ numComponents: 3, title });
expect(wrapper.find(GlModal).attributes('title')).toEqual(title);
expect(wrapper.findComponent(GlModal).attributes('title')).toEqual(title);
});
it('assigns the correct action button text to the modal', () => {
factory({ numComponents: 3 });
expect(wrapper.find(GlModal).attributes('ok-title')).toEqual('Close');
expect(wrapper.findComponent(GlModal).attributes('ok-title')).toEqual('Close');
});
it.each`
......
......@@ -20,7 +20,7 @@ describe('LicensesTableRow component', () => {
});
};
const findLoading = () => wrapper.find(GlSkeletonLoading);
const findLoading = () => wrapper.findComponent(GlSkeletonLoading);
const findContent = () => wrapper.find('.js-license-row');
const findNameSection = () => findContent().find('.section-30');
const findComponentSection = () => findContent().find('.section-70');
......@@ -66,7 +66,7 @@ describe('LicensesTableRow component', () => {
});
it('shows name', () => {
const nameLink = findNameSection().find(GlLink);
const nameLink = findNameSection().findComponent(GlLink);
expect(nameLink.exists()).toBe(true);
expect(nameLink.attributes('href')).toEqual(license.url);
......@@ -74,7 +74,7 @@ describe('LicensesTableRow component', () => {
});
it('shows components', () => {
const componentLinks = findComponentSection().find(LicenseComponentLinks);
const componentLinks = findComponentSection().findComponent(LicenseComponentLinks);
expect(componentLinks.exists()).toBe(true);
expect(componentLinks.props()).toEqual(
......@@ -100,9 +100,9 @@ describe('LicensesTableRow component', () => {
it('renders the GlFriendlyWrap and GlLink components', () => {
const nameSection = findNameSection();
expect(nameSection.find(GlLink).exists()).toBe(true);
expect(nameSection.find(GlFriendlyWrap).exists()).toBe(true);
expect(nameSection.find(GlFriendlyWrap).attributes().text).toBe(license.name);
expect(nameSection.findComponent(GlLink).exists()).toBe(true);
expect(nameSection.findComponent(GlFriendlyWrap).exists()).toBe(true);
expect(nameSection.findComponent(GlFriendlyWrap).attributes().text).toBe(license.name);
});
});
......@@ -120,7 +120,7 @@ describe('LicensesTableRow component', () => {
const nameSection = findNameSection();
expect(nameSection.text()).toContain(license.name);
expect(nameSection.find(GlLink).exists()).toBe(false);
expect(nameSection.findComponent(GlLink).exists()).toBe(false);
});
});
......@@ -135,8 +135,8 @@ describe('LicensesTableRow component', () => {
});
it('shows the policy violation badge', () => {
expect(wrapper.find(GlBadge).exists()).toBe(true);
expect(wrapper.find(GlBadge).text()).toContain('Policy violation: denied');
expect(wrapper.findComponent(GlBadge).exists()).toBe(true);
expect(wrapper.findComponent(GlBadge).text()).toContain('Policy violation: denied');
});
});
......@@ -151,7 +151,7 @@ describe('LicensesTableRow component', () => {
});
it('does not show the policy violation badge', () => {
expect(wrapper.find(GlBadge).exists()).toBe(false);
expect(wrapper.findComponent(GlBadge).exists()).toBe(false);
});
});
});
......@@ -13,7 +13,7 @@ describe('LicensesTable component', () => {
};
const findTableRowHeader = () => wrapper.find('.table-row-header');
const findRows = () => wrapper.findAll(LicensesTableRow);
const findRows = () => wrapper.findAllComponents(LicensesTableRow);
afterEach(() => {
wrapper.destroy();
......
......@@ -36,10 +36,10 @@ describe('MaintenanceModeSettingsApp', () => {
wrapper = null;
});
const findMaintenanceModeSettingsForm = () => wrapper.find(GlForm);
const findGlLoadingIcon = () => wrapper.find(GlLoadingIcon);
const findGlToggle = () => wrapper.find(GlToggle);
const findGlFormTextarea = () => wrapper.find(GlFormTextarea);
const findMaintenanceModeSettingsForm = () => wrapper.findComponent(GlForm);
const findGlLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findGlToggle = () => wrapper.findComponent(GlToggle);
const findGlFormTextarea = () => wrapper.findComponent(GlFormTextarea);
const findSubmitButton = () => findMaintenanceModeSettingsForm().find('[type="submit"]');
describe('template', () => {
......
......@@ -43,7 +43,7 @@ describe('NoteHeader component', () => {
// Wait for dynamic imports to resolve
return new Promise(setImmediate).then(() => {
expect(wrapper.find(GitlabTeamMemberBadge).exists()).toBe(expected);
expect(wrapper.findComponent(GitlabTeamMemberBadge).exists()).toBe(expected);
});
},
);
......
......@@ -6,7 +6,7 @@ describe('EmptyState', () => {
let wrapper;
// Finders
const findGlEmptyState = () => wrapper.find(GlEmptyState);
const findGlEmptyState = () => wrapper.findComponent(GlEmptyState);
// Helpers
const defaultGlEmptyStateProp = (prop) => GlEmptyState.props[prop].default;
......
......@@ -134,7 +134,7 @@ describe('Scheduled tab', () => {
it('renders the schedule cell', () => {
const scheduleCell = findCellAt(5);
const dastScanScheduleComponent = scheduleCell.find(DastScanSchedule);
const dastScanScheduleComponent = scheduleCell.findComponent(DastScanSchedule);
expect(dastScanScheduleComponent.exists()).toBe(true);
expect(dastScanScheduleComponent.props('schedule')).toEqual(firstProfile.dastProfileSchedule);
......
......@@ -70,7 +70,7 @@ describe('OnDemandScansForm', () => {
template: '<input />',
});
const findForm = () => wrapper.find(GlForm);
const findForm = () => wrapper.findComponent(GlForm);
const findByTestId = (testId) => wrapper.find(`[data-testid="${testId}"]`);
const findHelpPageLink = () => findByTestId('help-page-link');
const findNameInput = () => findByTestId('dast-scan-name-input');
......@@ -111,7 +111,7 @@ describe('OnDemandScansForm', () => {
return setValidFormData();
};
const selectProfile = (component) => async (profile) => {
wrapper.find(component).vm.$emit('input', profile.id);
wrapper.findComponent(component).vm.$emit('input', profile.id);
await wrapper.vm.$nextTick();
};
const selectScannerProfile = selectProfile(ScannerProfileSelector);
......@@ -248,7 +248,7 @@ describe('OnDemandScansForm', () => {
},
});
expect(wrapper.find(GlSkeletonLoader).exists()).toBe(isLoading);
expect(wrapper.findComponent(GlSkeletonLoader).exists()).toBe(isLoading);
},
);
});
......@@ -577,7 +577,7 @@ describe('OnDemandScansForm', () => {
});
it('automatically selects the only available profile', () => {
expect(wrapper.find(selector).attributes('value')).toBe(profile.id);
expect(wrapper.findComponent(selector).attributes('value')).toBe(profile.id);
});
});
......
......@@ -126,7 +126,7 @@ describe('EE - DAST Profiles Selector', () => {
},
});
expect(wrapper.find(GlSkeletonLoader).exists()).toBe(isLoading);
expect(wrapper.findComponent(GlSkeletonLoader).exists()).toBe(isLoading);
},
);
});
......@@ -179,7 +179,7 @@ describe('EE - DAST Profiles Selector', () => {
});
it('automatically selects the only available profile', () => {
expect(wrapper.find(selector).attributes('value')).toBe(profile.id);
expect(wrapper.findComponent(selector).attributes('value')).toBe(profile.id);
});
});
......@@ -209,8 +209,10 @@ describe('EE - DAST Profiles Selector', () => {
);
createComponent();
expect(wrapper.find(SiteProfileSelector).attributes('value')).toBe(siteProfile.id);
expect(wrapper.find(ScannerProfileSelector).attributes('value')).toBe(scannerProfile.id);
expect(wrapper.findComponent(SiteProfileSelector).attributes('value')).toBe(siteProfile.id);
expect(wrapper.findComponent(ScannerProfileSelector).attributes('value')).toBe(
scannerProfile.id,
);
});
});
});
......@@ -40,13 +40,13 @@ describe('OnDemandScansProfileSelector', () => {
// Helpers
const parseDropdownItems = () =>
findProfilesDropdown()
.findAll(GlDropdownItem)
.findAllComponents(GlDropdownItem)
.wrappers.map((x) => ({
text: x.text(),
isChecked: x.props('isChecked'),
}));
const selectFirstProfile = () => {
return findProfilesDropdown().find(GlDropdownItem).vm.$emit('click');
return findProfilesDropdown().findComponent(GlDropdownItem).vm.$emit('click');
};
const createFullComponent = (options = {}) => {
......
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