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

test_extensions.js « vue_mr_widget « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6344636873f6cdd3e8d44feb5d8ee45dc4aea543 (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
import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants';

export const workingExtension = (shouldCollapse = true) => ({
  name: 'WidgetTestExtension',
  props: ['targetProjectFullPath'],
  expandEvent: 'test_expand_event',
  computed: {
    summary({ count, targetProjectFullPath }) {
      return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
    },
    statusIcon({ count }) {
      return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
    },
    shouldCollapse() {
      return shouldCollapse;
    },
  },
  methods: {
    fetchCollapsedData({ targetProjectFullPath }) {
      return Promise.resolve({ targetProjectFullPath, count: 1 });
    },
    fetchFullData() {
      return Promise.resolve([
        {
          id: 1,
          text: 'Hello world',
          icon: {
            name: EXTENSION_ICONS.failed,
          },
          badge: {
            text: 'Closed',
          },
          link: {
            href: 'https://gitlab.com',
            text: 'GitLab.com',
          },
          actions: [{ text: 'Full report', href: 'https://gitlab.com', target: '_blank' }],
        },
      ]);
    },
  },
});

export const collapsedDataErrorExtension = {
  name: 'WidgetTestCollapsedErrorExtension',
  props: ['targetProjectFullPath'],
  expandEvent: 'test_expand_event',
  computed: {
    summary({ count, targetProjectFullPath }) {
      return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
    },
    statusIcon({ count }) {
      return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
    },
  },
  methods: {
    fetchCollapsedData() {
      return Promise.reject(new Error('Fetch error'));
    },
    fetchFullData() {
      return Promise.resolve([
        {
          id: 1,
          text: 'Hello world',
          icon: {
            name: EXTENSION_ICONS.failed,
          },
          badge: {
            text: 'Closed',
          },
          link: {
            href: 'https://gitlab.com',
            text: 'GitLab.com',
          },
          actions: [{ text: 'Full report', href: 'https://gitlab.com', target: '_blank' }],
        },
      ]);
    },
  },
};

export const fullDataErrorExtension = {
  name: 'WidgetTestCollapsedErrorExtension',
  props: ['targetProjectFullPath'],
  expandEvent: 'test_expand_event',
  computed: {
    summary({ count, targetProjectFullPath }) {
      return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
    },
    statusIcon({ count }) {
      return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
    },
  },
  methods: {
    fetchCollapsedData({ targetProjectFullPath }) {
      return Promise.resolve({ targetProjectFullPath, count: 1 });
    },
    fetchFullData() {
      return Promise.reject(new Error('Fetch error'));
    },
  },
};

export const pollingExtension = {
  ...workingExtension(),
  enablePolling: true,
};

export const pollingErrorExtension = {
  ...collapsedDataErrorExtension,
  enablePolling: true,
};