diff --git a/services/web/app/src/Features/Project/ProjectCreationHandler.js b/services/web/app/src/Features/Project/ProjectCreationHandler.js index be9dff61f3..be8729cc0a 100644 --- a/services/web/app/src/Features/Project/ProjectCreationHandler.js +++ b/services/web/app/src/Features/Project/ProjectCreationHandler.js @@ -15,7 +15,6 @@ const path = require('path') const { callbackify } = require('util') const _ = require('underscore') const AnalyticsManager = require('../Analytics/AnalyticsManager') -const SplitTestV2Handler = require('../SplitTests/SplitTestV2Handler') const MONTH_NAMES = [ 'January', @@ -31,7 +30,6 @@ const MONTH_NAMES = [ 'November', 'December', ] -const EXAMPLE_PROJECT_SPLITTEST_ID = 'example-project-v3' async function createBlankProject(ownerId, projectName, attributes = {}) { const isImport = attributes && attributes.overleaf @@ -61,76 +59,39 @@ async function createProjectFromSnippet(ownerId, projectName, docLines) { async function createBasicProject(ownerId, projectName) { const project = await _createBlankProject(ownerId, projectName) + + const docLines = await _buildTemplate('mainbasic.tex', ownerId, projectName) + await _createRootDoc(project, ownerId, docLines) + AnalyticsManager.recordEvent(ownerId, 'project-created', { projectId: project._id, }) - const docLines = await _buildTemplate('mainbasic.tex', ownerId, projectName) - await _createRootDoc(project, ownerId, docLines) + return project } async function createExampleProject(ownerId, projectName) { const project = await _createBlankProject(ownerId, projectName) - const assignment = await SplitTestV2Handler.promises.getAssignment( - ownerId, - EXAMPLE_PROJECT_SPLITTEST_ID - ) - - if (assignment.variant === 'example-frog') { - await _addSplitTestExampleProjectFiles(ownerId, projectName, project) - } else { - await _addDefaultExampleProjectFiles(ownerId, projectName, project) - } + await _addExampleProjectFiles(ownerId, projectName, project) AnalyticsManager.recordEvent(ownerId, 'project-created', { projectId: project._id, - ...assignment.analytics.segmentation, }) return project } -async function _addDefaultExampleProjectFiles(ownerId, projectName, project) { - const mainDocLines = await _buildTemplate('main.tex', ownerId, projectName) - await _createRootDoc(project, ownerId, mainDocLines) - - const referenceDocLines = await _buildTemplate( - 'references.bib', - ownerId, - projectName - ) - await ProjectEntityUpdateHandler.promises.addDoc( - project._id, - project.rootFolder[0]._id, - 'references.bib', - referenceDocLines, - ownerId - ) - - const universePath = path.resolve( - __dirname + '/../../../templates/project_files/universe.jpg' - ) - await ProjectEntityUpdateHandler.promises.addFile( - project._id, - project.rootFolder[0]._id, - 'universe.jpg', - universePath, - null, - ownerId - ) -} - -async function _addSplitTestExampleProjectFiles(ownerId, projectName, project) { +async function _addExampleProjectFiles(ownerId, projectName, project) { const mainDocLines = await _buildTemplate( - 'test-example-project/main.tex', + 'example-project/main.tex', ownerId, projectName ) await _createRootDoc(project, ownerId, mainDocLines) const bibDocLines = await _buildTemplate( - 'test-example-project/sample.bib', + 'example-project/sample.bib', ownerId, projectName ) @@ -143,8 +104,7 @@ async function _addSplitTestExampleProjectFiles(ownerId, projectName, project) { ) const frogPath = path.resolve( - __dirname + - '/../../../templates/project_files/test-example-project/frog.jpg' + __dirname + '/../../../templates/project_files/example-project/frog.jpg' ) await ProjectEntityUpdateHandler.promises.addFile( project._id, diff --git a/services/web/app/templates/project_files/test-example-project/frog.jpg b/services/web/app/templates/project_files/example-project/frog.jpg similarity index 100% rename from services/web/app/templates/project_files/test-example-project/frog.jpg rename to services/web/app/templates/project_files/example-project/frog.jpg diff --git a/services/web/app/templates/project_files/test-example-project/main.tex b/services/web/app/templates/project_files/example-project/main.tex similarity index 100% rename from services/web/app/templates/project_files/test-example-project/main.tex rename to services/web/app/templates/project_files/example-project/main.tex diff --git a/services/web/app/templates/project_files/test-example-project/sample.bib b/services/web/app/templates/project_files/example-project/sample.bib similarity index 100% rename from services/web/app/templates/project_files/test-example-project/sample.bib rename to services/web/app/templates/project_files/example-project/sample.bib diff --git a/services/web/scripts/create_project.js b/services/web/scripts/create_project.js index 0220c9ce9e..86cda94764 100644 --- a/services/web/scripts/create_project.js +++ b/services/web/scripts/create_project.js @@ -45,30 +45,34 @@ async function _createRootDoc(project, ownerId, docLines) { } async function _addDefaultExampleProjectFiles(ownerId, projectName, project) { - const mainDocLines = await _buildTemplate('main.tex', ownerId, projectName) + const mainDocLines = await _buildTemplate( + 'example-project/main.tex', + ownerId, + projectName + ) await _createRootDoc(project, ownerId, mainDocLines) - const referenceDocLines = await _buildTemplate( - 'references.bib', + const bibDocLines = await _buildTemplate( + 'example-project/sample.bib', ownerId, projectName ) await ProjectEntityUpdateHandler.promises.addDoc( project._id, project.rootFolder[0]._id, - 'references.bib', - referenceDocLines, + 'sample.bib', + bibDocLines, ownerId ) - const universePath = path.resolve( - __dirname + '/../app/templates/project_files/universe.jpg' + const frogPath = path.resolve( + __dirname + '/../app/templates/project_files/example-project/frog.jpg' ) await ProjectEntityUpdateHandler.promises.addFile( project._id, project.rootFolder[0]._id, - 'universe.jpg', - universePath, + 'frog.jpg', + frogPath, null, ownerId ) diff --git a/services/web/test/acceptance/src/ProjectDuplicateNameTests.js b/services/web/test/acceptance/src/ProjectDuplicateNameTests.js index f7fb1ae0fc..5c58dbee48 100644 --- a/services/web/test/acceptance/src/ProjectDuplicateNameTests.js +++ b/services/web/test/acceptance/src/ProjectDuplicateNameTests.js @@ -65,11 +65,11 @@ describe('ProjectDuplicateNames', function () { ) this.refBibDoc = _.find( project.rootFolder[0].docs, - doc => doc.name === 'references.bib' + doc => doc.name === 'sample.bib' ) this.imageFile = _.find( project.rootFolder[0].fileRefs, - file => file.name === 'universe.jpg' + file => file.name === 'frog.jpg' ) this.rootFolderId = project.rootFolder[0]._id.toString() // create a folder called 'testfolder' @@ -181,7 +181,7 @@ describe('ProjectDuplicateNames', function () { { uri: `/project/${this.example_project_id}/doc`, json: { - name: 'universe.jpg', + name: 'frog.jpg', parent_folder_id: this.rootFolderId, }, }, @@ -203,7 +203,7 @@ describe('ProjectDuplicateNames', function () { { uri: `/project/${this.example_project_id}/folder`, json: { - name: 'universe.jpg', + name: 'frog.jpg', parent_folder_id: this.rootFolderId, }, }, @@ -227,7 +227,7 @@ describe('ProjectDuplicateNames', function () { json: true, qs: { folder_id: this.rootFolderId, - qqfilename: 'universe.jpg', + qqfilename: 'frog.jpg', }, formData: { qqfile: { @@ -235,7 +235,7 @@ describe('ProjectDuplicateNames', function () { Path.resolve(__dirname + '/../files/1pixel.png') ), options: { - filename: 'universe.jpg', + filename: 'frog.jpg', contentType: 'image/jpeg', }, }, @@ -310,7 +310,7 @@ describe('ProjectDuplicateNames', function () { json: true, qs: { folder_id: this.rootFolderId, - qqfilename: 'universe.jpg', + qqfilename: 'frog.jpg', }, formData: { qqfile: { @@ -409,7 +409,7 @@ describe('ProjectDuplicateNames', function () { { uri: `/project/${this.example_project_id}/doc/${this.refBibDoc._id}/rename`, json: { - name: 'universe.jpg', + name: 'frog.jpg', }, }, (err, res, body) => { @@ -430,7 +430,7 @@ describe('ProjectDuplicateNames', function () { { uri: `/project/${this.example_project_id}/folder/${this.testFolderId}/rename`, json: { - name: 'universe.jpg', + name: 'frog.jpg', }, }, (err, res, body) => { @@ -451,7 +451,7 @@ describe('ProjectDuplicateNames', function () { { uri: `/project/${this.example_project_id}/file/${this.imageFile._id}/rename`, json: { - name: 'universe.jpg', + name: 'frog.jpg', }, }, (err, res, body) => { @@ -547,7 +547,7 @@ describe('ProjectDuplicateNames', function () { { uri: `/project/${this.example_project_id}/doc`, json: { - name: 'universe.jpg', + name: 'frog.jpg', parent_folder_id: this.testFolderId, }, },