Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_suite_table_spec.js « test_reports « pipelines « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2feb6aa5799dff17665b8305392dd20813ed2c1a (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
import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { getJSONFixture } from 'helpers/fixtures';
import SuiteTable from '~/pipelines/components/test_reports/test_suite_table.vue';
import * as getters from '~/pipelines/stores/test_reports/getters';
import { TestStatus } from '~/pipelines/constants';
import skippedTestCases from './mock_data';

const localVue = createLocalVue();
localVue.use(Vuex);

describe('Test reports suite table', () => {
  let wrapper;
  let store;

  const {
    test_suites: [testSuite],
  } = getJSONFixture('pipelines/test_report.json');

  testSuite.test_cases = [...testSuite.test_cases, ...skippedTestCases];
  const testCases = testSuite.test_cases;

  const noCasesMessage = () => wrapper.find('.js-no-test-cases');
  const allCaseRows = () => wrapper.findAll('.js-case-row');
  const findCaseRowAtIndex = index => wrapper.findAll('.js-case-row').at(index);
  const findIconForRow = (row, status) => row.find(`.ci-status-icon-${status}`);

  const createComponent = (suite = testSuite) => {
    store = new Vuex.Store({
      state: {
        testReports: {
          test_suites: [suite],
        },
        selectedSuiteIndex: 0,
      },
      getters,
    });

    wrapper = shallowMount(SuiteTable, {
      store,
      localVue,
    });
  };

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

  describe('should not render', () => {
    beforeEach(() => createComponent([]));

    it('a table when there are no test cases', () => {
      expect(noCasesMessage().exists()).toBe(true);
    });
  });

  describe('when a test suite is supplied', () => {
    beforeEach(() => createComponent());

    it('renders the correct number of rows', () => {
      expect(allCaseRows().length).toBe(testCases.length);
    });

    it('renders the correct icon for each status', () => {
      const failedTest = testCases.findIndex(x => x.status === TestStatus.FAILED);
      const skippedTest = testCases.findIndex(x => x.status === TestStatus.SKIPPED);
      const successTest = testCases.findIndex(x => x.status === TestStatus.SUCCESS);

      const failedRow = findCaseRowAtIndex(failedTest);
      const skippedRow = findCaseRowAtIndex(skippedTest);
      const successRow = findCaseRowAtIndex(successTest);

      expect(findIconForRow(failedRow, TestStatus.FAILED).exists()).toBe(true);
      expect(findIconForRow(skippedRow, TestStatus.SKIPPED).exists()).toBe(true);
      expect(findIconForRow(successRow, TestStatus.SUCCESS).exists()).toBe(true);
    });
  });
});