Commit cf943277 authored by Jacques Erasmus's avatar Jacques Erasmus

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

Replace usage of find/findAll in ee/spec/frontend/vulnerabilities

See merge request gitlab-org/gitlab!78642
parents 4433f9f4 40b5f69a
...@@ -226,8 +226,8 @@ describe('Vulnerability Footer', () => { ...@@ -226,8 +226,8 @@ describe('Vulnerability Footer', () => {
const properties = { remediations: [{ diff: [{}] }], solution: 'some solution' }; const properties = { remediations: [{ diff: [{}] }], solution: 'some solution' };
createWrapper({ properties, discussionsHandler: discussionsHandler({ discussions: [] }) }); createWrapper({ properties, discussionsHandler: discussionsHandler({ discussions: [] }) });
expect(wrapper.find(SolutionCard).exists()).toBe(true); expect(wrapper.findComponent(SolutionCard).exists()).toBe(true);
expect(wrapper.find(SolutionCard).props()).toEqual({ expect(wrapper.findComponent(SolutionCard).props()).toEqual({
solution: properties.solution, solution: properties.solution,
remediation: properties.remediations[0], remediation: properties.remediations[0],
hasDownload: true, hasDownload: true,
...@@ -237,7 +237,7 @@ describe('Vulnerability Footer', () => { ...@@ -237,7 +237,7 @@ describe('Vulnerability Footer', () => {
it('does not show solution card when there is not one', () => { it('does not show solution card when there is not one', () => {
createWrapper(); createWrapper();
expect(wrapper.find(SolutionCard).exists()).toBe(false); expect(wrapper.findComponent(SolutionCard).exists()).toBe(false);
}); });
}); });
...@@ -305,7 +305,7 @@ describe('Vulnerability Footer', () => { ...@@ -305,7 +305,7 @@ describe('Vulnerability Footer', () => {
describe('detection note', () => { describe('detection note', () => {
const detectionNote = () => wrapper.find('[data-testid="detection-note"]'); const detectionNote = () => wrapper.find('[data-testid="detection-note"]');
const statusDescription = () => wrapper.find(StatusDescription); const statusDescription = () => wrapper.findComponent(StatusDescription);
const vulnerabilityStates = Object.keys(VULNERABILITY_STATES); const vulnerabilityStates = Object.keys(VULNERABILITY_STATES);
it.each(vulnerabilityStates)( it.each(vulnerabilityStates)(
......
...@@ -82,11 +82,11 @@ describe('Vulnerability Header', () => { ...@@ -82,11 +82,11 @@ describe('Vulnerability Header', () => {
return user; return user;
}; };
const findGlButton = () => wrapper.find(GlButton); const findGlButton = () => wrapper.findComponent(GlButton);
const findSplitButton = () => wrapper.find(SplitButton); const findSplitButton = () => wrapper.findComponent(SplitButton);
const findBadge = () => wrapper.find(GlBadge); const findBadge = () => wrapper.findComponent(GlBadge);
const findResolutionAlert = () => wrapper.find(ResolutionAlert); const findResolutionAlert = () => wrapper.findComponent(ResolutionAlert);
const findStatusDescription = () => wrapper.find(StatusDescription); const findStatusDescription = () => wrapper.findComponent(StatusDescription);
const createWrapper = ({ vulnerability = {}, apolloProvider }) => { const createWrapper = ({ vulnerability = {}, apolloProvider }) => {
wrapper = shallowMount(Header, { wrapper = shallowMount(Header, {
...@@ -139,7 +139,7 @@ describe('Vulnerability Header', () => { ...@@ -139,7 +139,7 @@ describe('Vulnerability Header', () => {
}); });
it(`emits the updated vulnerability properly - ${action}`, async () => { it(`emits the updated vulnerability properly - ${action}`, async () => {
const dropdown = wrapper.find(VulnerabilityStateDropdown); const dropdown = wrapper.findComponent(VulnerabilityStateDropdown);
dropdown.vm.$emit('change', { action }); dropdown.vm.$emit('change', { action });
await waitForPromises(); await waitForPromises();
...@@ -149,7 +149,7 @@ describe('Vulnerability Header', () => { ...@@ -149,7 +149,7 @@ describe('Vulnerability Header', () => {
}); });
it(`emits an event when the state is changed - ${action}`, async () => { it(`emits an event when the state is changed - ${action}`, async () => {
const dropdown = wrapper.find(VulnerabilityStateDropdown); const dropdown = wrapper.findComponent(VulnerabilityStateDropdown);
dropdown.vm.$emit('change', { action }); dropdown.vm.$emit('change', { action });
await waitForPromises(); await waitForPromises();
...@@ -175,7 +175,7 @@ describe('Vulnerability Header', () => { ...@@ -175,7 +175,7 @@ describe('Vulnerability Header', () => {
}); });
it('when the vulnerability state changes but the API call fails, an error message is displayed', async () => { it('when the vulnerability state changes but the API call fails, an error message is displayed', async () => {
const dropdown = wrapper.find(VulnerabilityStateDropdown); const dropdown = wrapper.findComponent(VulnerabilityStateDropdown);
dropdown.vm.$emit('change', { action }); dropdown.vm.$emit('change', { action });
await waitForPromises(); await waitForPromises();
......
...@@ -11,9 +11,9 @@ describe('History Comment Editor', () => { ...@@ -11,9 +11,9 @@ describe('History Comment Editor', () => {
}); });
}; };
const textarea = () => wrapper.find(GlFormTextarea); const textarea = () => wrapper.findComponent(GlFormTextarea);
const saveButton = () => wrapper.find({ ref: 'saveButton' }); const saveButton = () => wrapper.findComponent({ ref: 'saveButton' });
const cancelButton = () => wrapper.find({ ref: 'cancelButton' }); const cancelButton = () => wrapper.findComponent({ ref: 'cancelButton' });
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
......
...@@ -74,13 +74,13 @@ describe('History Comment', () => { ...@@ -74,13 +74,13 @@ describe('History Comment', () => {
.mockResolvedValue(createMutationResponse({ queryName: UPDATE_NOTE, note })); .mockResolvedValue(createMutationResponse({ queryName: UPDATE_NOTE, note }));
}); });
const addCommentButton = () => wrapper.find({ ref: 'addCommentButton' }); const addCommentButton = () => wrapper.findComponent({ ref: 'addCommentButton' });
const commentEditor = () => wrapper.findComponent(HistoryCommentEditor); const commentEditor = () => wrapper.findComponent(HistoryCommentEditor);
const eventItem = () => wrapper.findComponent(EventItem); const eventItem = () => wrapper.findComponent(EventItem);
const editButton = () => wrapper.find('[title="Edit Comment"]'); const editButton = () => wrapper.find('[title="Edit Comment"]');
const deleteButton = () => wrapper.find('[title="Delete Comment"]'); const deleteButton = () => wrapper.find('[title="Delete Comment"]');
const confirmDeleteButton = () => wrapper.find({ ref: 'confirmDeleteButton' }); const confirmDeleteButton = () => wrapper.findComponent({ ref: 'confirmDeleteButton' });
const cancelDeleteButton = () => wrapper.find({ ref: 'cancelDeleteButton' }); const cancelDeleteButton = () => wrapper.findComponent({ ref: 'cancelDeleteButton' });
// Check that the passed-in elements exist, and that everything else does not exist. // Check that the passed-in elements exist, and that everything else does not exist.
const expectExists = (...expectedElements) => { const expectExists = (...expectedElements) => {
......
...@@ -53,10 +53,10 @@ describe('Vulnerability related issues component', () => { ...@@ -53,10 +53,10 @@ describe('Vulnerability related issues component', () => {
} }
}; };
const relatedIssuesBlock = () => wrapper.find(RelatedIssuesBlock); const relatedIssuesBlock = () => wrapper.findComponent(RelatedIssuesBlock);
const blockProp = (prop) => relatedIssuesBlock().props(prop); const blockProp = (prop) => relatedIssuesBlock().props(prop);
const blockEmit = (eventName, data) => relatedIssuesBlock().vm.$emit(eventName, data); const blockEmit = (eventName, data) => relatedIssuesBlock().vm.$emit(eventName, data);
const findCreateIssueButton = () => wrapper.find({ ref: 'createIssue' }); const findCreateIssueButton = () => wrapper.findComponent({ ref: 'createIssue' });
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
......
...@@ -9,7 +9,7 @@ const POPOVER_CONTENT = ...@@ -9,7 +9,7 @@ const POPOVER_CONTENT =
describe('Remediated badge component', () => { describe('Remediated badge component', () => {
let wrapper; let wrapper;
const findBadge = () => wrapper.find(GlBadge); const findBadge = () => wrapper.findComponent(GlBadge);
const createWrapper = () => { const createWrapper = () => {
return shallowMount(RemediatedBadge); return shallowMount(RemediatedBadge);
...@@ -26,12 +26,12 @@ describe('Remediated badge component', () => { ...@@ -26,12 +26,12 @@ describe('Remediated badge component', () => {
}); });
it('should link the badge and the popover', () => { it('should link the badge and the popover', () => {
const popover = wrapper.find({ ref: 'popover' }); const popover = wrapper.findComponent({ ref: 'popover' });
expect(popover.props('target')()).toEqual(findBadge().element); expect(popover.props('target')()).toEqual(findBadge().element);
}); });
it('should pass down the data to the popover', () => { it('should pass down the data to the popover', () => {
const popoverAttributes = wrapper.find(GlPopover).attributes(); const popoverAttributes = wrapper.findComponent(GlPopover).attributes();
expect(popoverAttributes.title).toEqual(POPOVER_TITLE); expect(popoverAttributes.title).toEqual(POPOVER_TITLE);
expect(popoverAttributes.content).toEqual(POPOVER_CONTENT); expect(popoverAttributes.content).toEqual(POPOVER_CONTENT);
......
...@@ -12,7 +12,7 @@ describe('Vulnerability list component', () => { ...@@ -12,7 +12,7 @@ describe('Vulnerability list component', () => {
wrapper = shallowMount(ResolutionAlert, options); wrapper = shallowMount(ResolutionAlert, options);
}; };
const findAlert = () => wrapper.find(GlAlert); const findAlert = () => wrapper.findComponent(GlAlert);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
......
...@@ -22,11 +22,11 @@ describe('Vulnerability status description component', () => { ...@@ -22,11 +22,11 @@ describe('Vulnerability status description component', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const timeAgo = () => wrapper.find(TimeAgoTooltip); const timeAgo = () => wrapper.findComponent(TimeAgoTooltip);
const pipelineLink = () => wrapper.find(GlLink); const pipelineLink = () => wrapper.findComponent(GlLink);
const userAvatar = () => wrapper.find(UserAvatarLink); const userAvatar = () => wrapper.findComponent(UserAvatarLink);
const userLoadingIcon = () => wrapper.find(GlLoadingIcon); const userLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const skeletonLoader = () => wrapper.find(GlSkeletonLoading); const skeletonLoader = () => wrapper.findComponent(GlSkeletonLoading);
const statusEl = () => wrapper.find('[data-testid="status"]'); const statusEl = () => wrapper.find('[data-testid="status"]');
// Create a date using the passed-in string, or just use the current time if nothing was passed in. // Create a date using the passed-in string, or just use the current time if nothing was passed in.
......
...@@ -38,7 +38,7 @@ describe('Vulnerability Details', () => { ...@@ -38,7 +38,7 @@ describe('Vulnerability Details', () => {
it('shows the properties that should always be shown', () => { it('shows the properties that should always be shown', () => {
createWrapper(); createWrapper();
expect(getById('description').html()).toContain(vulnerability.descriptionHtml); expect(getById('description').html()).toContain(vulnerability.descriptionHtml);
expect(wrapper.find(SeverityBadge).props('severity')).toBe(vulnerability.severity); expect(wrapper.findComponent(SeverityBadge).props('severity')).toBe(vulnerability.severity);
expect(getText('reportType')).toBe(`Tool: ${vulnerability.reportType}`); expect(getText('reportType')).toBe(`Tool: ${vulnerability.reportType}`);
expect(getById('title').exists()).toBe(false); expect(getById('title').exists()).toBe(false);
...@@ -202,7 +202,7 @@ describe('Vulnerability Details', () => { ...@@ -202,7 +202,7 @@ describe('Vulnerability Details', () => {
}); });
describe('file link', () => { describe('file link', () => {
const file = () => getById('file').find(GlLink); const file = () => getById('file').findComponent(GlLink);
it('shows only the file name if there is no start line', () => { it('shows only the file name if there is no start line', () => {
createWrapper({ location: { file: 'test.txt', blobPath: 'blob_path.txt' } }); createWrapper({ location: { file: 'test.txt', blobPath: 'blob_path.txt' } });
......
...@@ -24,9 +24,9 @@ describe('Vulnerability state dropdown component', () => { ...@@ -24,9 +24,9 @@ describe('Vulnerability state dropdown component', () => {
const dropdownItems = () => wrapper.findAll('.dropdown-item'); const dropdownItems = () => wrapper.findAll('.dropdown-item');
const firstUnselectedItem = () => wrapper.find('.dropdown-item:not(.selected)'); const firstUnselectedItem = () => wrapper.find('.dropdown-item:not(.selected)');
const selectedItem = () => wrapper.find('.dropdown-item.selected'); const selectedItem = () => wrapper.find('.dropdown-item.selected');
const saveButton = () => wrapper.find({ ref: 'save-button' }); const saveButton = () => wrapper.findComponent({ ref: 'save-button' });
const cancelButton = () => wrapper.find({ ref: 'cancel-button' }); const cancelButton = () => wrapper.findComponent({ ref: 'cancel-button' });
const innerDropdown = () => wrapper.find({ ref: 'dropdown' }); const innerDropdown = () => wrapper.findComponent({ ref: 'dropdown' });
const dropdownItemFor = (state) => wrapper.findByTestId(state); const dropdownItemFor = (state) => wrapper.findByTestId(state);
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
......
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