mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-22 15:51:59 +00:00
Merge pull request #21755 from overleaf/jpa-history-initialize-project
[history-v1] tests: use createEmptyProject helper consistently GitOrigin-RevId: 80d979091d80c53c780919700561849d9703368e
This commit is contained in:
parent
76c7c3e28e
commit
61c7c728ad
4 changed files with 33 additions and 33 deletions
|
@ -9,6 +9,7 @@ exports.paths = {
|
|||
operationId: 'initializeProject',
|
||||
tags: ['Project'],
|
||||
description: 'Initialize project.',
|
||||
consumes: ['application/json'],
|
||||
parameters: [
|
||||
{
|
||||
name: 'body',
|
||||
|
|
|
@ -11,6 +11,7 @@ const expectResponse = require('./support/expect_response')
|
|||
const testServer = require('./support/test_server')
|
||||
|
||||
const core = require('overleaf-editor-core')
|
||||
const testProjects = require('./support/test_projects')
|
||||
const Change = core.Change
|
||||
const ChunkResponse = core.ChunkResponse
|
||||
const File = core.File
|
||||
|
@ -637,10 +638,10 @@ describe('history import', function () {
|
|||
|
||||
let testProjectId
|
||||
|
||||
return BPromise.resolve(basicAuthClient.apis.Project.initializeProject())
|
||||
.then(response => {
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
testProjectId = response.obj.projectId
|
||||
return testProjects
|
||||
.createEmptyProject()
|
||||
.then(projectId => {
|
||||
testProjectId = projectId
|
||||
expect(testProjectId).to.be.a('string')
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -705,10 +706,10 @@ describe('history import', function () {
|
|||
|
||||
let testProjectId
|
||||
|
||||
return basicAuthClient.apis.Project.initializeProject()
|
||||
.then(response => {
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
testProjectId = response.obj.projectId
|
||||
return testProjects
|
||||
.createEmptyProject()
|
||||
.then(projectId => {
|
||||
testProjectId = projectId
|
||||
expect(testProjectId).to.be.a('string')
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -756,10 +757,10 @@ describe('history import', function () {
|
|||
|
||||
let testProjectId
|
||||
|
||||
return basicAuthClient.apis.Project.initializeProject()
|
||||
.then(response => {
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
testProjectId = response.obj.projectId
|
||||
return testProjects
|
||||
.createEmptyProject()
|
||||
.then(projectId => {
|
||||
testProjectId = projectId
|
||||
expect(testProjectId).to.be.a('string')
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -802,10 +803,9 @@ describe('history import', function () {
|
|||
})
|
||||
|
||||
it("returns unprocessable if end_version isn't provided", function () {
|
||||
return basicAuthClient.apis.Project.initializeProject()
|
||||
.then(response => {
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
const projectId = response.obj.projectId
|
||||
return testProjects
|
||||
.createEmptyProject()
|
||||
.then(projectId => {
|
||||
expect(projectId).to.be.a('string')
|
||||
return projectId
|
||||
})
|
||||
|
@ -828,11 +828,8 @@ describe('history import', function () {
|
|||
})
|
||||
|
||||
it('returns unprocessable if return_snapshot is invalid', function () {
|
||||
return basicAuthClient.apis.Project.initializeProject()
|
||||
.then(response => {
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
return response.obj.projectId
|
||||
})
|
||||
return testProjects
|
||||
.createEmptyProject()
|
||||
.then(projectId => {
|
||||
// Import changes
|
||||
return basicAuthClient.apis.ProjectImport.importChanges1({
|
||||
|
|
|
@ -22,23 +22,16 @@ const {
|
|||
Change,
|
||||
AddFileOperation,
|
||||
} = require('overleaf-editor-core')
|
||||
const testProjects = require('./support/test_projects')
|
||||
|
||||
describe('project controller', function () {
|
||||
beforeEach(cleanup.everything)
|
||||
beforeEach(fixtures.create)
|
||||
|
||||
describe('initializeProject', function () {
|
||||
let initializeProject
|
||||
|
||||
before(function () {
|
||||
initializeProject =
|
||||
testServer.basicAuthClient.apis.Project.initializeProject
|
||||
})
|
||||
|
||||
it('can initialize a new project', async function () {
|
||||
const response = await initializeProject()
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
expect(response.obj.projectId).to.be.a('string')
|
||||
const projectId = await testProjects.createEmptyProject()
|
||||
expect(projectId).to.be.a('string')
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -5,9 +5,18 @@ const assert = require('../../../../../storage/lib/assert')
|
|||
|
||||
const testServer = require('./test_server')
|
||||
|
||||
exports.createEmptyProject = function () {
|
||||
/**
|
||||
* Without a provided history id, a new one will get generated.
|
||||
* The history id could either be a mongo id, or a postgres id.
|
||||
*
|
||||
* @param {string} [existingHistoryId]
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
exports.createEmptyProject = function (existingHistoryId) {
|
||||
return BPromise.resolve(
|
||||
testServer.basicAuthClient.apis.Project.initializeProject()
|
||||
testServer.basicAuthClient.apis.Project.initializeProject({
|
||||
body: { projectId: existingHistoryId },
|
||||
})
|
||||
).then(response => {
|
||||
expect(response.status).to.equal(HTTPStatus.OK)
|
||||
const { projectId } = response.obj
|
||||
|
|
Loading…
Reference in a new issue