mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05: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',
|
operationId: 'initializeProject',
|
||||||
tags: ['Project'],
|
tags: ['Project'],
|
||||||
description: 'Initialize project.',
|
description: 'Initialize project.',
|
||||||
|
consumes: ['application/json'],
|
||||||
parameters: [
|
parameters: [
|
||||||
{
|
{
|
||||||
name: 'body',
|
name: 'body',
|
||||||
|
|
|
@ -11,6 +11,7 @@ const expectResponse = require('./support/expect_response')
|
||||||
const testServer = require('./support/test_server')
|
const testServer = require('./support/test_server')
|
||||||
|
|
||||||
const core = require('overleaf-editor-core')
|
const core = require('overleaf-editor-core')
|
||||||
|
const testProjects = require('./support/test_projects')
|
||||||
const Change = core.Change
|
const Change = core.Change
|
||||||
const ChunkResponse = core.ChunkResponse
|
const ChunkResponse = core.ChunkResponse
|
||||||
const File = core.File
|
const File = core.File
|
||||||
|
@ -637,10 +638,10 @@ describe('history import', function () {
|
||||||
|
|
||||||
let testProjectId
|
let testProjectId
|
||||||
|
|
||||||
return BPromise.resolve(basicAuthClient.apis.Project.initializeProject())
|
return testProjects
|
||||||
.then(response => {
|
.createEmptyProject()
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
.then(projectId => {
|
||||||
testProjectId = response.obj.projectId
|
testProjectId = projectId
|
||||||
expect(testProjectId).to.be.a('string')
|
expect(testProjectId).to.be.a('string')
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -705,10 +706,10 @@ describe('history import', function () {
|
||||||
|
|
||||||
let testProjectId
|
let testProjectId
|
||||||
|
|
||||||
return basicAuthClient.apis.Project.initializeProject()
|
return testProjects
|
||||||
.then(response => {
|
.createEmptyProject()
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
.then(projectId => {
|
||||||
testProjectId = response.obj.projectId
|
testProjectId = projectId
|
||||||
expect(testProjectId).to.be.a('string')
|
expect(testProjectId).to.be.a('string')
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -756,10 +757,10 @@ describe('history import', function () {
|
||||||
|
|
||||||
let testProjectId
|
let testProjectId
|
||||||
|
|
||||||
return basicAuthClient.apis.Project.initializeProject()
|
return testProjects
|
||||||
.then(response => {
|
.createEmptyProject()
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
.then(projectId => {
|
||||||
testProjectId = response.obj.projectId
|
testProjectId = projectId
|
||||||
expect(testProjectId).to.be.a('string')
|
expect(testProjectId).to.be.a('string')
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -802,10 +803,9 @@ describe('history import', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns unprocessable if end_version isn't provided", function () {
|
it("returns unprocessable if end_version isn't provided", function () {
|
||||||
return basicAuthClient.apis.Project.initializeProject()
|
return testProjects
|
||||||
.then(response => {
|
.createEmptyProject()
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
.then(projectId => {
|
||||||
const projectId = response.obj.projectId
|
|
||||||
expect(projectId).to.be.a('string')
|
expect(projectId).to.be.a('string')
|
||||||
return projectId
|
return projectId
|
||||||
})
|
})
|
||||||
|
@ -828,11 +828,8 @@ describe('history import', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns unprocessable if return_snapshot is invalid', function () {
|
it('returns unprocessable if return_snapshot is invalid', function () {
|
||||||
return basicAuthClient.apis.Project.initializeProject()
|
return testProjects
|
||||||
.then(response => {
|
.createEmptyProject()
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
|
||||||
return response.obj.projectId
|
|
||||||
})
|
|
||||||
.then(projectId => {
|
.then(projectId => {
|
||||||
// Import changes
|
// Import changes
|
||||||
return basicAuthClient.apis.ProjectImport.importChanges1({
|
return basicAuthClient.apis.ProjectImport.importChanges1({
|
||||||
|
|
|
@ -22,23 +22,16 @@ const {
|
||||||
Change,
|
Change,
|
||||||
AddFileOperation,
|
AddFileOperation,
|
||||||
} = require('overleaf-editor-core')
|
} = require('overleaf-editor-core')
|
||||||
|
const testProjects = require('./support/test_projects')
|
||||||
|
|
||||||
describe('project controller', function () {
|
describe('project controller', function () {
|
||||||
beforeEach(cleanup.everything)
|
beforeEach(cleanup.everything)
|
||||||
beforeEach(fixtures.create)
|
beforeEach(fixtures.create)
|
||||||
|
|
||||||
describe('initializeProject', function () {
|
describe('initializeProject', function () {
|
||||||
let initializeProject
|
|
||||||
|
|
||||||
before(function () {
|
|
||||||
initializeProject =
|
|
||||||
testServer.basicAuthClient.apis.Project.initializeProject
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can initialize a new project', async function () {
|
it('can initialize a new project', async function () {
|
||||||
const response = await initializeProject()
|
const projectId = await testProjects.createEmptyProject()
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
expect(projectId).to.be.a('string')
|
||||||
expect(response.obj.projectId).to.be.a('string')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,18 @@ const assert = require('../../../../../storage/lib/assert')
|
||||||
|
|
||||||
const testServer = require('./test_server')
|
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(
|
return BPromise.resolve(
|
||||||
testServer.basicAuthClient.apis.Project.initializeProject()
|
testServer.basicAuthClient.apis.Project.initializeProject({
|
||||||
|
body: { projectId: existingHistoryId },
|
||||||
|
})
|
||||||
).then(response => {
|
).then(response => {
|
||||||
expect(response.status).to.equal(HTTPStatus.OK)
|
expect(response.status).to.equal(HTTPStatus.OK)
|
||||||
const { projectId } = response.obj
|
const { projectId } = response.obj
|
||||||
|
|
Loading…
Reference in a new issue