summaryrefslogtreecommitdiff
path: root/spec/frontend/pipelines/pipelines_spec.js
blob: b0ad6bbd2286f3259ae8fe5b8b1b5c9c425b2dbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises';
import { GlFilteredSearch } from '@gitlab/ui';
import Api from '~/api';
import axios from '~/lib/utils/axios_utils';
import PipelinesComponent from '~/pipelines/components/pipelines_list/pipelines.vue';
import Store from '~/pipelines/stores/pipelines_store';
import { pipelineWithStages, stageReply, users, mockSearch, branches } from './mock_data';
import { RAW_TEXT_WARNING } from '~/pipelines/constants';
import { deprecatedCreateFlash as createFlash } from '~/flash';

jest.mock('~/flash');

describe('Pipelines', () => {
  const jsonFixtureName = 'pipelines/pipelines.json';

  preloadFixtures(jsonFixtureName);

  let pipelines;
  let wrapper;
  let mock;

  const paths = {
    endpoint: 'twitter/flight/pipelines.json',
    autoDevopsPath: '/help/topics/autodevops/index.md',
    helpPagePath: '/help/ci/quick_start/README',
    emptyStateSvgPath: '/assets/illustrations/pipelines_empty.svg',
    errorStateSvgPath: '/assets/illustrations/pipelines_failed.svg',
    noPipelinesSvgPath: '/assets/illustrations/pipelines_pending.svg',
    ciLintPath: '/ci/lint',
    resetCachePath: '/twitter/flight/settings/ci_cd/reset_cache',
    newPipelinePath: '/twitter/flight/pipelines/new',
  };

  const noPermissions = {
    endpoint: 'twitter/flight/pipelines.json',
    autoDevopsPath: '/help/topics/autodevops/index.md',
    helpPagePath: '/help/ci/quick_start/README',
    emptyStateSvgPath: '/assets/illustrations/pipelines_empty.svg',
    errorStateSvgPath: '/assets/illustrations/pipelines_failed.svg',
    noPipelinesSvgPath: '/assets/illustrations/pipelines_pending.svg',
  };

  const defaultProps = {
    hasGitlabCi: true,
    canCreatePipeline: true,
    ...paths,
  };

  const findFilteredSearch = () => wrapper.find(GlFilteredSearch);

  const createComponent = (props = defaultProps, methods) => {
    wrapper = mount(PipelinesComponent, {
      provide: { glFeatures: { filterPipelinesSearch: true } },
      propsData: {
        store: new Store(),
        projectId: '21',
        params: {},
        ...props,
      },
      methods: {
        ...methods,
      },
    });
  };

  beforeEach(() => {
    mock = new MockAdapter(axios);
    pipelines = getJSONFixture(jsonFixtureName);

    jest.spyOn(Api, 'projectUsers').mockResolvedValue(users);
    jest.spyOn(Api, 'branches').mockResolvedValue({ data: branches });
  });

  afterEach(() => {
    wrapper.destroy();
    mock.restore();
  });

  describe('With permission', () => {
    describe('With pipelines in main tab', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);
        createComponent();
        return waitForPromises();
      });

      it('renders tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');
      });

      it('renders Run Pipeline link', () => {
        expect(wrapper.find('.js-run-pipeline').attributes('href')).toBe(paths.newPipelinePath);
      });

      it('renders CI Lint link', () => {
        expect(wrapper.find('.js-ci-lint').attributes('href')).toBe(paths.ciLintPath);
      });

      it('renders Clear Runner Cache button', () => {
        expect(wrapper.find('.js-clear-cache').text()).toBe('Clear Runner Caches');
      });

      it('renders pipelines table', () => {
        expect(wrapper.findAll('.gl-responsive-table-row')).toHaveLength(
          pipelines.pipelines.length + 1,
        );
      });
    });

    describe('Without pipelines on main tab with CI', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, {
          pipelines: [],
          count: {
            all: 0,
            pending: 0,
            running: 0,
            finished: 0,
          },
        });

        createComponent();

        return waitForPromises();
      });

      it('renders tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');
      });

      it('renders Run Pipeline link', () => {
        expect(wrapper.find('.js-run-pipeline').attributes('href')).toEqual(paths.newPipelinePath);
      });

      it('renders CI Lint link', () => {
        expect(wrapper.find('.js-ci-lint').attributes('href')).toEqual(paths.ciLintPath);
      });

      it('renders Clear Runner Cache button', () => {
        expect(wrapper.find('.js-clear-cache').text()).toEqual('Clear Runner Caches');
      });

      it('renders tab empty state', () => {
        expect(wrapper.find('.empty-state h4').text()).toEqual('There are currently no pipelines.');
      });
    });

    describe('Without pipelines nor CI', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, {
          pipelines: [],
          count: {
            all: 0,
            pending: 0,
            running: 0,
            finished: 0,
          },
        });

        createComponent({ hasGitlabCi: false, canCreatePipeline: true, ...paths });

        return waitForPromises();
      });

      it('renders empty state', () => {
        expect(wrapper.find('.js-empty-state h4').text()).toEqual('Build with confidence');

        expect(wrapper.find('.js-get-started-pipelines').attributes('href')).toEqual(
          paths.helpPagePath,
        );
      });

      it('does not render tabs nor buttons', () => {
        expect(wrapper.find('.js-pipelines-tab-all').exists()).toBeFalsy();
        expect(wrapper.find('.js-run-pipeline').exists()).toBeFalsy();
        expect(wrapper.find('.js-ci-lint').exists()).toBeFalsy();
        expect(wrapper.find('.js-clear-cache').exists()).toBeFalsy();
      });
    });

    describe('When API returns error', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(500, {});
        createComponent({ hasGitlabCi: false, canCreatePipeline: true, ...paths });

        return waitForPromises();
      });

      it('renders tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');
      });

      it('renders buttons', () => {
        expect(wrapper.find('.js-run-pipeline').attributes('href')).toEqual(paths.newPipelinePath);

        expect(wrapper.find('.js-ci-lint').attributes('href')).toEqual(paths.ciLintPath);
        expect(wrapper.find('.js-clear-cache').text()).toEqual('Clear Runner Caches');
      });

      it('renders error state', () => {
        expect(wrapper.find('.empty-state').text()).toContain(
          'There was an error fetching the pipelines.',
        );
      });
    });
  });

  describe('Without permission', () => {
    describe('With pipelines in main tab', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);

        createComponent({ hasGitlabCi: false, canCreatePipeline: false, ...noPermissions });

        return waitForPromises();
      });

      it('renders tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');
      });

      it('does not render buttons', () => {
        expect(wrapper.find('.js-run-pipeline').exists()).toBeFalsy();
        expect(wrapper.find('.js-ci-lint').exists()).toBeFalsy();
        expect(wrapper.find('.js-clear-cache').exists()).toBeFalsy();
      });

      it('renders pipelines table', () => {
        expect(wrapper.findAll('.gl-responsive-table-row')).toHaveLength(
          pipelines.pipelines.length + 1,
        );
      });
    });

    describe('Without pipelines on main tab with CI', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, {
          pipelines: [],
          count: {
            all: 0,
            pending: 0,
            running: 0,
            finished: 0,
          },
        });

        createComponent({ hasGitlabCi: true, canCreatePipeline: false, ...noPermissions });

        return waitForPromises();
      });

      it('renders tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');
      });

      it('does not render buttons', () => {
        expect(wrapper.find('.js-run-pipeline').exists()).toBeFalsy();
        expect(wrapper.find('.js-ci-lint').exists()).toBeFalsy();
        expect(wrapper.find('.js-clear-cache').exists()).toBeFalsy();
      });

      it('renders tab empty state', () => {
        expect(wrapper.find('.empty-state h4').text()).toEqual('There are currently no pipelines.');
      });
    });

    describe('Without pipelines nor CI', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, {
          pipelines: [],
          count: {
            all: 0,
            pending: 0,
            running: 0,
            finished: 0,
          },
        });

        createComponent({ hasGitlabCi: false, canCreatePipeline: false, ...noPermissions });

        return waitForPromises();
      });

      it('renders empty state without button to set CI', () => {
        expect(wrapper.find('.js-empty-state').text()).toEqual(
          'This project is not currently set up to run pipelines.',
        );

        expect(wrapper.find('.js-get-started-pipelines').exists()).toBeFalsy();
      });

      it('does not render tabs or buttons', () => {
        expect(wrapper.find('.js-pipelines-tab-all').exists()).toBeFalsy();
        expect(wrapper.find('.js-run-pipeline').exists()).toBeFalsy();
        expect(wrapper.find('.js-ci-lint').exists()).toBeFalsy();
        expect(wrapper.find('.js-clear-cache').exists()).toBeFalsy();
      });
    });

    describe('When API returns error', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(500, {});

        createComponent({ hasGitlabCi: false, canCreatePipeline: true, ...noPermissions });

        return waitForPromises();
      });

      it('renders tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');
      });

      it('does not renders buttons', () => {
        expect(wrapper.find('.js-run-pipeline').exists()).toBeFalsy();
        expect(wrapper.find('.js-ci-lint').exists()).toBeFalsy();
        expect(wrapper.find('.js-clear-cache').exists()).toBeFalsy();
      });

      it('renders error state', () => {
        expect(wrapper.find('.empty-state').text()).toContain(
          'There was an error fetching the pipelines.',
        );
      });
    });
  });

  describe('successful request', () => {
    describe('with pipelines', () => {
      beforeEach(() => {
        mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);

        createComponent();
        return waitForPromises();
      });

      it('should render table', () => {
        expect(wrapper.find('.table-holder').exists()).toBe(true);
        expect(wrapper.findAll('.gl-responsive-table-row')).toHaveLength(
          pipelines.pipelines.length + 1,
        );
      });

      it('should render navigation tabs', () => {
        expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('All');

        expect(wrapper.find('.js-pipelines-tab-finished').text()).toContain('Finished');

        expect(wrapper.find('.js-pipelines-tab-branches').text()).toContain('Branches');

        expect(wrapper.find('.js-pipelines-tab-tags').text()).toContain('Tags');
      });

      it('should make an API request when using tabs', () => {
        const updateContentMock = jest.fn(() => {});
        createComponent(
          { hasGitlabCi: true, canCreatePipeline: true, ...paths },
          {
            updateContent: updateContentMock,
          },
        );

        return waitForPromises().then(() => {
          wrapper.find('.js-pipelines-tab-finished').trigger('click');

          expect(updateContentMock).toHaveBeenCalledWith({ scope: 'finished', page: '1' });
        });
      });

      describe('with pagination', () => {
        it('should make an API request when using pagination', () => {
          const updateContentMock = jest.fn(() => {});
          createComponent(
            { hasGitlabCi: true, canCreatePipeline: true, ...paths },
            {
              updateContent: updateContentMock,
            },
          );

          return waitForPromises()
            .then(() => {
              // Mock pagination
              wrapper.vm.store.state.pageInfo = {
                page: 1,
                total: 10,
                perPage: 2,
                nextPage: 2,
                totalPages: 5,
              };

              return wrapper.vm.$nextTick();
            })
            .then(() => {
              wrapper.find('.next-page-item').trigger('click');

              expect(updateContentMock).toHaveBeenCalledWith({ scope: 'all', page: '2' });
            });
        });
      });
    });
  });

  describe('methods', () => {
    beforeEach(() => {
      jest.spyOn(window.history, 'pushState').mockImplementation(() => null);
    });

    describe('onChangeTab', () => {
      it('should set page to 1', () => {
        const updateContentMock = jest.fn(() => {});
        createComponent(
          { hasGitlabCi: true, canCreatePipeline: true, ...paths },
          {
            updateContent: updateContentMock,
          },
        );

        wrapper.vm.onChangeTab('running');

        expect(updateContentMock).toHaveBeenCalledWith({ scope: 'running', page: '1' });
      });
    });

    describe('onChangePage', () => {
      it('should update page and keep scope', () => {
        const updateContentMock = jest.fn(() => {});
        createComponent(
          { hasGitlabCi: true, canCreatePipeline: true, ...paths },
          {
            updateContent: updateContentMock,
          },
        );

        wrapper.vm.onChangePage(4);

        expect(updateContentMock).toHaveBeenCalledWith({ scope: wrapper.vm.scope, page: '4' });
      });
    });
  });

  describe('computed properties', () => {
    beforeEach(() => {
      createComponent();
    });

    describe('tabs', () => {
      it('returns default tabs', () => {
        expect(wrapper.vm.tabs).toEqual([
          { name: 'All', scope: 'all', count: undefined, isActive: true },
          { name: 'Finished', scope: 'finished', count: undefined, isActive: false },
          { name: 'Branches', scope: 'branches', isActive: false },
          { name: 'Tags', scope: 'tags', isActive: false },
        ]);
      });
    });

    describe('emptyTabMessage', () => {
      it('returns message with finished scope', () => {
        wrapper.vm.scope = 'finished';

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.emptyTabMessage).toEqual('There are currently no finished pipelines.');
        });
      });

      it('returns message without scope when scope is `all`', () => {
        expect(wrapper.vm.emptyTabMessage).toEqual('There are currently no pipelines.');
      });
    });

    describe('stateToRender', () => {
      it('returns loading state when the app is loading', () => {
        expect(wrapper.vm.stateToRender).toEqual('loading');
      });

      it('returns error state when app has error', () => {
        wrapper.vm.hasError = true;
        wrapper.vm.isLoading = false;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.stateToRender).toEqual('error');
        });
      });

      it('returns table list when app has pipelines', () => {
        wrapper.vm.isLoading = false;
        wrapper.vm.hasError = false;
        wrapper.vm.state.pipelines = pipelines.pipelines;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.stateToRender).toEqual('tableList');
        });
      });

      it('returns empty tab when app does not have pipelines but project has pipelines', () => {
        wrapper.vm.state.count.all = 10;
        wrapper.vm.isLoading = false;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.stateToRender).toEqual('emptyTab');
        });
      });

      it('returns empty tab when project has CI', () => {
        wrapper.vm.isLoading = false;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.stateToRender).toEqual('emptyTab');
        });
      });

      it('returns empty state when project does not have pipelines nor CI', () => {
        createComponent({ hasGitlabCi: false, canCreatePipeline: true, ...paths });

        wrapper.vm.isLoading = false;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.stateToRender).toEqual('emptyState');
        });
      });
    });

    describe('shouldRenderTabs', () => {
      it('returns true when state is loading & has already made the first request', () => {
        wrapper.vm.isLoading = true;
        wrapper.vm.hasMadeRequest = true;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderTabs).toEqual(true);
        });
      });

      it('returns true when state is tableList & has already made the first request', () => {
        wrapper.vm.isLoading = false;
        wrapper.vm.state.pipelines = pipelines.pipelines;
        wrapper.vm.hasMadeRequest = true;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderTabs).toEqual(true);
        });
      });

      it('returns true when state is error & has already made the first request', () => {
        wrapper.vm.isLoading = false;
        wrapper.vm.hasError = true;
        wrapper.vm.hasMadeRequest = true;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderTabs).toEqual(true);
        });
      });

      it('returns true when state is empty tab & has already made the first request', () => {
        wrapper.vm.isLoading = false;
        wrapper.vm.state.count.all = 10;
        wrapper.vm.hasMadeRequest = true;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderTabs).toEqual(true);
        });
      });

      it('returns false when has not made first request', () => {
        wrapper.vm.hasMadeRequest = false;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderTabs).toEqual(false);
        });
      });

      it('returns false when state is empty state', () => {
        createComponent({ hasGitlabCi: false, canCreatePipeline: true, ...paths });

        wrapper.vm.isLoading = false;
        wrapper.vm.hasMadeRequest = true;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderTabs).toEqual(false);
        });
      });
    });

    describe('shouldRenderButtons', () => {
      it('returns true when it has paths & has made the first request', () => {
        wrapper.vm.hasMadeRequest = true;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderButtons).toEqual(true);
        });
      });

      it('returns false when it has not made the first request', () => {
        wrapper.vm.hasMadeRequest = false;

        return wrapper.vm.$nextTick().then(() => {
          expect(wrapper.vm.shouldRenderButtons).toEqual(false);
        });
      });
    });
  });

  describe('updates results when a staged is clicked', () => {
    beforeEach(() => {
      const copyPipeline = { ...pipelineWithStages };
      copyPipeline.id += 1;
      mock
        .onGet('twitter/flight/pipelines.json')
        .reply(
          200,
          {
            pipelines: [pipelineWithStages],
            count: {
              all: 1,
              finished: 1,
              pending: 0,
              running: 0,
            },
          },
          {
            'POLL-INTERVAL': 100,
          },
        )
        .onGet(pipelineWithStages.details.stages[0].dropdown_path)
        .reply(200, stageReply);

      createComponent();
    });

    describe('when a request is being made', () => {
      it('stops polling, cancels the request, & restarts polling', () => {
        const stopMock = jest.spyOn(wrapper.vm.poll, 'stop');
        const restartMock = jest.spyOn(wrapper.vm.poll, 'restart');
        const cancelMock = jest.spyOn(wrapper.vm.service.cancelationSource, 'cancel');
        mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);

        return waitForPromises()
          .then(() => {
            wrapper.vm.isMakingRequest = true;
            wrapper.find('.js-builds-dropdown-button').trigger('click');
          })
          .then(() => {
            expect(cancelMock).toHaveBeenCalled();
            expect(stopMock).toHaveBeenCalled();
            expect(restartMock).toHaveBeenCalled();
          });
      });
    });

    describe('when no request is being made', () => {
      it('stops polling & restarts polling', () => {
        const stopMock = jest.spyOn(wrapper.vm.poll, 'stop');
        const restartMock = jest.spyOn(wrapper.vm.poll, 'restart');
        mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);

        return waitForPromises()
          .then(() => {
            wrapper.find('.js-builds-dropdown-button').trigger('click');
            expect(stopMock).toHaveBeenCalled();
          })
          .then(() => {
            expect(restartMock).toHaveBeenCalled();
          });
      });
    });
  });

  describe('Pipeline filters', () => {
    let updateContentMock;

    beforeEach(() => {
      mock.onGet(paths.endpoint).reply(200, pipelines);
      createComponent();

      updateContentMock = jest.spyOn(wrapper.vm, 'updateContent');

      return waitForPromises();
    });

    it('updates request data and query params on filter submit', () => {
      const expectedQueryParams = {
        page: '1',
        scope: 'all',
        username: 'root',
        ref: 'master',
        status: 'pending',
      };

      findFilteredSearch().vm.$emit('submit', mockSearch);

      expect(wrapper.vm.requestData).toEqual(expectedQueryParams);
      expect(updateContentMock).toHaveBeenCalledWith(expectedQueryParams);
    });

    it('does not add query params if raw text search is used', () => {
      const expectedQueryParams = { page: '1', scope: 'all' };

      findFilteredSearch().vm.$emit('submit', ['rawText']);

      expect(wrapper.vm.requestData).toEqual(expectedQueryParams);
      expect(updateContentMock).toHaveBeenCalledWith(expectedQueryParams);
    });

    it('displays a warning message if raw text search is used', () => {
      findFilteredSearch().vm.$emit('submit', ['rawText']);

      expect(createFlash).toHaveBeenCalledTimes(1);
      expect(createFlash).toHaveBeenCalledWith(RAW_TEXT_WARNING, 'warning');
    });
  });
});