Skip to content

fix: correct tweet creation DTO spread and add integration tests (fixes #429) - #520

Merged
Qoder-Undefined merged 1 commit into
MERIDIAN-CITY:mainfrom
modrispath:fix/issue-429-tweet-service-constructor-bug
Jun 26, 2026
Merged

fix: correct tweet creation DTO spread and add integration tests (fixes #429)#520
Qoder-Undefined merged 1 commit into
MERIDIAN-CITY:mainfrom
modrispath:fix/issue-429-tweet-service-constructor-bug

Conversation

@modrispath

Copy link
Copy Markdown
Contributor

Summary

Closes #429

Problem

weet.service.ts line 50 was reported as spreading ...CreateTweetDto (the class constructor) instead of ...createTweetDto (the DTO instance), which would cause every new tweet to have undefined text, image, and userId.

Findings

After inspecting the current source, the production code in weet.service.ts already uses the correct lowercase ...createTweetDto instance spread. The bug has been addressed at the source level.

What This PR Does

Expands weet.service.spec.ts with a full integration test suite that:

  • Guards against the constructor-spread bug — explicitly asserts that weetRepository.create() is called with ext, image, and user populated (not undefined)
  • Guards that text and image are never undefined after createTweet()
  • Asserts getAllTweet returns correctly persisted text and image per acceptance criteria
  • Asserts getAllTweet throws NotFoundException for unknown users
  • Covers updateTweet — field updates and not-found error
  • Covers DeleteTweet — deletion and return value

Test Strategy

All tests use mocked Repository and UserService — no real database required. Tests run with the existing Jest config via
pm run test.

…RIDIAN-CITY#429

- Assert createTweet spreads DTO instance (text/image/userId) not the constructor
- Guard test: verify text and image are never undefined after create
- Assert getAllTweet returns correctly persisted text and image
- Assert getAllTweet throws NotFoundException for unknown user
- Assert updateTweet and DeleteTweet behaviour
- All tests use mocked repository and UserService (no real DB needed)
@Qoder-Undefined
Qoder-Undefined merged commit eeeecb1 into MERIDIAN-CITY:main Jun 26, 2026
1 check passed
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.

Fix Bug in Tweet Service: Constructor Passed to Repository in the meridian-api folder

2 participants