Skip to content

Fix flaky/broken regression test for the "move to new part lot" fix - #1514

Merged
jbtronics merged 5 commits into
masterfrom
claude/part-lots-creation-exception-xwejkq
Sep 1, 2026
Merged

Fix flaky/broken regression test for the "move to new part lot" fix#1514
jbtronics merged 5 commits into
masterfrom
claude/part-lots-creation-exception-xwejkq

Conversation

@jbtronics

@jbtronics jbtronics commented Sep 1, 2026

Copy link
Copy Markdown
Member

Summary

  • PR Fix error when creating new part lots on postgres #1513 already merged the underlying controller fix for the "move stock to a newly created lot" (target_id=new) crash, along with a regression test — but that test as merged is broken: it fetches its CSRF token via CsrfTokenManagerInterface::getToken() before any client request has been made, which throws SessionNotFoundException (no session exists yet), and it also omits the comment field, which the real form always submits (causing a TypeError in PartStockChangedLogEntry::move(), which requires a string).
  • This PR fixes testWithdrawAddMoveToNewLotDoesNotThrow in tests/Controller/PartControllerTest.php by:
    • Sourcing the CSRF token from the actually-rendered withdraw/move form (via a GET request to the part page first, which also starts the session), instead of pulling it out-of-band before any request exists.
    • Submitting an empty comment field, matching what the real HTML form always sends.
  • No production code changes — src/Controller/PartController.php already 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

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.
@jbtronics

Copy link
Copy Markdown
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>

Copilot AI commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in commit 3bc5633 by merging origin/master into this branch and fixing the conflict in tests/Controller/PartControllerTest.php.

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.
@jbtronics jbtronics changed the title Fix DB error when creating a new part lot via withdraw/move form Fix flaky/broken regression test for the "move to new part lot" fix Sep 1, 2026
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.80%. Comparing base (3aafba0) to head (6a51fe3).
⚠️ Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jbtronics
jbtronics merged commit dc7679b into master Sep 1, 2026
27 checks 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.

3 participants