Files
payloadcms/test/custom-graphql/int.spec.ts
Dan Ribbens 9ceee8ea3c chore: ci changes to add compatibility for mongodb alternates (#13898)
- Adds documentdb and cosmosdb to CI test matrix
- Adds missing generateDatabaseAdapter configs
- Adjust generateDatabaseAdapter firestore config to make it pure to the
compatibilityOptions we provide as an export

Creating as draft because I expect a few tests to fail based on previous
comments.

---------

Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com>
2025-10-06 16:48:02 -04:00

68 lines
2.0 KiB
TypeScript

import type { Payload } from 'payload'
import path from 'path'
import { fileURLToPath } from 'url'
import type { NextRESTClient } from '../helpers/NextRESTClient.js'
import { initPayloadInt } from '../helpers/initPayloadInt.js'
let restClient: NextRESTClient
let payload: Payload
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
describe('Custom GraphQL', () => {
beforeAll(async () => {
;({ payload, restClient } = await initPayloadInt(dirname))
})
afterAll(async () => {
await payload.destroy()
})
if (
!['cosmosdb', 'firestore', 'sqlite', 'sqlite-uuid'].includes(process.env.PAYLOAD_DATABASE || '')
) {
describe('Isolated Transaction ID', () => {
it('should isolate transaction IDs between queries in the same request', async () => {
const query = `query {
TransactionID1
TransactionID2
}`
const { data } = await restClient
.GRAPHQL_POST({
body: JSON.stringify({ query }),
})
.then((res) => res.json())
// either no transactions at all or they are different
expect(
(data.TransactionID2 === null && data.TransactionID1 === null) ||
data.TransactionID2 !== data.TransactionID1,
).toBe(true)
})
it('should isolate transaction IDs between mutations in the same request', async () => {
const query = `mutation {
MutateTransactionID1
MutateTransactionID2
}`
const { data } = await restClient
.GRAPHQL_POST({
body: JSON.stringify({ query }),
})
.then((res) => res.json())
// either no transactions at all or they are different
expect(
(data.MutateTransactionID2 === null && data.MutateTransactionID1 === null) ||
data.MutateTransactionID2 !== data.MutateTransactionID1,
).toBe(true)
})
})
} else {
it('should not run isolated transaction ID tests for sqlite/firestore/cosmosdb', () => {
expect(true).toBe(true)
})
}
})