-
-
Notifications
You must be signed in to change notification settings - Fork 6
Validate warehouse location name length instead of silently truncating it #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| context("6_1_Warehouse_Locations_Test", () => { | ||
| // exact-length strings, built programmatically so the boundary is never off-by-one | ||
| const Test_label_prefix = "aaa_LocLenTest_"; | ||
| const Test_label_at_limit = Test_label_prefix.padEnd(50, "X"); // exactly 50 chars | ||
| const Test_label_over_limit = Test_label_prefix.padEnd(51, "X"); // exactly 51 chars | ||
|
|
||
| function NavigateToNewLocationForm() { | ||
| cy.visit('/?action=locations_edit&origin=locations'); | ||
| } | ||
|
|
||
| function FillLocationForm(label) { | ||
| cy.get("input[id='field_label']").clear().type(label); | ||
| cy.selectOptionByText("box_state_id", "Instock"); | ||
| } | ||
|
|
||
| function ArchiveTestedLocation(label) { | ||
| cy.visit('/?action=locations'); | ||
| cy.get('body').then(($body) => { | ||
| if ($body.text().includes(label)) { | ||
| cy.checkGridCheckboxByText(label); | ||
| cy.get("button[data-testid='reactivate-cms-user']").click(); | ||
| cy.getConfirmActionButton().click(); | ||
| cy.waitForAjaxAction("do=archive", "Item deleted"); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| beforeEach(function () { | ||
| cy.setupAjaxActionHook(); | ||
| cy.loginAsCoordinator(); | ||
| }); | ||
|
|
||
| afterEach(function () { | ||
| ArchiveTestedLocation(Test_label_at_limit); | ||
| }); | ||
|
|
||
| it("6_1_1 Rejects a location name over the character limit with an inline error, and does not save it", () => { | ||
| NavigateToNewLocationForm(); | ||
| FillLocationForm(Test_label_over_limit); | ||
| cy.getButtonWithText("Save and close").click(); | ||
|
|
||
| cy.checkQtipWithText("qtip-content", "Please use 50 characters or fewer."); | ||
| // still on the form - the too-long name was never submitted | ||
| cy.url().should('include', 'action=locations_edit'); | ||
|
|
||
| cy.visit('/?action=locations'); | ||
| cy.get('body').should('not.contain', Test_label_prefix); | ||
| }); | ||
|
|
||
| it("6_1_2 Saves a location name that is exactly at the character limit", () => { | ||
| NavigateToNewLocationForm(); | ||
| FillLocationForm(Test_label_at_limit); | ||
| cy.getButtonWithText("Save and close").click(); | ||
|
|
||
| cy.url().should('include', 'action=locations'); | ||
| cy.getRowWithText(Test_label_at_limit).should('exist'); | ||
| }); | ||
| }); | ||
37 changes: 37 additions & 0 deletions
37
db/migrations/20260725095602_widen_locations_label_column.php
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use Phinx\Migration\AbstractMigration; | ||
|
|
||
| final class WidenLocationsLabelColumn extends AbstractMigration | ||
| { | ||
| /** | ||
| * Widens locations.label from varchar(20) to varchar(50) so that | ||
| * location names are no longer silently truncated by MySQL on save. | ||
| */ | ||
| public function up(): void | ||
| { | ||
| $this->table('locations') | ||
| ->changeColumn('label', 'string', [ | ||
| 'null' => false, | ||
| 'limit' => 50, | ||
| ]) | ||
| ->update() | ||
| ; | ||
| } | ||
|
|
||
| /** | ||
| * This will truncate labels that exceed the character limit. | ||
| */ | ||
| public function down(): void | ||
| { | ||
| $this->table('locations') | ||
| ->changeColumn('label', 'string', [ | ||
| 'null' => false, | ||
| 'limit' => 20, | ||
| ]) | ||
| ->update() | ||
| ; | ||
| } | ||
| } |
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
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
This file was deleted.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.