Skip to content

feat: implement quest serialization contract and fix API fixture tests#1819

Open
Dydex wants to merge 2 commits into
EarnQuestOne:mainfrom
Dydex:API-fixture
Open

feat: implement quest serialization contract and fix API fixture tests#1819
Dydex wants to merge 2 commits into
EarnQuestOne:mainfrom
Dydex:API-fixture

Conversation

@Dydex

@Dydex Dydex commented Jun 26, 2026

Copy link
Copy Markdown

closes #826

This Pull Request addresses the serialization mismatch between the NestJS backend response and the frontend's expected type schema. Previously, the frontend Vitest suite mocked unwrapped payloads, failing to reflect the actual { data, meta } response envelope returned by the backend. Consequently, this PR implements a robust mapping and normalization layer to ensure the application correctly handles production payloads.

On the backend, QuestResponseDto has been updated to expose several required database columns that were previously omitted from the response, including contractQuestId (mapped from contractTaskId), rewardAsset, deadline, and completion counters. The entity mapping logic inside fromEntity has also been updated to ensure all these fields are correctly populated and sent in both single-quest and paginated listing endpoints.

On the frontend, the quest client endpoints (getQuests, getQuestById, createQuest, and updateQuest) have been wrapped with custom deserializeQuest and deserializePaginatedQuests helper functions. These helpers seamlessly handle both standard NestJS wrapped responses and the direct/unwrapped JSON fixture formats, while mapping backend-specific property keys to frontend-expected formats. In addition, the serializers handle type-coercion for numbers and normalize lowercase status strings (e.g., 'active') to frontend-specific capitalized enum values (e.g., 'Active').

Finally, the Vitest integration suite in quests.serialization.test.ts has been upgraded. All MSW mock handlers now wrap the test fixtures inside the authentic backend { data, meta } response envelope. This aligns the mock servers with the production API contracts, ensuring all assertions verify actual end-to-end serialization behavior.

@Dydex Dydex requested a review from RUKAYAT-CODER as a code owner June 26, 2026 22:29
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Dydex Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

RUKAYAT-CODER commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Kindly resolve conflict and fix workflow

@Dydex

Dydex commented Jun 27, 2026

Copy link
Copy Markdown
Author

Kindly resolve conflict and fix workflow

Done

@Dydex

Dydex commented Jun 29, 2026

Copy link
Copy Markdown
Author

@RUKAYAT-CODER Pls merge
Everytime i solve ci errors and u merge someone else pr, mine gets errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FE-037] Add contract/API fixture tests for quest serialization from backend response

2 participants