From c5f5d9454ce1e98a81d3aa8786007a3a43ee80e5 Mon Sep 17 00:00:00 2001 From: jvcalderon Date: Tue, 26 Mar 2024 09:41:57 +0100 Subject: [PATCH] Remove more qa-core tests. Suite is going to be removed. See https://linear.app/budibase/issue/BUDI-8106/remove-qa-core --- .../tests/applications/create.spec.ts | 42 ------ .../tests/applications/delete.spec.ts | 19 --- .../tests/applications/publish.spec.ts | 54 ------- .../tests/applications/update.spec.ts | 45 ------ .../tests/screens/screens.spec.ts | 51 ------- .../internal-api/tests/tables/tables.spec.ts | 133 ------------------ .../tests/users/userManagement.spec.ts | 90 ------------ .../tests/applications/applications.spec.ts | 97 ------------- .../src/public-api/tests/tables/rows.spec.ts | 62 -------- .../public-api/tests/tables/tables.spec.ts | 51 ------- .../src/public-api/tests/users/users.spec.ts | 49 ------- 11 files changed, 693 deletions(-) delete mode 100644 qa-core/src/internal-api/tests/applications/create.spec.ts delete mode 100644 qa-core/src/internal-api/tests/applications/delete.spec.ts delete mode 100644 qa-core/src/internal-api/tests/applications/publish.spec.ts delete mode 100644 qa-core/src/internal-api/tests/applications/update.spec.ts delete mode 100644 qa-core/src/internal-api/tests/screens/screens.spec.ts delete mode 100644 qa-core/src/internal-api/tests/tables/tables.spec.ts delete mode 100644 qa-core/src/internal-api/tests/users/userManagement.spec.ts delete mode 100644 qa-core/src/public-api/tests/applications/applications.spec.ts delete mode 100644 qa-core/src/public-api/tests/tables/rows.spec.ts delete mode 100644 qa-core/src/public-api/tests/tables/tables.spec.ts delete mode 100644 qa-core/src/public-api/tests/users/users.spec.ts diff --git a/qa-core/src/internal-api/tests/applications/create.spec.ts b/qa-core/src/internal-api/tests/applications/create.spec.ts deleted file mode 100644 index 2bb209719c..0000000000 --- a/qa-core/src/internal-api/tests/applications/create.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import * as fixtures from "../../fixtures" - -describe("Internal API - Application creation", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("Get applications without applications", async () => { - await config.api.apps.fetchEmptyAppList() - }) - - it("Get all Applications after creating an application", async () => { - await config.api.apps.create({ - ...fixtures.apps.generateApp(), - useTemplate: "false", - }) - - await config.api.apps.fetchAllApplications() - }) - - it("Get application details", async () => { - const app = await config.createApp({ - ...fixtures.apps.generateApp(), - useTemplate: "false", - }) - - const [appPackageResponse, appPackageJson] = - await config.api.apps.getAppPackage(app.appId!) - expect(appPackageJson.application.name).toEqual(app.name) - expect(appPackageJson.application.version).toEqual(app.version) - expect(appPackageJson.application.url).toEqual(app.url) - expect(appPackageJson.application.tenantId).toEqual(app.tenantId) - expect(appPackageJson.application.status).toEqual(app.status) - }) -}) diff --git a/qa-core/src/internal-api/tests/applications/delete.spec.ts b/qa-core/src/internal-api/tests/applications/delete.spec.ts deleted file mode 100644 index 1841d7c42d..0000000000 --- a/qa-core/src/internal-api/tests/applications/delete.spec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" - -describe("Internal API - Application creation, update, publish and delete", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("DELETE - Delete an application", async () => { - const app = await config.createApp() - - await config.api.apps.delete(app.appId!) - }) -}) diff --git a/qa-core/src/internal-api/tests/applications/publish.spec.ts b/qa-core/src/internal-api/tests/applications/publish.spec.ts deleted file mode 100644 index e614a0f2a4..0000000000 --- a/qa-core/src/internal-api/tests/applications/publish.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import { db } from "@budibase/backend-core" -import * as fixtures from "../../fixtures" - -describe("Internal API - Application creation, update, publish and delete", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("Publish app", async () => { - // create the app - const app = await config.createApp(fixtures.apps.appFromTemplate()) - - // check preview renders - await config.api.apps.canRender() - - // publish app - await config.api.apps.publish(app.appId) - - // check published app renders - config.state.appId = db.getProdAppID(app.appId!) - await config.api.apps.canRender() - - // unpublish app - await config.api.apps.unpublish(app.appId!) - }) - - it("Sync application before deployment", async () => { - const app = await config.createApp() - - const [syncResponse, sync] = await config.api.apps.sync(app.appId!) - expect(sync).toEqual({ - message: "App sync completed successfully.", - }) - }) - - it("Sync application after deployment", async () => { - const app = await config.createApp() - - // publish app - await config.api.apps.publish(app._id) - - const [syncResponse, sync] = await config.api.apps.sync(app.appId!) - expect(sync).toEqual({ - message: "App sync completed successfully.", - }) - }) -}) diff --git a/qa-core/src/internal-api/tests/applications/update.spec.ts b/qa-core/src/internal-api/tests/applications/update.spec.ts deleted file mode 100644 index 93b57dcb61..0000000000 --- a/qa-core/src/internal-api/tests/applications/update.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import { generator } from "../../../shared" -import * as fixtures from "../../fixtures" - -describe("Internal API - Application creation, update, publish and delete", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("Update an application", async () => { - const app = await config.createApp() - - await config.api.apps.rename(app.appId!, app.name!, { - name: generator.word(), - }) - }) - - it("Revert Changes without changes", async () => { - const app = await config.createApp() - - await config.api.apps.revertUnpublished(app.appId!) - }) - - it("Revert Changes", async () => { - const app = await config.createApp() - - // publish app - await config.api.apps.publish(app._id) - - // Change/add component to the app - await config.api.screens.create(fixtures.screens.generateScreen("BASIC")) - - // // Revert the app to published state - await config.api.apps.revertPublished(app.appId!) - - // Check screen is removed - await config.api.apps.getRoutes() - }) -}) diff --git a/qa-core/src/internal-api/tests/screens/screens.spec.ts b/qa-core/src/internal-api/tests/screens/screens.spec.ts deleted file mode 100644 index 9c5fa42847..0000000000 --- a/qa-core/src/internal-api/tests/screens/screens.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import * as fixtures from "../../fixtures" - -describe("Internal API - /screens endpoints", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("Create a screen with each role type", async () => { - // Create app - await config.createApp() - - // Create Screen - const roleArray = ["BASIC", "POWER", "ADMIN", "PUBLIC"] - for (let role in roleArray) { - const [response, screen] = await config.api.screens.create( - fixtures.screens.generateScreen(roleArray[role]) - ) - } - }) - - it("Get screens", async () => { - // Create app - await config.createApp() - - // Create Screen - await config.api.screens.create(fixtures.screens.generateScreen("BASIC")) - - // Check screen exists - await config.api.apps.getRoutes(true) - }) - - it("Delete a screen", async () => { - // Create app - await config.createApp() - - // Create Screen - const [screenResponse, screen] = await config.api.screens.create( - fixtures.screens.generateScreen("BASIC") - ) - - // Delete Screen - await config.api.screens.delete(screen._id!, screen._rev!) - }) -}) diff --git a/qa-core/src/internal-api/tests/tables/tables.spec.ts b/qa-core/src/internal-api/tests/tables/tables.spec.ts deleted file mode 100644 index a38b8e6059..0000000000 --- a/qa-core/src/internal-api/tests/tables/tables.spec.ts +++ /dev/null @@ -1,133 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import { generator } from "../../../shared" -import * as fixtures from "../../fixtures" - -describe("Internal API - Table Operations", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("Create and delete table, columns and rows", async () => { - // create the app - await config.createApp(fixtures.apps.appFromTemplate()) - - // Get current tables: expect 2 in this template - await config.api.tables.getAll(2) - - // Add new table - const [createdTableResponse, createdTableData] = - await config.api.tables.save(fixtures.tables.generateTable()) - - //Table was added - await config.api.tables.getAll(3) - - //Get information about the table - await config.api.tables.getTableById(createdTableData._id!) - - //Add Column to table - const newColumn = - fixtures.tables.generateNewColumnForTable(createdTableData) - const [addColumnResponse, addColumnData] = await config.api.tables.save( - newColumn, - true - ) - - //Add Row to table - const newRow = fixtures.rows.generateNewRowForTable(addColumnData._id!) - await config.api.rows.add(addColumnData._id!, newRow) - - //Get Row from table - const [getRowResponse, getRowData] = await config.api.rows.getAll( - addColumnData._id! - ) - - //Delete Row from table - const rowToDelete = { - rows: [getRowData[0]], - } - const [deleteRowResponse, deleteRowData] = await config.api.rows.delete( - addColumnData._id!, - rowToDelete - ) - expect(deleteRowData[0]._id).toEqual(getRowData[0]._id) - - //Delete the table - const [deleteTableResponse, deleteTable] = await config.api.tables.delete( - addColumnData._id!, - addColumnData._rev! - ) - - //Table was deleted - await config.api.tables.getAll(2) - }) - - it("Search and pagination", async () => { - // create the app - await config.createApp(fixtures.apps.appFromTemplate()) - - // Get current tables: expect 2 in this template - await config.api.tables.getAll(2) - - // Add new table - const [createdTableResponse, createdTableData] = - await config.api.tables.save(fixtures.tables.generateTable()) - - //Table was added - await config.api.tables.getAll(3) - - //Get information about the table - await config.api.tables.getTableById(createdTableData._id!) - - //Add Column to table - const newColumn = - fixtures.tables.generateNewColumnForTable(createdTableData) - const [addColumnResponse, addColumnData] = await config.api.tables.save( - newColumn, - true - ) - - //Add Row to table - let newRow = fixtures.rows.generateNewRowForTable(addColumnData._id!) - await config.api.rows.add(addColumnData._id!, newRow) - - //Search single row - await config.api.rows.searchNoPagination( - createdTableData._id!, - fixtures.rows.searchBody(createdTableData.primaryDisplay!) - ) - - //Add 10 more rows - for (let i = 0; i < 10; i++) { - let newRow = fixtures.rows.generateNewRowForTable(addColumnData._id!) - await config.api.rows.add(addColumnData._id!, newRow) - } - - //Search rows with pagination - const [allRowsResponse, allRowsJson] = - await config.api.rows.searchWithPagination( - createdTableData._id!, - fixtures.rows.searchBody(createdTableData.primaryDisplay!) - ) - - //Delete Rows from table - const rowToDelete = { - rows: [allRowsJson], - } - const [deleteRowResponse, deleteRowData] = await config.api.rows.delete( - createdTableData._id!, - rowToDelete - ) - - //Search single row - await config.api.rows.searchWithPagination( - createdTableData._id!, - fixtures.rows.searchBody(createdTableData.primaryDisplay!) - ) - }) -}) diff --git a/qa-core/src/internal-api/tests/users/userManagement.spec.ts b/qa-core/src/internal-api/tests/users/userManagement.spec.ts deleted file mode 100644 index 28096c08c9..0000000000 --- a/qa-core/src/internal-api/tests/users/userManagement.spec.ts +++ /dev/null @@ -1,90 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import { User } from "@budibase/types" -import * as fixtures from "./../../fixtures" - -describe("Internal API - User Management & Permissions", () => { - const config = new TestConfiguration() - - // Before each test, login as admin. Some tests will require login as a different user - beforeAll(async () => { - await config.beforeAll() - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("Add Users with different roles", async () => { - // Get all users - await config.api.users.search() - - // Get all roles - await config.api.users.getRoles() - - // Add users with each role - const admin = fixtures.users.generateUser(1, "admin") - expect(admin[0].builder?.global).toEqual(true) - expect(admin[0].admin?.global).toEqual(true) - const developer = fixtures.users.generateUser(1, "developer") - expect(developer[0].builder?.global).toEqual(true) - const appUser = fixtures.users.generateUser(1, "appUser") - expect(appUser[0].builder?.global).toEqual(false) - expect(appUser[0].admin?.global).toEqual(false) - - const userList = [...admin, ...developer, ...appUser] - - await config.api.users.addMultiple(userList) - - // Check users are added - const [allUsersResponse, allUsersJson] = await config.api.users.getAll() - expect(allUsersJson.length).toBeGreaterThan(0) - }) - - it("Delete User", async () => { - const appUser = fixtures.users.generateUser() - expect(appUser[0].builder?.global).toEqual(false) - expect(appUser[0].admin?.global).toEqual(false) - const [userResponse, userJson] = await config.api.users.addMultiple(appUser) - const userId = userJson.created.successful[0]._id - await config.api.users.delete(userId) - }) - - it("Reset Password", async () => { - const appUser = fixtures.users.generateUser() - expect(appUser[0].builder?.global).toEqual(false) - expect(appUser[0].admin?.global).toEqual(false) - const [userResponse, userJson] = await config.api.users.addMultiple(appUser) - const [userInfoResponse, userInfoJson] = await config.api.users.getInfo( - userJson.created.successful[0]._id - ) - const body: User = { - ...userInfoJson, - password: "newPassword", - } - await config.api.users.forcePasswordReset(body) - }) - - it("Change User information", async () => { - const appUser = fixtures.users.generateUser() - expect(appUser[0].builder?.global).toEqual(false) - expect(appUser[0].admin?.global).toEqual(false) - const [userResponse, userJson] = await config.api.users.addMultiple(appUser) - const [userInfoResponse, userInfoJson] = await config.api.users.getInfo( - userJson.created.successful[0]._id - ) - const body: User = { - ...userInfoJson, - firstName: "newFirstName", - lastName: "newLastName", - builder: { - global: true, - }, - } - await config.api.users.updateInfo(body) - - const [changedUserInfoResponse, changedUserInfoJson] = - await config.api.users.getInfo(userJson.created.successful[0]._id) - expect(changedUserInfoJson.builder?.global).toBeDefined() - expect(changedUserInfoJson.builder?.global).toEqual(true) - }) -}) diff --git a/qa-core/src/public-api/tests/applications/applications.spec.ts b/qa-core/src/public-api/tests/applications/applications.spec.ts deleted file mode 100644 index 0c8636452a..0000000000 --- a/qa-core/src/public-api/tests/applications/applications.spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { db as dbCore } from "@budibase/backend-core" -import { TestConfiguration } from "../../config" -import { Application } from "../../../types" -import * as fixtures from "../../fixtures" - -describe("Public API - /applications endpoints", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - await config.createApp() - config.context = (await config.api.apps.read(config.state.appId!))[1] - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("POST - Create an application", async () => { - const [response, app] = await config.api.apps.create( - fixtures.apps.generateApp() - ) - expect(response).toHaveStatusCode(200) - expect(app._id).toBeDefined() - }) - - it("POST - Search applications", async () => { - const [response, apps] = await config.api.apps.search({ - name: config.context.name, - }) - expect(response).toHaveStatusCode(200) - expect(apps[0]).toEqual(config.context) - }) - - it("GET - Retrieve an application", async () => { - const [response, app] = await config.api.apps.read(config.context._id) - expect(response).toHaveStatusCode(200) - expect(app).toEqual(config.context) - }) - - it("PUT - update an application", async () => { - config.context.name = "UpdatedName" - const [response, app] = await config.api.apps.update( - config.context._id, - config.context - ) - expect(response).toHaveStatusCode(200) - expect(app.updatedAt).not.toEqual(config.context.updatedAt) - expect(app.name).toEqual(config.context.name) - }) - - it("POST - publish an application", async () => { - config.context.name = "UpdatedName" - const [response, deployment] = await config.api.apps.publish( - config.context._id - ) - expect(response).toHaveStatusCode(200) - expect(deployment).toEqual({ - status: "SUCCESS", - }) - - // Verify publish - const prodAppId = dbCore.getProdAppID(config.context._id) - const [_, publishedApp] = await config.api.apps.read(prodAppId) - expect(response).toHaveStatusCode(200) - expect(publishedApp._id).toEqual(prodAppId) - }) - - it("POST - unpublish a published application", async () => { - await config.api.apps.publish(config.context._id) - const [response] = await config.api.apps.unpublish(config.context._id) - expect(response).toHaveStatusCode(204) - }) - - it("POST - unpublish an unpublished application", async () => { - const [response] = await config.api.apps.unpublish(config.context._id) - expect(response).toHaveStatusCode(400) - }) - - it("DELETE - delete a published application and the dev application", async () => { - await config.api.apps.publish(config.context._id) - const [response, deletion] = await config.api.apps.delete( - config.context._id - ) - expect(response).toHaveStatusCode(200) - expect(deletion._id).toEqual(config.context._id) - - // verify dev app deleted - const [devAppResponse] = await config.api.apps.read(config.context._id) - expect(devAppResponse).toHaveStatusCode(404) - - // verify prod app deleted - const prodAppId = dbCore.getProdAppID(config.context._id) - const [publishedAppResponse] = await config.api.apps.read(prodAppId) - expect(publishedAppResponse).toHaveStatusCode(404) - }) -}) diff --git a/qa-core/src/public-api/tests/tables/rows.spec.ts b/qa-core/src/public-api/tests/tables/rows.spec.ts deleted file mode 100644 index e35f071a4e..0000000000 --- a/qa-core/src/public-api/tests/tables/rows.spec.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { TestConfiguration } from "../../config" -import * as fixtures from "../../fixtures" -import { Row } from "../../../types" - -describe("Public API - /rows endpoints", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - await config.createApp() - - const [tResp, table] = await config.api.tables.seed() - config.state.tableId = table._id - - const [rResp, row] = await config.api.rows.seed(table._id) - config.context = row - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("POST - Create a row", async () => { - const [response, row] = await config.api.rows.create( - fixtures.rows.generateRow() - ) - expect(response).toHaveStatusCode(200) - expect(row._id).toBeDefined() - }) - - it("POST - Search rows", async () => { - const [response, rows] = await config.api.rows.search({ - query: { - string: { - testColumn: config.context.testColumn as string, - }, - }, - }) - expect(response).toHaveStatusCode(200) - expect(rows.length).toEqual(1) - expect(rows[0]._id).toEqual(config.context._id) - expect(rows[0].tableId).toEqual(config.context.tableId) - expect(rows[0].testColumn).toEqual(config.context.testColumn) - }) - - it("GET - Retrieve a row", async () => { - const [response, row] = await config.api.rows.read(config.context._id) - expect(response).toHaveStatusCode(200) - expect(row._id).toEqual(config.context._id) - expect(row.tableId).toEqual(config.context.tableId) - }) - - it("PUT - update a row", async () => { - config.context.testColumn = "UpdatedName" - const [response, row] = await config.api.rows.update( - config.context._id, - config.context - ) - expect(response).toHaveStatusCode(200) - expect(row.testColumn).toEqual(config.context.testColumn) - }) -}) diff --git a/qa-core/src/public-api/tests/tables/tables.spec.ts b/qa-core/src/public-api/tests/tables/tables.spec.ts deleted file mode 100644 index 010444b7c8..0000000000 --- a/qa-core/src/public-api/tests/tables/tables.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { TestConfiguration } from "../../config" -import * as fixtures from "../../fixtures" -import { Table } from "../../../types" - -describe("Public API - /tables endpoints", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - await config.createApp() - - const [tableResp, table] = await config.api.tables.seed() - config.context = table - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("POST - Create a table", async () => { - const [response, table] = await config.api.tables.create( - fixtures.tables.generateTable() - ) - expect(response).toHaveStatusCode(200) - expect(table._id).toBeDefined() - }) - - it("POST - Search tables", async () => { - const [response, tables] = await config.api.tables.search({ - name: config.context.name, - }) - expect(response).toHaveStatusCode(200) - expect(tables[0]).toEqual(config.context) - }) - - it("GET - Retrieve a table", async () => { - const [response, table] = await config.api.tables.read(config.context._id) - expect(response).toHaveStatusCode(200) - expect(table).toEqual(config.context) - }) - - it("PUT - update a table", async () => { - config.context.name = "updatedName" - const [response, table] = await config.api.tables.update( - config.context._id, - config.context - ) - expect(response).toHaveStatusCode(200) - expect(table).toEqual(config.context) - }) -}) diff --git a/qa-core/src/public-api/tests/users/users.spec.ts b/qa-core/src/public-api/tests/users/users.spec.ts deleted file mode 100644 index 98f390b9bd..0000000000 --- a/qa-core/src/public-api/tests/users/users.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -import TestConfiguration from "../../config/TestConfiguration" -import * as fixtures from "../../fixtures" -import { User } from "../../../types" - -describe("Public API - /users endpoints", () => { - const config = new TestConfiguration() - - beforeAll(async () => { - await config.beforeAll() - const [_, user] = await config.api.users.seed() - config.context = user - }) - - afterAll(async () => { - await config.afterAll() - }) - - it("POST - Create a user", async () => { - const [response, user] = await config.api.users.create( - fixtures.users.generateUser() - ) - expect(response).toHaveStatusCode(200) - expect(user._id).toBeDefined() - }) - - it("POST - Search users", async () => { - const [response, users] = await config.api.users.search({ - name: config.context.email, - }) - expect(response).toHaveStatusCode(200) - expect(users[0]).toEqual(config.context) - }) - - it("GET - Retrieve a user", async () => { - const [response, user] = await config.api.users.read(config.context._id) - expect(response).toHaveStatusCode(200) - expect(user).toEqual(config.context) - }) - - it("PUT - update a user", async () => { - config.context.firstName = "Updated First Name" - const [response, user] = await config.api.users.update( - config.context._id, - config.context - ) - expect(response).toHaveStatusCode(200) - expect(user).toEqual(config.context) - }) -})