Fix flaky/broken regression test for the "move to new part lot" fix - #1514
Merged
Conversation
target_id=new (sentinel for "create a new lot") was passed straight to EntityManager::find(PartLot::class, ...), which fails on PostgreSQL with "invalid input syntax for type integer" since the id column is an integer. Skip the lookup for the 'new' sentinel so the existing new-lot-creation branch in the "move" case can handle it as before.
Covers the withdraw/add/move form's "move to new lot" action (target_id=new), which previously crashed with a DBAL DriverException because the sentinel string was passed straight to EntityManager::find(PartLot::class, ...).
CsrfTokenManagerInterface::getToken() needs an active session, which doesn't exist until a request has gone through the client. Grab the CSRF token from the rendered withdraw/move form on the part page instead of asking the token manager directly before any request.
Member
Author
|
@copilot resolve the merge conflicts in this pull request |
…eation-exception-xwejkq # Conflicts: # tests/Controller/PartControllerTest.php Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
Contributor
PartStockChangedLogEntry::move() requires a string comment. The real withdraw/move form always submits this field (empty string by default), so the test needs to as well instead of omitting it, which produced a TypeError since Request::get() returns null for a missing key.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1514 +/- ##
============================================
+ Coverage 61.68% 61.80% +0.11%
- Complexity 9725 9728 +3
============================================
Files 724 724
Lines 31302 31302
============================================
+ Hits 19310 19347 +37
+ Misses 11992 11955 -37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
target_id=new) crash, along with a regression test — but that test as merged is broken: it fetches its CSRF token viaCsrfTokenManagerInterface::getToken()before any client request has been made, which throwsSessionNotFoundException(no session exists yet), and it also omits thecommentfield, which the real form always submits (causing aTypeErrorinPartStockChangedLogEntry::move(), which requires astring).testWithdrawAddMoveToNewLotDoesNotThrowintests/Controller/PartControllerTest.phpby:commentfield, matching what the real HTML form always sends.src/Controller/PartController.phpalready carries the fix from Fix error when creating new part lots on postgres #1513.Test plan
vendor/bin/phpunit --filter testWithdrawAddMoveToNewLotDoesNotThrow tests/Controller/PartControllerTest.php🤖 Generated with Claude Code
https://claude.ai/code/session_01L3pUtJQb2gYppm8ThhTEJU