diff --git a/packages/backend-core/src/db/tests/utils.seq.spec.ts b/packages/backend-core/src/db/tests/utils.seq.spec.ts index 38166ab1cf..83253402f7 100644 --- a/packages/backend-core/src/db/tests/utils.seq.spec.ts +++ b/packages/backend-core/src/db/tests/utils.seq.spec.ts @@ -8,7 +8,7 @@ const { const { generateAppID, getPlatformUrl, getScopedConfig } = require("../utils") const tenancy = require("../../tenancy") const { Config, DEFAULT_TENANT_ID } = require("../../constants") -import { faker } from "@faker-js/faker" +import { generator } from "../../../tests" import env from "../../environment" describe("utils", () => { @@ -119,7 +119,7 @@ describe("getPlatformUrl", () => { it("gets the platform url from the database", async () => { await tenancy.doInTenant(null, async () => { - const dbUrl = faker.internet.url() + const dbUrl = generator.url() await setDbPlatformUrl(dbUrl) const url = await getPlatformUrl() expect(url).toBe(dbUrl) @@ -153,7 +153,7 @@ describe("getPlatformUrl", () => { it("never gets the platform url from the database", async () => { await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => { - await setDbPlatformUrl(faker.internet.url()) + await setDbPlatformUrl(generator.url()) const url = await getPlatformUrl() expect(url).toBe(TENANT_AWARE_URL) }) @@ -171,7 +171,7 @@ describe("getScopedConfig", () => { it("returns the platform url with an existing config", async () => { await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => { - const dbUrl = faker.internet.url() + const dbUrl = generator.url() await setDbPlatformUrl(dbUrl) const db = tenancy.getGlobalDB() const config = await getScopedConfig(db, { type: Config.SETTINGS }) diff --git a/packages/backend-core/src/migrations/tests/index.spec.js b/packages/backend-core/src/migrations/tests/index.spec.js index 608e700d9b..3efb10fbf3 100644 --- a/packages/backend-core/src/migrations/tests/index.spec.js +++ b/packages/backend-core/src/migrations/tests/index.spec.js @@ -2,9 +2,8 @@ require("../../../tests") const { runMigrations, getMigrationsDoc } = require("../index") const { getGlobalDBName, getDB } = require("../../db") -const { faker } = require( "@faker-js/faker") - const { default: environment } = require("../../environment") +const { newid } = require("../../newid") environment._set("MULTI_TENANCY", 'TRUE') let db @@ -22,7 +21,7 @@ describe("migrations", () => { let tenantId beforeEach(() => { - tenantId =faker.random.alpha(10) + tenantId = `tenant_${newid()}` db = getDB(getGlobalDBName(tenantId)) }) diff --git a/packages/backend-core/src/utils/tests/utils.spec.ts b/packages/backend-core/src/utils/tests/utils.spec.ts index 52de2cc9f1..2d3d40f9d5 100644 --- a/packages/backend-core/src/utils/tests/utils.spec.ts +++ b/packages/backend-core/src/utils/tests/utils.spec.ts @@ -4,8 +4,8 @@ import * as events from "../../events" import * as db from "../../db" import { Header } from "../../constants" import { doInTenant } from "../../context" -import { faker } from "@faker-js/faker" import environment from "../../environment" +import { newid } from "../../utils" describe("utils", () => { describe("platformLogout", () => { @@ -14,7 +14,7 @@ describe("utils", () => { }) it("should call platform logout", async () => { - await doInTenant(faker.random.alpha(10), async () => { + await doInTenant(`tenant-${newid()}`, async () => { const ctx = structures.koa.newContext() await utils.platformLogout({ ctx, userId: "test" }) expect(events.auth.logout).toBeCalledTimes(1) @@ -64,7 +64,7 @@ describe("utils", () => { const app = structures.apps.app(expected) // set custom url - const appUrl = faker.datatype.uuid() + const appUrl = newid() app.url = `/${appUrl}` ctx.path = `/app/${appUrl}`