Merge pull request #10112 from Budibase/qa-16-get-qa-core-tests-ready-for-split-runs
Qa 16 get qa core tests ready for split runs
This commit is contained in:
commit
6bf6bbb9e2
|
@ -3,20 +3,32 @@
|
||||||
The QA Core API tests are a jest suite that run directly against the budibase backend APIs.
|
The QA Core API tests are a jest suite that run directly against the budibase backend APIs.
|
||||||
|
|
||||||
## Auto Setup
|
## Auto Setup
|
||||||
|
|
||||||
You can run the whole test suite with one command, that spins up the budibase server and runs the jest tests:
|
You can run the whole test suite with one command, that spins up the budibase server and runs the jest tests:
|
||||||
|
|
||||||
`yarn api:test`
|
`yarn api:test`
|
||||||
|
|
||||||
## Setup Server Only
|
## Setup Server Only
|
||||||
|
|
||||||
You can also just stand up the budibase server alone.
|
You can also just stand up the budibase server alone.
|
||||||
|
|
||||||
`yarn api:server:setup`
|
`yarn api:server:setup`
|
||||||
|
|
||||||
## Run Tests
|
## Run Tests
|
||||||
|
|
||||||
If you configured the server using the previous command, you can run the whole test suite by using:
|
If you configured the server using the previous command, you can run the whole test suite by using:
|
||||||
|
|
||||||
`yarn test`
|
`yarn test`
|
||||||
|
|
||||||
for watch mode, where the tests will run on every change:
|
for watch mode, where the tests will run on every change:
|
||||||
|
|
||||||
`yarn test:watch`
|
`yarn test:watch`
|
||||||
|
|
||||||
|
To run tests locally against a cloud service you can use the command:
|
||||||
|
`yarn run api:test:local`
|
||||||
|
|
||||||
|
To run the tests in CI, it assumes the correct environment variables are set, and the server is already running. Use the command:
|
||||||
|
`yarn run api:test:ci`
|
||||||
|
|
||||||
|
To run the nightly tests against the QA environment, use the command:
|
||||||
|
`yarn run api:test:nightly`
|
||||||
|
|
|
@ -13,13 +13,15 @@
|
||||||
"test:watch": "env-cmd jest --watch",
|
"test:watch": "env-cmd jest --watch",
|
||||||
"test:debug": "DEBUG=1 jest",
|
"test:debug": "DEBUG=1 jest",
|
||||||
"test:notify": "node scripts/testResultsWebhook",
|
"test:notify": "node scripts/testResultsWebhook",
|
||||||
"test:ci": "jest --runInBand --json --outputFile=testResults.json",
|
"test:ci": "jest --runInBand --json --outputFile=testResults.json --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"",
|
||||||
"docker:up": "docker-compose up -d",
|
"docker:up": "docker-compose up -d",
|
||||||
"docker:down": "docker-compose down",
|
"docker:down": "docker-compose down",
|
||||||
"api:server:setup": "npm run docker:up && env-cmd ts-node ../packages/builder/ts/setup.ts",
|
"api:server:setup": "npm run docker:up && env-cmd ts-node ../packages/builder/ts/setup.ts",
|
||||||
"api:server:setup:ci": "env-cmd node ../packages/builder/setup.js",
|
"api:server:setup:ci": "env-cmd node ../packages/builder/setup.js",
|
||||||
"api:test:ci": "start-server-and-test api:server:setup:ci http://localhost:4100/builder test",
|
"api:test:ci": "start-server-and-test api:server:setup:ci http://localhost:4100/builder test",
|
||||||
"api:test": "start-server-and-test api:server:setup http://localhost:4100/builder test"
|
"api:test": "start-server-and-test api:server:setup http://localhost:4100/builder test",
|
||||||
|
"api:test:local": "env-cmd jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"",
|
||||||
|
"api:test:nightly": "env-cmd jest --runInBand --outputFile=testResults.json"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "ts-jest",
|
"preset": "ts-jest",
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
||||||
|
import { App } from "@budibase/types"
|
||||||
|
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
||||||
|
import AccountsAPIClient from "../../../config/internal-api/TestConfiguration/accountsAPIClient"
|
||||||
|
import { generateApp } from "../../../config/internal-api/fixtures/applications"
|
||||||
|
import { Screen } from "@budibase/types"
|
||||||
|
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
||||||
|
|
||||||
|
describe("Internal API - Data Sources", () => {
|
||||||
|
const api = new InternalAPIClient()
|
||||||
|
const accountsAPI = new AccountsAPIClient()
|
||||||
|
const config = new TestConfiguration<Screen>(api, accountsAPI)
|
||||||
|
const appConfig = new TestConfiguration<App>(api, accountsAPI)
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await config.setupAccountAndTenant()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await config.afterAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Create an app with a data source", async () => {
|
||||||
|
// Create app
|
||||||
|
const app = await appConfig.applications.create(generateApp())
|
||||||
|
|
||||||
|
// Create Screen
|
||||||
|
const roleArray = ["BASIC", "POWER", "ADMIN", "PUBLIC"]
|
||||||
|
appConfig.applications.api.appId = app.appId
|
||||||
|
for (let role in roleArray) {
|
||||||
|
const [response, screen] = await config.screen.create(
|
||||||
|
generateScreen(roleArray[role])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue