fix(media-manager): resolve video preview issues and stabilize tests

- Backend (MediaService):
    - Implemented robust contentUrl generation for Drive files using drive.google.com/uc pattern.
    - Added mimeType exposure to unified media state.

- Frontend (MediaManager):
    - Replaced video tag with iframe embedding the Google Drive Preview player (/preview) for reliable playback.
    - Fixed syntax error in console logging causing UI freeze.
    - Updated gallery card logic to prioritize video content URLs.

- Tests (Integration):
    - Refactored mediaManager.integration.test.ts to align with new logic.
    - Mocked DriveApp completely to support orphan adoption flows.
    - Updated file renaming expectations to support timestamped filenames.

- Documentation:
    - Updated MEMORY.md with video preview strategy.
This commit is contained in:
Ben Miller
2025-12-28 15:51:56 -07:00
parent dadcccb7f9
commit 243f7057b7
7 changed files with 74 additions and 21 deletions

View File

@ -37,6 +37,8 @@ This project (`product_inventory`) integrates Google Sheets with Shopify. It ser
- **Google Photos Picker**:
- The `baseUrl` returned by the Picker API is hidden inside `mediaFile.baseUrl` (not top-level).
- Downloading this URL requires an **Authorization header** with the script's OAuth token, or it returns 403.
- `DriveApp.createFile(blob)` is fragile with blobs from `UrlFetchApp`. We use a 2-step fallback:
1. Sanitize with `Utilities.newBlob()`.
2. Fallback to **Advanced Drive Service** (`Drive.Files.create` / `v3`) if standard creation fails.
- **Video Previews**:
- HTML5 `<video>` tags often fail with standard Drive download URLs due to auth/codec issues.
- **Strategy**: Use an `<iframe>` embedding the `https://drive.google.com/file/d/{ID}/preview` URL. This leverages Google's native player for reliable auth and transcoding.