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

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

export const workingExtension = (shouldCollapse = true) => ({
  name: 'WidgetTestExtension',
  props: ['targetProjectFullPath'],
  expandEvent: 'test_expand_event',
  i18n: {
    loading: 'Test extension loading...',
  },
  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 pollingFullDataExtension = {
  ...workingExtension(),
  enableExpandedPolling: true,
  methods: {
    fetchCollapsedData({ targetProjectFullPath }) {
      return Promise.resolve({ targetProjectFullPath, count: 1 });
    },
    fetchFullData() {
      return Promise.resolve([
        {
          headers: { 'poll-interval': 0 },
          status: 200,
          data: {
            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 fullReportExtension = {
  ...workingExtension(),
  computed: {
    ...workingExtension().computed,
    tertiaryButtons() {
      return [
        {
          text: 'test',
          href: `testref`,
          target: '_blank',
          fullReport: true,
        },
      ];
    },
  },
};

export const noTelemetryExtension = {
  ...fullReportExtension,
  telemetry: false,
};

export const multiPollingExtension = (endpointsToBePolled) => ({
  name: 'WidgetTestMultiPollingExtension',
  props: [],
  i18n: {
    loading: 'Test extension loading...',
  },
  computed: {
    summary(data) {
      return `Multi polling test extension reports: ${data?.[0]?.reports}, count: ${data.length}`;
    },
    statusIcon(data) {
      return data?.[0]?.reports === 'parsed' ? EXTENSION_ICONS.success : EXTENSION_ICONS.warning;
    },
  },
  enablePolling: true,
  methods: {
    fetchMultiData() {
      return endpointsToBePolled;
    },
  },
});

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