summaryrefslogtreecommitdiff
path: root/spec/javascripts/jobs/components/stages_dropdown_spec.js
blob: aa6cc0f1b1a01038dae701994a29f0f476e14ea1 (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
import Vue from 'vue';
import component from '~/jobs/components/stages_dropdown.vue';
import mountComponent from '../../helpers/vue_mount_component_helper';

describe('Artifacts block', () => {
  const Component = Vue.extend(component);
  let vm;

  beforeEach(() => {
    vm = mountComponent(Component, {
      pipeline: {
        id: 28029444,
        details: {
          status: {
            details_path: '/gitlab-org/gitlab-ce/pipelines/28029444',
            group: 'success',
            has_details: true,
            icon: 'status_success',
            label: 'passed',
            text: 'passed',
            tooltip: 'passed',
          },
        },
        path: 'pipeline/28029444',
      },
      ref: {
        path: 'commits/50101-truncated-job-information',
        name: '50101-truncated-job-information',
      },
      stages: [
        {
          name: 'build',
        },
        {
          name: 'test',
        },
      ],
    });
  });

  afterEach(() => {
    vm.$destroy();
  });

  it('renders pipeline status', () => {
    expect(vm.$el.querySelector('.js-ci-status-icon-success')).not.toBeNull();
  });

  it('renders pipeline link', () => {
    expect(vm.$el.querySelector('.js-pipeline-path').getAttribute('href')).toEqual(
      'pipeline/28029444',
    );
  });

  it('renders dropdown with stages', () => {
    expect(vm.$el.querySelector('.dropdown button').textContent).toContain('build');
  });

  it('updates selected stage on click', done => {
    vm.$el.querySelectorAll('.stage-item')[1].click();
    vm
      .$nextTick()
      .then(() => {
        expect(vm.$el.querySelector('.dropdown button').textContent).toContain('test');
      })
      .then(done)
      .catch(done.fail);
  });
});