debian-mirror-gitlab/spec/frontend/vue_merge_request_widget/test_extensions.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

193 lines
4.8 KiB
JavaScript
Raw Normal View History

2022-01-26 12:08:38 +05:30
import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants';
2022-06-21 17:19:12 +05:30
export const workingExtension = (shouldCollapse = true) => ({
2022-01-26 12:08:38 +05:30
name: 'WidgetTestExtension',
props: ['targetProjectFullPath'],
expandEvent: 'test_expand_event',
2022-07-23 23:45:48 +05:30
i18n: {
loading: 'Test extension loading...',
},
2022-01-26 12:08:38 +05:30
computed: {
2022-07-23 23:45:48 +05:30
summary({ count, targetProjectFullPath } = {}) {
2022-01-26 12:08:38 +05:30
return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
},
2022-07-23 23:45:48 +05:30
statusIcon({ count } = {}) {
2022-01-26 12:08:38 +05:30
return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
},
2022-06-21 17:19:12 +05:30
shouldCollapse() {
return shouldCollapse;
},
2022-01-26 12:08:38 +05:30
},
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' }],
},
]);
},
},
2022-06-21 17:19:12 +05:30
});
2022-01-26 12:08:38 +05:30
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'));
},
},
};
2022-03-02 08:16:31 +05:30
export const pollingExtension = {
2022-06-21 17:19:12 +05:30
...workingExtension(),
2022-03-02 08:16:31 +05:30
enablePolling: true,
};
2022-08-13 15:12:31 +05:30
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' }],
},
},
]);
},
},
};
2022-07-23 23:45:48 +05:30
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;
},
},
});
2022-03-02 08:16:31 +05:30
export const pollingErrorExtension = {
...collapsedDataErrorExtension,
enablePolling: true,
};