fix: preserve generated proposal ids#6662
Open
MolhamHamwi wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a regression test to ensure createProposal always uses a server-generated proposal ID (even if the client supplies an id) and updates the service implementation to enforce that behavior.
Changes:
- Added a
node:testtest covering ID override behavior and persistence vialistProposals(). - Updated
createProposalspread order so the generatedidcannot be overridden bypayload.id.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/api/src/tests/proposalService.test.js | Adds regression test asserting server-generated IDs are preserved and stored. |
| apps/api/src/services/proposalService.js | Changes object spread order to ensure generated id wins over client payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+5
to
+21
| test("createProposal preserves the generated proposal id over payload id", async () => { | ||
| const proposal = await createProposal({ | ||
| id: "prp_client_supplied", | ||
| jobId: "job_123", | ||
| freelancerId: "usr_123", | ||
| coverLetter: "Focused proposal", | ||
| }); | ||
|
|
||
| assert.match(proposal.id, /^prp_\d+$/); | ||
| assert.notEqual(proposal.id, "prp_client_supplied"); | ||
| assert.equal(proposal.jobId, "job_123"); | ||
| assert.equal(proposal.freelancerId, "usr_123"); | ||
| assert.equal(proposal.coverLetter, "Focused proposal"); | ||
|
|
||
| const stored = (await listProposals()).find((entry) => entry.jobId === "job_123"); | ||
| assert.equal(stored?.id, proposal.id); | ||
| }); No newline at end of file |
|
|
||
| export async function createProposal(payload) { | ||
| const proposal = { id: `prp_${Date.now()}`, ...payload }; | ||
| const proposal = { ...payload, id: `prp_${Date.now()}` }; |
Author
|
Addressed the review feedback: proposal IDs now use randomUUID(), the test resets the proposal store before each run, and the fixture uses a unique job id with semantic assertions. Local check: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6661
/claim #6661
/claim #743
Test Plan
node --test apps/api/src/tests/proposalService.test.jsnode --test apps/api/src/tests/*.test.jsgit diff --check