Skip to content

test(e2e): add missing webhook tests #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/stupid-rabbits-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
114 changes: 114 additions & 0 deletions packages/core/manifest/e2e/assets/mock-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,120 @@ entities:
delete:
- access: public

# Testing webhooks
WebhookTester:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e
headers:
x-test-header: 'e2e-test'
policies: &publicAccess
create:
- access: public
read:
- access: public
update:
- access: public
delete:
- access: public

WebhookGet:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e
method: GET
policies: *publicAccess

WebhookPut:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e
method: PUT
policies: *publicAccess

WebhookPatch:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e
method: PATCH
policies: *publicAccess

WebhookDelete:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e
method: DELETE
policies: *publicAccess

WebhookEnv:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e-from-env
method: POST
policies: *publicAccess

WebhookFail:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9998/this-will-fail
policies: *publicAccess

WebhookEvents:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e
afterUpdate:
- url: http://localhost:9999/webhooks-e2e
afterDelete:
- url: http://localhost:9999/webhooks-e2e
policies: *publicAccess

WebhookWithHeaders:
properties:
- name
hooks:
afterCreate:
- url: http://localhost:9999/webhooks-e2e-from-env
headers:
Authorization: 'Bearer ${TOKEN_SECRET_KEY}'
policies: *publicAccess

WebhookSinglePage:
single: true
nameSingular: WebhookSingle
slug: webhook-single
properties:
- { name: title, type: string }
hooks:
afterUpdate:
- url: http://localhost:9999/webhooks-e2e
policies:
create:
- access: public
read:
- access: public
update:
- access: public
delete:
- access: public


# Testing endpoints
endpoints:
basicEndpoint:
Expand Down
15 changes: 9 additions & 6 deletions packages/core/manifest/e2e/jest.mysql-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ beforeAll(async () => {
process.env.DB_DATABASE = 'test'

// Start the NestJS application mocking some services.
const yamlService = new YamlService()
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule]
})
.overrideProvider(YamlService)
.useValue({
load: () =>
load(
fs.readFileSync(
`${process.cwd()}/e2e/assets/mock-backend.yml`,
'utf8'
)
load: () => {
const fileContent = fs.readFileSync(
`${process.cwd()}/e2e/assets/mock-backend.yml`,
'utf8'
)
const interpolatedContent =
yamlService.interpolateDotEnvVariables(fileContent)
return load(interpolatedContent)
}
})
.compile()

Expand Down
15 changes: 9 additions & 6 deletions packages/core/manifest/e2e/jest.pg-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,21 @@ beforeAll(async () => {
process.env.DB_DATABASE = 'test'

// Start the NestJS application mocking some services.
const yamlService = new YamlService()
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule]
})
.overrideProvider(YamlService)
.useValue({
load: () =>
load(
fs.readFileSync(
`${process.cwd()}/e2e/assets/mock-backend.yml`,
'utf8'
)
load: () => {
const fileContent = fs.readFileSync(
`${process.cwd()}/e2e/assets/mock-backend.yml`,
'utf8'
)
const interpolatedContent =
yamlService.interpolateDotEnvVariables(fileContent)
return load(interpolatedContent)
}
})
.compile()

Expand Down
15 changes: 9 additions & 6 deletions packages/core/manifest/e2e/jest.sqlite-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ beforeAll(async () => {
process.env.DB_DROP_SCHEMA = 'true'

// Start the NestJS application mocking some services.
const yamlService = new YamlService()
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule]
})
.overrideProvider(YamlService)
.useValue({
load: () =>
load(
fs.readFileSync(
`${process.cwd()}/e2e/assets/mock-backend.yml`,
'utf8'
)
load: () => {
const fileContent = fs.readFileSync(
`${process.cwd()}/e2e/assets/mock-backend.yml`,
'utf8'
)
const interpolatedContent =
yamlService.interpolateDotEnvVariables(fileContent)
return load(interpolatedContent)
}
})
.compile()

Expand Down
Loading