From 39523685d696b8828c1890dfbf2061cce7e3fa8e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 5 Jul 2024 16:20:27 +0100 Subject: [PATCH] Adding test case for searching sample data. --- .../src/api/routes/tests/search.spec.ts | 20 +++++++++++++++++++ .../src/tests/utilities/api/application.ts | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 145db9b4a3..6b1fd2a198 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -30,6 +30,8 @@ import { encodeJSBinding } from "@budibase/string-templates" import { dataFilters } from "@budibase/shared-core" import { Knex } from "knex" import { structures } from "@budibase/backend-core/tests" +import { DEFAULT_EMPLOYEE_TABLE_SCHEMA } from "../../../db/defaultData/datasource_bb_default" +import { employeeImport } from "../../../db/defaultData/employeeImport" describe.each([ ["in-memory", undefined], @@ -2167,6 +2169,24 @@ describe.each([ } ) + isInternal && + describe("sample data", () => { + beforeAll(async () => { + await config.api.application.addSampleData(config.appId!) + table = DEFAULT_EMPLOYEE_TABLE_SCHEMA + }) + + it("should be able to search sample data", async () => { + await expectSearch({ + query: {}, + }).toContain([ + { + "First Name": "Mandy", + }, + ]) + }) + }) + describe.each([ "名前", // Japanese for "name" "Benutzer-ID", // German for "user ID", includes a hyphen diff --git a/packages/server/src/tests/utilities/api/application.ts b/packages/server/src/tests/utilities/api/application.ts index bb9357c893..516af5c973 100644 --- a/packages/server/src/tests/utilities/api/application.ts +++ b/packages/server/src/tests/utilities/api/application.ts @@ -149,4 +149,8 @@ export class ApplicationAPI extends TestAPI { query: { status }, }) } + + addSampleData = async (appId: string): Promise => { + await this._post(`/api/applications/${appId}/sample`) + } }