fix: missing find collection versions REST endpoint (#10573)

The `/api/:collection/versions` endpoint was missing, added a test to
prevent regressions like this.
This commit is contained in:
Sasha
2025-01-14 20:35:32 +02:00
committed by GitHub
parent 16ad7a671f
commit 120735c55c
2 changed files with 20 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ import { duplicateHandler } from './duplicate.js'
import { findHandler } from './find.js' import { findHandler } from './find.js'
import { findByIDHandler } from './findByID.js' import { findByIDHandler } from './findByID.js'
import { findVersionByIDHandler } from './findVersionByID.js' import { findVersionByIDHandler } from './findVersionByID.js'
import { findVersionsHandler } from './findVersions.js'
import { getFileHandler } from './getFile.js' import { getFileHandler } from './getFile.js'
import { previewHandler } from './preview.js' import { previewHandler } from './preview.js'
import { restoreVersionHandler } from './restoreVersion.js' import { restoreVersionHandler } from './restoreVersion.js'
@@ -45,6 +46,11 @@ export const defaultCollectionEndpoints: Endpoint[] = [
method: 'post', method: 'post',
path: '/access/:id?', path: '/access/:id?',
}, },
{
handler: findVersionsHandler,
method: 'get',
path: '/versions',
},
{ {
handler: duplicateHandler, handler: duplicateHandler,
method: 'post', method: 'post',

View File

@@ -1436,6 +1436,20 @@ describe('Versions', () => {
}) })
}) })
describe('Collections - REST', () => {
it('sholud query versions', async () => {
const response = await restClient.GET(`/${collection}/versions`)
expect(response.status).toBe(200)
const json = await response.json()
expect(json.docs[0].parent).toBe(collectionLocalPostID)
const responseByID = await restClient.GET(`/${collection}/versions/${json.docs[0].id}`)
expect(responseByID.status).toBe(200)
const jsonByID = await responseByID.json()
expect(jsonByID.parent).toBe(collectionLocalPostID)
})
})
describe('Globals - Local', () => { describe('Globals - Local', () => {
beforeEach(async () => { beforeEach(async () => {
const title2 = 'Here is an updated global title in EN' const title2 = 'Here is an updated global title in EN'