Commit e0e316fc authored by Dave Pisek's avatar Dave Pisek

Add mock-server setup

* Adds settings to jest-config
* Adds mockdata and routes
parent 57b5517b
export const mockIssueLink = {
assignee: null,
assignees: [],
author: { id: 1, name: 'Administrator', username: 'container', state: 'active' },
blocking_issues_count: 0,
closed_at: null,
closed_by: null,
confidential: true,
created_at: '2021-01-10T23:17:23.385Z',
description: 'description',
discussion_locked: null,
downvotes: 0,
due_date: null,
id: 501,
iid: 12,
labels: [],
merge_requests_count: 0,
milestone: null,
project_id: 23,
state: 'opened',
task_completion_status: { count: 0, completed_count: 0 },
time_stats: {
time_estimate: 0,
total_time_spent: 0,
human_time_estimate: null,
human_total_time_spent: null,
},
title: 'Investigate vulnerability: Improper Input Validation in xterm',
updated_at: '2021-01-10T23:17:23.385Z',
upvotes: 0,
user_notes_count: 0,
vulnerability_link_id: 53,
vulnerability_link_type: 'created',
web_url: 'http://gdk.test:3000/security-reports/dependency-list-test/-/issues/12',
weight: null,
};
import defaultRoutes from 'test_helpers/mock_server/routes';
/* eslint-disable global-require */
export default (server) => {
[require('./vulnerabilities')].forEach(({ default: setup }) => {
setup(server);
});
defaultRoutes(server);
};
import { mockIssueLink } from '../../mock_data/vulnerabilities_mock_data';
export default (server) => {
server.get('/api/v4/vulnerabilities/:id/issue_links', () => [mockIssueLink]);
};
......@@ -13,40 +13,3 @@ export const mockVulnerability = {
full_path: '/project_full_path',
},
};
export const mockIssueLink = {
assignee: null,
assignees: [],
author: { id: 1, name: 'Administrator', username: 'container', state: 'active' },
blocking_issues_count: 0,
closed_at: null,
closed_by: null,
confidential: true,
created_at: '2021-01-10T23:17:23.385Z',
description: 'description',
discussion_locked: null,
downvotes: 0,
due_date: null,
id: 501,
iid: 12,
labels: [],
merge_requests_count: 0,
milestone: null,
project_id: 23,
state: 'opened',
task_completion_status: { count: 0, completed_count: 0 },
time_stats: {
time_estimate: 0,
total_time_spent: 0,
human_time_estimate: null,
human_total_time_spent: null,
},
title: 'Investigate vulnerability: Improper Input Validation in xterm',
updated_at: '2021-01-10T23:17:23.385Z',
upvotes: 0,
user_notes_count: 0,
vulnerability_link_id: 53,
vulnerability_link_type: 'created',
web_url: 'http://gdk.test:3000/security-reports/dependency-list-test/-/issues/12',
weight: null,
};
import { mockIssueLink } from './mock_data';
export const createIssueLinksRoute = () => {
mockServer.get('/api/v4/vulnerabilities/:id/issue_links', () => [mockIssueLink]);
};
......@@ -45,7 +45,8 @@ module.exports = (path) => {
'emojis(/.*).json': '<rootDir>/fixtures/emojis$1.json',
'^spec/test_constants$': '<rootDir>/spec/frontend/__helpers__/test_constants',
'^jest/(.*)$': '<rootDir>/spec/frontend/$1',
'test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1',
'^test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1',
'^ee_else_ce_test_helpers(/.*)$': '<rootDir>/spec/frontend_integration/test_helpers$1',
};
const collectCoverageFrom = ['<rootDir>/app/assets/javascripts/**/*.{js,vue}'];
......@@ -56,6 +57,7 @@ module.exports = (path) => {
'^ee(/.*)$': rootDirEE,
'^ee_component(/.*)$': rootDirEE,
'^ee_else_ce(/.*)$': rootDirEE,
'^ee_else_ce_test_helpers(/.*)$': '<rootDir>/ee/spec/frontend_integration/test_helpers$1',
'^ee_jest/(.*)$': '<rootDir>/ee/spec/frontend/$1',
[TEST_FIXTURES_PATTERN]: '<rootDir>/tmp/tests/frontend/fixtures-ee$1',
});
......
import { Server, Model, RestSerializer } from 'miragejs';
import setupRoutes from 'ee_else_ce_test_helpers/mock_server/routes';
import {
getProject,
getEmptyProject,
......@@ -11,7 +12,6 @@ import {
getBlobImage,
getBlobZip,
} from 'test_helpers/fixtures';
import setupRoutes from './routes';
export const createMockServerOptions = () => ({
models: {
......
......@@ -4,4 +4,3 @@ import './setup_axios';
import './setup_serializers';
import './setup_mock_server';
import './setup_testing_library';
import './setup_jest_dom';
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment