twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.69k stars 1.7k forks source link

Automagically QA all the REST endpoints based on the openapi #5583

Open waynehamadi opened 3 months ago

waynehamadi commented 3 months ago

See here: https://github.com/allenheltondev/postman-contract-test-generator

You need something like that, a lot of rest endpoints don't work, and it's so much work to test all of them.

I asked Allen if he built something even better: https://x.com/waynebluewind/status/1794701810709475329

greptile-apps[bot] commented 3 months ago

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :).

To automate QA for all REST endpoints based on OpenAPI, follow these steps:

  1. Generate Postman Tests: Use the postman-contract-test-generator to generate Postman tests from your OpenAPI spec.

  2. Locate OpenAPI Spec: Ensure your OpenAPI spec is up-to-date. It is typically found in the twenty-server package.

  3. Integrate Tests: Integrate the generated Postman tests into your CI/CD pipeline. This can be done by adding a script in your package.json:

"scripts": {
  "test:api": "newman run postman_collection.json"
}
  1. Run Tests: Execute the tests using the command npm run test:api.

  2. Handle Responses: Ensure your response handlers in twenty-server/src/handlers are correctly processing the responses as per the OpenAPI spec.

  3. Update Endpoints: Fix any failing endpoints as identified by the tests. Refer to twenty-server/src/routes for endpoint definitions.

This will help in automating the QA process for your REST endpoints.

References