diff options
Diffstat (limited to 'spec/frontend_integration/test_helpers/mock_server')
7 files changed, 22 insertions, 12 deletions
diff --git a/spec/frontend_integration/test_helpers/mock_server/index.js b/spec/frontend_integration/test_helpers/mock_server/index.js index 6f090565635..2aebdefaafb 100644 --- a/spec/frontend_integration/test_helpers/mock_server/index.js +++ b/spec/frontend_integration/test_helpers/mock_server/index.js @@ -26,7 +26,7 @@ export const createMockServerOptions = () => ({ }, seeds(schema) { schema.db.loadData({ - files: getRepositoryFiles().map(path => ({ path })), + files: getRepositoryFiles().map((path) => ({ path })), projects: [getProject(), getEmptyProject()], branches: [getBranch()], mergeRequests: getMergeRequests(), diff --git a/spec/frontend_integration/test_helpers/mock_server/routes/404.js b/spec/frontend_integration/test_helpers/mock_server/routes/404.js index 9e08016577b..bc8edba927e 100644 --- a/spec/frontend_integration/test_helpers/mock_server/routes/404.js +++ b/spec/frontend_integration/test_helpers/mock_server/routes/404.js @@ -1,5 +1,5 @@ -export default server => { - ['get', 'post', 'put', 'delete', 'patch'].forEach(method => { +export default (server) => { + ['get', 'post', 'put', 'delete', 'patch'].forEach((method) => { server[method]('*', () => { return new Response(404); }); diff --git a/spec/frontend_integration/test_helpers/mock_server/routes/ci.js b/spec/frontend_integration/test_helpers/mock_server/routes/ci.js index 83951f09c56..6f1593a2cf9 100644 --- a/spec/frontend_integration/test_helpers/mock_server/routes/ci.js +++ b/spec/frontend_integration/test_helpers/mock_server/routes/ci.js @@ -1,6 +1,6 @@ import { getPipelinesEmptyResponse } from 'test_helpers/fixtures'; -export default server => { +export default (server) => { server.get('*/commit/:id/pipelines', () => { return getPipelinesEmptyResponse(); }); diff --git a/spec/frontend_integration/test_helpers/mock_server/routes/graphql.js b/spec/frontend_integration/test_helpers/mock_server/routes/graphql.js index ebb5415ba97..a22763dcb45 100644 --- a/spec/frontend_integration/test_helpers/mock_server/routes/graphql.js +++ b/spec/frontend_integration/test_helpers/mock_server/routes/graphql.js @@ -1,6 +1,6 @@ import { graphqlQuery } from '../graphql'; -export default server => { +export default (server) => { server.post('/api/graphql', (schema, request) => { const batches = JSON.parse(request.requestBody); diff --git a/spec/frontend_integration/test_helpers/mock_server/routes/index.js b/spec/frontend_integration/test_helpers/mock_server/routes/index.js index eea196b5158..e30fecf2f06 100644 --- a/spec/frontend_integration/test_helpers/mock_server/routes/index.js +++ b/spec/frontend_integration/test_helpers/mock_server/routes/index.js @@ -1,5 +1,5 @@ /* eslint-disable global-require */ -export default server => { +export default (server) => { [ require('./graphql'), require('./projects'), diff --git a/spec/frontend_integration/test_helpers/mock_server/routes/projects.js b/spec/frontend_integration/test_helpers/mock_server/routes/projects.js index f4d8ce4b23d..de37aa98eee 100644 --- a/spec/frontend_integration/test_helpers/mock_server/routes/projects.js +++ b/spec/frontend_integration/test_helpers/mock_server/routes/projects.js @@ -1,6 +1,6 @@ import { withKeys } from 'test_helpers/utils/obj'; -export default server => { +export default (server) => { server.get('/api/v4/projects/:id', (schema, request) => { const { id } = request.params; diff --git a/spec/frontend_integration/test_helpers/mock_server/routes/repository.js b/spec/frontend_integration/test_helpers/mock_server/routes/repository.js index 166c0cc32db..ba36463cad8 100644 --- a/spec/frontend_integration/test_helpers/mock_server/routes/repository.js +++ b/spec/frontend_integration/test_helpers/mock_server/routes/repository.js @@ -1,9 +1,9 @@ import { createNewCommit, createCommitIdGenerator } from 'test_helpers/factories'; -export default server => { +export default (server) => { const commitIdGenerator = createCommitIdGenerator(); - server.get('/api/v4/projects/:id/repository/branches', schema => { + server.get('/api/v4/projects/:id/repository/branches', (schema) => { return schema.db.branches; }); @@ -15,7 +15,7 @@ export default server => { return branch.attrs; }); - server.get('*/-/files/:id', schema => { + server.get('*/-/files/:id', (schema) => { return schema.db.files.map(({ path }) => path); }); @@ -37,13 +37,23 @@ export default server => { ); const branch = schema.branches.findBy({ name: branchName }); + const prevCommit = branch + ? branch.attrs.commit + : schema.branches.findBy({ name: 'master' }).attrs.commit; const commit = { - ...createNewCommit({ id: commitIdGenerator.next(), message }, branch.attrs.commit), + ...createNewCommit({ id: commitIdGenerator.next(), message }, prevCommit), __actions: actions, }; - branch.update({ commit }); + if (branch) { + branch.update({ commit }); + } else { + schema.branches.create({ + name: branchName, + commit, + }); + } return commit; }); |