test: point oembed API tests at the CI mock-server instead of real providers

Merged
KE
3mo ago
+197-17

Proposed changes (including videos or screenshots)

The chat.sendMessage oembed API tests fetched real external sites (YouTube's oembed endpoint, rocket.chat) at test time, so slow or failed external fetches flaked the suite โ€” e.g. should generate previews of chosen URL when the previewUrls array is provided failing with expected {} not to be empty after its fixed 1s sleep.

This points the whole oembed suite at the mock-server already used by the ABAC API tests:

  • providers.ts registers a TEST_MODE-only oembed provider that resolves http://mock-server.local:8080/video/* URLs through GET /oembed on the mock-server; tests program that endpoint per case with captured real provider payloads (YouTube video, Spotify rich).
  • docker-compose-ci.yml adds a mock-server.local network alias, since single-label hostnames fail server-fetch SSRF domain validation.
  • The CE api job now also starts mock-server (the EE job already does via COMPOSE_PROFILES=api).
  • The flaky fixed sleep(1000) is replaced with the existing retry polling helper.

New coverage on top of the converted tests, using real captured oembed responses:

  • full metadata of a rich provider response (title/type/provider/thumbnail, oembedHtml max-width injection, non-string values dropped)
  • provider response with no string values embeds only oembedUrl
  • provider error response (500) embeds no metadata

Locally verified against the pinned mockserver image: path matching ignores query strings, string bodies work for the generic-page (pageTitle) case, and the dotted alias resolves via docker DNS from a peer container.

Steps to test or reproduce

Run the api E2E suite; the [Chat] /chat.sendMessage oembed block no longer performs any external network request.

Further comments

Test-only change, no changeset.

Summary by CodeRabbit

  • Bug Fixes

    • Improved link previews for supported video and rich-media URLs.
    • Enhanced preview metadata handling, including iframe content and provider responses.
    • Prevented invalid or incomplete metadata from appearing in message previews.
    • Improved behavior when preview providers return errors or when messages contain more than five external URLs.
  • Tests

    • Expanded end-to-end coverage for chat message previews and link-preview edge cases.

Task: CORE-2457