Explorar el Código

Merge pull request #32730 from overleaf/mj-conversion-compiler-luatex

[web] Use LuaLaTeX compiler for converted documents

GitOrigin-RevId: e9a0d2020ce40a0ada16eb9afae8b1a08933db49
Mathias Jakobsen hace 6 meses
padre
commit
78c81cd0d5

+ 2 - 0
services/web/app/src/Features/Uploads/ProjectUploadController.mjs

@@ -15,6 +15,7 @@ import lodash from 'lodash'
 import { expressify } from '@overleaf/promise-utils'
 import { DuplicateNameError, FileTooLargeError } from '../Errors/Errors.js'
 import DocumentConversionManager from './DocumentConversionManager.mjs'
+import ProjectOptionsHandler from '../Project/ProjectOptionsHandler.mjs'
 
 const defaultsDeep = lodash.defaultsDeep
 
@@ -191,6 +192,7 @@ async function importDocx(req, res, next) {
           name,
           archivePath
         )
+      await ProjectOptionsHandler.promises.setCompiler(project._id, 'lualatex')
       res.json({ success: true, project_id: project._id })
     } finally {
       await fsPromises.unlink(archivePath).catch(() => {})

+ 18 - 0
services/web/test/unit/src/Uploads/ProjectUploadController.test.mjs

@@ -41,6 +41,11 @@ describe('ProjectUploadController', function () {
     ctx.EditorController = {
       promises: {},
     }
+    ctx.ProjectOptionsHandler = {
+      promises: {
+        setCompiler: sinon.stub().resolves(),
+      },
+    }
     ctx.DocumentConversionManager = {
       promises: {
         convertDocxToLaTeXZipArchive: sinon.stub(),
@@ -93,6 +98,13 @@ describe('ProjectUploadController', function () {
       default: ctx.EditorController,
     }))
 
+    vi.doMock(
+      '../../../../app/src/Features/Project/ProjectOptionsHandler',
+      () => ({
+        default: ctx.ProjectOptionsHandler,
+      })
+    )
+
     vi.doMock(
       '../../../../app/src/Features/Uploads/DocumentConversionManager.mjs',
       () => ({
@@ -477,6 +489,12 @@ describe('ProjectUploadController', function () {
         ).to.have.been.calledWith(ctx.user_id, 'file', ctx.archivePath)
       })
 
+      it('should set the compiler to lualatex', function (ctx) {
+        expect(
+          ctx.ProjectOptionsHandler.promises.setCompiler
+        ).to.have.been.calledWith('new-project-id', 'lualatex')
+      })
+
       it('should unlink the archive after creating the project', function (ctx) {
         expect(ctx.fsPromises.unlink).to.have.been.calledWith(ctx.archivePath)
       })