fix: skip instance ID in license check during E2E tests (#6968)

Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
Matti Nannt
2025-12-12 05:05:25 +01:00
committed by GitHub
parent c3d97c2932
commit 666a79044f
2 changed files with 18 additions and 9 deletions

View File

@@ -114,7 +114,7 @@ jobs:
- name: Start MinIO Server
run: |
set -euo pipefail
# Start MinIO server in background
docker run -d \
--name minio-server \
@@ -124,7 +124,7 @@ jobs:
-e MINIO_ROOT_PASSWORD=devminio123 \
minio/minio:RELEASE.2025-09-07T16-13-09Z \
server /data --console-address :9001
echo "MinIO server started"
- name: Wait for MinIO and create S3 bucket

View File

@@ -7,6 +7,7 @@ import { createCacheKey } from "@formbricks/cache";
import { prisma } from "@formbricks/database";
import { logger } from "@formbricks/logger";
import { cache } from "@/lib/cache";
import { E2E_TESTING } from "@/lib/constants";
import { env } from "@/lib/env";
import { hashString } from "@/lib/hash-string";
import { getInstanceId } from "@/lib/instance";
@@ -262,7 +263,9 @@ const fetchLicenseFromServerInternal = async (retryCount = 0): Promise<TEnterpri
const startOfNextYear = new Date(now.getFullYear() + 1, 0, 1);
const [instanceId, responseCount] = await Promise.all([
getInstanceId(),
// Skip instance ID during E2E tests to avoid license key conflicts
// as the instance ID changes with each test run
E2E_TESTING ? null : getInstanceId(),
prisma.response.count({
where: {
createdAt: {
@@ -274,7 +277,8 @@ const fetchLicenseFromServerInternal = async (retryCount = 0): Promise<TEnterpri
]);
// No organization exists, cannot perform license check
if (!instanceId) return null;
// (skip this check during E2E tests as we intentionally use null)
if (!E2E_TESTING && !instanceId) return null;
const proxyUrl = env.HTTPS_PROXY ?? env.HTTP_PROXY;
const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;
@@ -282,12 +286,17 @@ const fetchLicenseFromServerInternal = async (retryCount = 0): Promise<TEnterpri
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), CONFIG.API.TIMEOUT_MS);
const payload: Record<string, unknown> = {
licenseKey: env.ENTERPRISE_LICENSE_KEY,
usage: { responseCount },
};
if (instanceId) {
payload.instanceId = instanceId;
}
const res = await fetch(CONFIG.API.ENDPOINT, {
body: JSON.stringify({
licenseKey: env.ENTERPRISE_LICENSE_KEY,
usage: { responseCount },
instanceId,
}),
body: JSON.stringify(payload),
headers: { "Content-Type": "application/json" },
method: "POST",
agent,