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

sentry_error_stack_trace_spec.js « components « sentry_error_stack_trace « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 135a3844e7800312a0d7ff03f7ee004ded5f9305 (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
import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui';
import Stacktrace from '~/error_tracking/components/stacktrace.vue';
import SentryErrorStackTrace from '~/sentry_error_stack_trace/components/sentry_error_stack_trace.vue';

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

describe('Sentry Error Stack Trace', () => {
  let actions;
  let getters;
  let store;
  let wrapper;

  function mountComponent({
    stubs = {
      stacktrace: Stacktrace,
    },
  } = {}) {
    wrapper = shallowMount(SentryErrorStackTrace, {
      localVue,
      stubs,
      store,
      propsData: {
        issueStackTracePath: '/stacktrace',
      },
    });
  }

  beforeEach(() => {
    actions = {
      startPollingStacktrace: () => {},
    };

    getters = {
      stacktrace: () => [{ context: [1, 2], lineNo: 53, filename: 'index.js' }],
    };

    const state = {
      stacktraceData: {},
      loadingStacktrace: true,
    };

    store = new Vuex.Store({
      modules: {
        details: {
          namespaced: true,
          actions,
          getters,
          state,
        },
      },
    });
  });

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

  describe('loading', () => {
    it('should show spinner while loading', () => {
      mountComponent();
      expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
      expect(wrapper.find(Stacktrace).exists()).toBe(false);
    });
  });

  describe('Stack trace', () => {
    beforeEach(() => {
      store.state.details.loadingStacktrace = false;
    });

    it('should show stacktrace', () => {
      mountComponent({ stubs: {} });
      expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
      expect(wrapper.find(Stacktrace).exists()).toBe(true);
    });
  });
});