mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
[document-updater] adopt strict zod types and extend test coverage (#36077)
* [document-updater] adopt strict zod types and extend test coverage * [saas-e2e] add test for project restore with binary and linked file GitOrigin-RevId: a8e45bd1e46b6ac8a293da24c8b8ad7b236fd9bd
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
let MockProjectHistoryApi
|
||||
const { expressify } = require('@overleaf/promise-utils')
|
||||
const express = require('express')
|
||||
const {
|
||||
handleValidationError,
|
||||
parseReq,
|
||||
z,
|
||||
zz,
|
||||
} = require('@overleaf/validation-tools')
|
||||
const app = express()
|
||||
|
||||
const flushProjectSchema = z.object({
|
||||
params: z.strictObject({
|
||||
project_id: zz.objectId(),
|
||||
}),
|
||||
})
|
||||
|
||||
module.exports = MockProjectHistoryApi = {
|
||||
async flushProject(docId) {},
|
||||
|
||||
@@ -10,8 +22,9 @@ module.exports = MockProjectHistoryApi = {
|
||||
app.post(
|
||||
'/project/:project_id/flush',
|
||||
expressify(async (req, res, next) => {
|
||||
const { params } = parseReq(req, flushProjectSchema)
|
||||
try {
|
||||
await this.flushProject(req.params.project_id)
|
||||
await this.flushProject(params.project_id)
|
||||
return res.sendStatus(204)
|
||||
} catch (error) {
|
||||
return res.sendStatus(500)
|
||||
@@ -19,6 +32,8 @@ module.exports = MockProjectHistoryApi = {
|
||||
})
|
||||
)
|
||||
|
||||
app.use(handleValidationError)
|
||||
|
||||
return app.listen(3054, error => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user