test: plugin-sentry suite (#4040)

This commit is contained in:
Elliot DeNolf
2023-11-07 13:51:40 -05:00
committed by GitHub
parent 2abb46f4f1
commit 55c38a8934
15 changed files with 54 additions and 241 deletions

View File

@@ -0,0 +1,15 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const Posts: CollectionConfig = {
slug: 'posts',
access: {
create: () => false,
read: () => true,
},
fields: [
{
name: 'text',
type: 'text',
},
],
}

View File

@@ -0,0 +1,16 @@
import type { CollectionConfig } from '../../../packages/payload/src/collections/config/types'
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
access: {
read: () => true,
},
fields: [
// Email added by default
// Add more fields as needed
],
}

View File

@@ -0,0 +1,32 @@
import { sentry } from '../../packages/plugin-sentry/src'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults'
import { devUser } from '../credentials'
import { Posts } from './collections/Posts'
import { Users } from './collections/Users'
export default buildConfigWithDefaults({
collections: [Posts, Users],
plugins: [
sentry({
dsn: 'https://61edebe5ee6d4d38a9d6459c7323d777@o4505289711681536.ingest.sentry.io/4505357688242176',
options: {
init: {
debug: true,
},
requestHandler: {
serverName: false,
},
captureErrors: [400, 403, 404],
},
}),
],
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
},
})

View File

@@ -0,0 +1,11 @@
import { initPayloadTest } from '../helpers/configHelpers'
describe('plugin-sentry', () => {
beforeAll(async () => {
await initPayloadTest({ __dirname, init: { local: true } })
})
describe('tests', () => {
it.todo('plugin-sentry tests')
})
})