From 51b116bd6bbfc2263cd7f0038c4d6d82cf8e166b Mon Sep 17 00:00:00 2001 From: pandeymangg Date: Wed, 10 Sep 2025 10:38:07 +0530 Subject: [PATCH] e2e --- .github/workflows/e2e.yml | 39 +++++++++++++++++-- apps/web/modules/storage/file-upload.ts | 4 ++ .../ui/components/file-input/index.tsx | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 83569d5bee..92840bc4d7 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -64,8 +64,8 @@ jobs: - 9000:9000 options: >- --health-cmd="curl -fsS http://localhost:9000/minio/health/live || exit 1" - --health-interval=5s - --health-timeout=2s + --health-interval=10s + --health-timeout=5s --health-retries=20 steps: - name: Harden the runner (Audit all outbound calls) @@ -120,17 +120,34 @@ jobs: - name: Wait for MinIO and create S3 bucket run: | + echo "Waiting for MinIO to be ready..." for i in {1..60}; do if curl -fsS http://localhost:9000/minio/health/live >/dev/null; then - echo "MinIO is up" + echo "MinIO is up after ${i} seconds" break fi + echo "Waiting for MinIO... (attempt ${i}/60)" sleep 1 done + # Give MinIO a bit more time to fully initialize + sleep 5 + + echo "Configuring MinIO client..." mc alias set local http://localhost:9000 minioadmin minioadmin + + echo "Creating S3 bucket..." mc mb --ignore-existing local/formbricks-e2e + echo "Verifying bucket creation..." + mc ls local/ + + echo "Testing MinIO connectivity..." + curl -fsS http://localhost:9000/minio/health/live && echo "✓ MinIO health check passed" + + echo "Testing S3 API endpoint..." + curl -fsS http://localhost:9000/ && echo "✓ MinIO S3 API accessible" || echo "✗ MinIO S3 API not accessible" + - name: Build App run: | pnpm build --filter=@formbricks/web... @@ -173,6 +190,22 @@ jobs: sleep 10 done + - name: Test Storage and MinIO Integration + run: | + echo "Testing MinIO file upload with mc client..." + # Test file upload using MinIO client + echo "test content" > test-file.txt + mc cp test-file.txt local/formbricks-e2e/test-file.txt + + echo "Verifying file was uploaded..." + mc ls local/formbricks-e2e/ + + echo "Testing file download..." + mc cp local/formbricks-e2e/test-file.txt downloaded-test-file.txt + cat downloaded-test-file.txt + + echo "MinIO integration test completed successfully!" + - name: Install Playwright run: pnpm exec playwright install --with-deps diff --git a/apps/web/modules/storage/file-upload.ts b/apps/web/modules/storage/file-upload.ts index b324db1fe0..a455cd1883 100644 --- a/apps/web/modules/storage/file-upload.ts +++ b/apps/web/modules/storage/file-upload.ts @@ -1,3 +1,5 @@ +import toast from "react-hot-toast"; + export enum FileUploadError { NO_FILE = "No file provided or invalid file type. Expected a File or Blob.", INVALID_FILE_TYPE = "Please upload an image file.", @@ -59,6 +61,8 @@ export const handleFileUpload = async ( }); if (!response.ok) { + toast.error(JSON.stringify(response), { duration: 1000 }); + if (response.status === 400) { const json = (await response.json()) as { details?: { fileName?: string } }; if (json.details?.fileName) { diff --git a/apps/web/modules/ui/components/file-input/index.tsx b/apps/web/modules/ui/components/file-input/index.tsx index 48ce4c4128..c7ee3155ac 100644 --- a/apps/web/modules/ui/components/file-input/index.tsx +++ b/apps/web/modules/ui/components/file-input/index.tsx @@ -85,6 +85,7 @@ export const FileInput = ({ if (uploadedFiles.length < allowedFiles.length || uploadedFiles.some((file) => file.error)) { const firstError = uploadedFiles.find((f) => f.error)?.error; + toast.error(JSON.stringify(uploadedFiles), { duration: 1000 }); if (firstError === FileUploadError.INVALID_FILE_NAME) { toast.error(t("common.invalid_file_name")); } else if (uploadedFiles.length === 0) {