Skip to content

Implement MinIO presigned upload for advertisement attachments #7199

@Piyush-Goenka

Description

@Piyush-Goenka

Context

PR #7196 fixed the E2E test failures by temporarily removing attachment upload functionality from the advertisement creation flow. The backend schema was updated to accept FileMetadataInput[] instead of Upload[], which requires implementing a MinIO presigned upload flow.

Current State

  • The ADD_ADVERTISEMENT_MUTATION schema now expects attachments: [FileMetadataInput!] where FileMetadataInput includes:
    • fileHash: String!
    • mimeType: String!
    • name: String!
    • objectName: String!
  • The frontend currently collects file objects but does not send them to the backend
  • E2E tests skip attachment upload to prevent hanging on MinIO operations in CI

Implementation Requirements

Frontend Changes

  1. Presigned URL Request Flow

    • Add logic to request presigned URLs from the backend for file uploads
    • Handle the presigned URL response and prepare for upload
  2. MinIO Upload

    • Implement file upload to MinIO using the presigned URL
    • Handle upload progress and errors
    • Construct FileMetadataInput with the required fields after successful upload
  3. UI Updates

    • Update AdvertisementRegister.tsx to handle the new upload flow
    • Show upload progress/feedback to users
    • Handle file validation (size, type, etc.)

E2E Test Changes

  1. MinIO Mocking

    • Use cy.intercept() to mock MinIO presigned URL endpoints
    • Mock the file upload to MinIO (avoid actual uploads in CI)
    • Mock the backend response with FileMetadataInput data
  2. Test Coverage

    • Update cypress/e2e/admin_spec/advertisement.cy.ts to test attachment uploads
    • Restore file upload steps in cypress/pageObjects/AdminPortal/AdvertisementPage.ts
    • Verify successful upload and attachment metadata in created advertisements

Acceptance Criteria

  • Frontend successfully requests presigned URLs from the backend
  • Files are uploaded to MinIO using presigned URLs
  • FileMetadataInput is correctly constructed and sent with ADD_ADVERTISEMENT_MUTATION
  • Users can attach files when creating advertisements
  • E2E tests properly mock MinIO operations (no actual uploads to MinIO in CI)
  • E2E tests verify attachment upload functionality
  • All existing tests continue to pass

References

Technical Notes

This is a feature implementation that was intentionally separated from the E2E test fix to maintain clear separation of concerns and reduce review complexity.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions