Add `findLink` to panel_type_spec.js

The following discussion from !24337 (merged) should be addressed:

  • @pslaughter started a discussion:

    suggestion: It's a little strange to create a function just to be called right below it. What do you think of moving this finder up a few scopes so it can be shared? Also, I suggest we name it findLink for consistency and it makes it easier to find references.

    diff --git a/spec/frontend/monitoring/components/panel_type_spec.js b/spec/frontend/monitoring/components/panel_type_spec.js
    index 1da65208c2d..ae5e036976d 100644
    --- a/spec/frontend/monitoring/components/panel_type_spec.js
    +++ b/spec/frontend/monitoring/components/panel_type_spec.js
    @@ -38,6 +38,8 @@ describe('Panel Type component', () => {
         });
       };
     
    +  const findLink = () => wrapper.find({ ref: 'copyChartLink' });
    +
       beforeEach(() => {
         setTestTimeout(1000);
     
    @@ -96,8 +98,7 @@ describe('Panel Type component', () => {
         });
     
         it('sets no clipboard copy link on dropdown by default', () => {
    -      const link = () => wrapper.find({ ref: 'copyChartLink' });
    -      expect(link().exists()).toBe(false);
    +      expect(findLink().exists()).toBe(false);
         });
     
         describe('Time Series Chart panel type', () => {
    @@ -183,7 +184,6 @@ describe('Panel Type component', () => {
       });
     
       describe('when cliboard data is available', () => {
    -    const link = () => wrapper.find({ ref: 'copyChartLink' });
         const clipboardText = 'A value to copy.';
     
         beforeEach(() => {
    @@ -198,16 +198,16 @@ describe('Panel Type component', () => {
         });
     
         it('sets clipboard text on the dropdown', () => {
    -      expect(link().exists()).toBe(true);
    -      expect(link().element.dataset.clipboardText).toBe(clipboardText);
    +      expect(findLink().exists()).toBe(true);
    +      expect(findLink().element.dataset.clipboardText).toBe(clipboardText);
         });
     
         it('adds a copy button to the dropdown', () => {
    -      expect(link().text()).toContain('Generate link to chart');
    +      expect(findLink().text()).toContain('Generate link to chart');
         });
     
         it('opens a toast on click', () => {
    -      link().vm.$emit('click');
    +      findLink().vm.$emit('click');
     
           expect(wrapper.vm.$toast.show).toHaveBeenCalled();
         });