Skip to content

Commit 0b19e76

Browse files
dancergr2m
authored andcommitted
refactor(provider/openai): migrate all tests to fixture pattern (#12514)
## background openai provider tests used inline `prepareJsonResponse` / `prepareStreamResponse` helpers that constructed fake API responses. this made tests fragile and inconsistent with the fixture-based pattern used by other migrated providers ## summary - record real API fixtures for all 6 openai test files (chat, responses, completion, embedding, transcription, image) - replace all `prepareJsonResponse` / `prepareStreamResponse` helpers with `prepareJsonFixtureResponse` / `prepareChunksFixtureResponse` that read from `__fixtures__/` files - inline `server.urls` for tests that check specific response content (finish reasons, logprobs, usage overrides, etc.) - trim large response data per conventions (embedding vectors to 5 values, image base64 to ~100 chars, transcription words to 5) - fix missing `.filter(line => line.trim().length > 0)` in chat `prepareChunksFixtureResponse` to match reference pattern - zero `prepareJsonResponse` or `prepareStreamResponse` remaining in the openai package
1 parent 81db86a commit 0b19e76

15 files changed

Lines changed: 1855 additions & 1198 deletions

packages/openai/src/chat/__fixtures__/openai-text.chunks.txt

Lines changed: 303 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"id": "chatcmpl-D8Z5f52zQqikDBEKQMQoYcWMcWPeU",
3+
"object": "chat.completion",
4+
"created": 1770933883,
5+
"model": "gpt-4.1-nano-2025-04-14",
6+
"choices": [
7+
{
8+
"index": 0,
9+
"message": {
10+
"role": "assistant",
11+
"content": "**Holiday Name:** Galaxy Day \n\n**Date:** October 31st, aligning with the night sky's peak viewing of constellations and celestial events. \n\n**Purpose:** Galaxy Day celebrates the universe's vastness, beauty, and our collective curiosity about the cosmos. It's a time to honor science, imagination, and our shared human wonder about the stars and beyond. \n\n**Traditions:** \n\n1. **Stargazing Festivals:** Communities host outdoor gatherings in parks, rooftops, or open fields. People set up telescopes, enjoy guided stargazing sessions, and share stories about space, astronomy, and mythologies linked to constellations. \n\n2. **Cosmic Costumes:** Participants dress up as planets, stars, astronauts, aliens, or celestial phenomena. Parades and costume contests encourage creativity inspired by the universe's mysteries. \n\n3. **Celestial Art:** Art installations and light shows depict galaxies, nebulae, and astronomical phenomena. Schools and galleries often hold exhibitions or workshops focusing on space-inspired creativity. \n\n4. **Educational Activities:** Museums and science centers offer special exhibits, planetarium shows, and activities for all ages to learn about space exploration, astronomy, and the universe's origins. \n\n5. **Offering of Light:** In homage to distant stars, families and communities light candles or lanterns, symbolizing hope, curiosity, and the idea that even the smallest light can illuminate vast darkness\u2014mirroring our quest to find knowledge amidst the cosmos. \n\n6. **Global Connection:** As Galaxy Day emphasizes shared wonder, people are encouraged to connect virtually with friends or communities worldwide to share discoveries, stories, and aspirations related to space. \n\nGalaxy Day fosters a sense of unity, exploration, and awe, inspiring individuals to look up and dream beyond our world.",
12+
"refusal": null,
13+
"annotations": []
14+
},
15+
"logprobs": null,
16+
"finish_reason": "stop"
17+
}
18+
],
19+
"usage": {
20+
"prompt_tokens": 16,
21+
"completion_tokens": 363,
22+
"total_tokens": 379,
23+
"prompt_tokens_details": {
24+
"cached_tokens": 0,
25+
"audio_tokens": 0
26+
},
27+
"completion_tokens_details": {
28+
"reasoning_tokens": 0,
29+
"audio_tokens": 0,
30+
"accepted_prediction_tokens": 0,
31+
"rejected_prediction_tokens": 0
32+
}
33+
},
34+
"service_tier": "default",
35+
"system_fingerprint": "fp_de604bd877"
36+
}

0 commit comments

Comments
 (0)