From 46381c381dda7a879cf001fb6288abd849639f10 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Sun, 26 Mar 2023 18:00:20 +0100 Subject: [PATCH 1/4] Update commands to run locally and in CI --- qa-core/package.json | 6 ++-- .../internal-api/dataSources/example.spec.ts | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 qa-core/src/tests/internal-api/dataSources/example.spec.ts diff --git a/qa-core/package.json b/qa-core/package.json index 15246af294..6fb032cd04 100644 --- a/qa-core/package.json +++ b/qa-core/package.json @@ -13,13 +13,15 @@ "test:watch": "env-cmd jest --watch", "test:debug": "DEBUG=1 jest", "test:notify": "node scripts/testResultsWebhook", - "test:ci": "jest --runInBand --json --outputFile=testResults.json", + "test:ci": "jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", "docker:up": "docker-compose up -d", "docker:down": "docker-compose down", "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: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:local:withDataSources": "env-cmd jest --runInBand" }, "jest": { "preset": "ts-jest", diff --git a/qa-core/src/tests/internal-api/dataSources/example.spec.ts b/qa-core/src/tests/internal-api/dataSources/example.spec.ts new file mode 100644 index 0000000000..736e49bd89 --- /dev/null +++ b/qa-core/src/tests/internal-api/dataSources/example.spec.ts @@ -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(api, accountsAPI) + const appConfig = new TestConfiguration(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]) + ) + } + }) +}) From 077e7228622784fa2e0c79cb54e7c531325cac81 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Sun, 26 Mar 2023 18:03:17 +0100 Subject: [PATCH 2/4] Updade nightly command --- qa-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa-core/package.json b/qa-core/package.json index 6fb032cd04..dd6d559267 100644 --- a/qa-core/package.json +++ b/qa-core/package.json @@ -21,7 +21,7 @@ "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:local": "env-cmd jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", - "api:test:local:withDataSources": "env-cmd jest --runInBand" + "api:test:withDataSources": "env-cmd jest --runInBand" }, "jest": { "preset": "ts-jest", From f8f13ed2c7545bfdec6a38e658a0b7162233d8f6 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Sun, 26 Mar 2023 18:05:02 +0100 Subject: [PATCH 3/4] Fix logs in qa-core test runs --- qa-core/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qa-core/package.json b/qa-core/package.json index dd6d559267..59c028f9f9 100644 --- a/qa-core/package.json +++ b/qa-core/package.json @@ -13,7 +13,7 @@ "test:watch": "env-cmd jest --watch", "test:debug": "DEBUG=1 jest", "test:notify": "node scripts/testResultsWebhook", - "test:ci": "jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", + "test:ci": "jest --runInBand --json --outputFile=testResults.json --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", "docker:up": "docker-compose up -d", "docker:down": "docker-compose down", "api:server:setup": "npm run docker:up && env-cmd ts-node ../packages/builder/ts/setup.ts", @@ -21,7 +21,7 @@ "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:local": "env-cmd jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", - "api:test:withDataSources": "env-cmd jest --runInBand" + "api:test:withDataSources": "env-cmd jest --runInBand --outputFile=testResults.json" }, "jest": { "preset": "ts-jest", From 37ba34cf94c7f4ad7d0d0a6d580d0d66e3137e52 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Sun, 26 Mar 2023 18:12:26 +0100 Subject: [PATCH 4/4] Update readme --- qa-core/README.md | 20 ++++++++++++++++---- qa-core/package.json | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/qa-core/README.md b/qa-core/README.md index b812742ab3..c9d0727878 100644 --- a/qa-core/README.md +++ b/qa-core/README.md @@ -3,20 +3,32 @@ The QA Core API tests are a jest suite that run directly against the budibase backend APIs. ## Auto Setup + 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 + You can also just stand up the budibase server alone. -`yarn api:server:setup` +`yarn api:server:setup` ## Run Tests + 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: -`yarn test:watch` \ No newline at end of file +`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` diff --git a/qa-core/package.json b/qa-core/package.json index 59c028f9f9..9a5cc8dc32 100644 --- a/qa-core/package.json +++ b/qa-core/package.json @@ -21,7 +21,7 @@ "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:local": "env-cmd jest --runInBand --testPathIgnorePatterns=\\\"\\/dataSources\\/\\\"", - "api:test:withDataSources": "env-cmd jest --runInBand --outputFile=testResults.json" + "api:test:nightly": "env-cmd jest --runInBand --outputFile=testResults.json" }, "jest": { "preset": "ts-jest",