feat: refactor translation key management (#6717)

Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
Co-authored-by: Piyush Gupta <56182734+gupta-piyush19@users.noreply.github.com>
Co-authored-by: Victor Hugo dos Santos <115753265+victorvhs017@users.noreply.github.com>
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
Co-authored-by: Matti Nannt <matti@formbricks.com>
Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
This commit is contained in:
Dhruwang Jariwala
2025-10-23 20:23:11 +05:30
committed by GitHub
parent c9a50a6ff2
commit a5fa876aa3
510 changed files with 6129 additions and 1883 deletions
@@ -1,4 +1,5 @@
// utils.test.ts
// Pull in the mocked implementations to configure them in tests
import { getServerSession } from "next-auth";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { TEnvironment } from "@formbricks/types/environment";
@@ -16,13 +17,11 @@ import { getProjectByEnvironmentId } from "@/lib/project/service";
import { getUser } from "@/lib/user/service";
import { getProjectPermissionByUserId } from "@/modules/ee/teams/lib/roles";
import { getTeamPermissionFlags } from "@/modules/ee/teams/utils/teams";
// Pull in the mocked implementations to configure them in tests
import { getTranslate } from "@/tolgee/server";
import { environmentIdLayoutChecks, getEnvironmentAuth } from "./utils";
// Mock all external dependencies
vi.mock("@/tolgee/server", () => ({
getTranslate: vi.fn(),
vi.mock("@/lingodotdev/server", () => ({
getTranslate: vi.fn(() => (key: string) => key),
}));
vi.mock("next-auth", () => ({
@@ -76,7 +75,6 @@ vi.mock("@formbricks/types/errors", () => ({
describe("utils.ts", () => {
beforeEach(() => {
// Provide default mocks for successful scenario
vi.mocked(getTranslate).mockResolvedValue(((key: string) => key) as any); // Mock translation function
vi.mocked(getServerSession).mockResolvedValue({ user: { id: "user123" } });
vi.mocked(getEnvironment).mockResolvedValue({ id: "env123" } as TEnvironment);
vi.mocked(getProjectByEnvironmentId).mockResolvedValue({ id: "proj123" } as TProject);