-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resolver resolution status key types mismatch causing unwanted re…
…solver calls for identical state data (#52120) * Normalize * Add optional method property to normalize arguments before usage * Check for ID-like keys rather than numeric things Accounts for cases such as ‘this-is-a-slug-1234’ * Extract util and update to use suggestion from Code Review * Test for util * Add tests for normalizeArgs * Fix bug with normalizeArgs called even if there are no args * Add direct test on `normalizeArgs` method of getEntityRecord * Allow defining normalize method on selector and call for both selector and resolver * Move normalization function to getEntityRecord selector * Move normalization functino to getEntityRecord selector * Add rough outline of documentation * Add test to ensure normalization is applied to selector even without matching resolver * Improve documentation to better explain concept of normalizeArgs * Correct grammar * Apply types optimisation from code review See #52120 (comment) * Extract conditionals to helper function As per code review * Document getEntityRecord normalization function * Add type defs to normalization function * Fix nits in README * Remove new line * Add test for arguments length before invoking normalization function * Remove unwanted comment * Addition to docs as per code review #52120 (comment) * Fix bug with metadata selector args not being normalized * Add tests for normalization to metadata selector tests * Add test case for decimals * Prefix with __unstable to denote non “settled” approach amongst contributors * Remove check for args and conditionally access args index Addresses #52120 (comment) * Simplify coercing to number * Revert confusing DRY typescript * Fix renaming selector to `unstable` * Copy to new args Addresses https://github.com/WordPress/gutenberg/pull/52120/files#r1260851646
- Loading branch information
Showing
9 changed files
with
317 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,10 @@ | ||
/** | ||
* Checks argument to determine if it's a numeric ID. | ||
* For example, '123' is a numeric ID, but '123abc' is not. | ||
* | ||
* @param {any} id the argument to determine if it's a numeric ID. | ||
* @return {boolean} true if the string is a numeric ID, false otherwise. | ||
*/ | ||
export default function isNumericID( id ) { | ||
return /^\s*\d+\s*$/.test( id ); | ||
} |
This file contains 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,22 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import isNumericID from '../is-numeric-id'; | ||
|
||
describe( 'isNumericID', () => { | ||
test.each( [ | ||
[ true, '12345' ], | ||
[ true, '42' ], | ||
[ true, ' 42 ' ], | ||
[ false, 'abc123' ], | ||
[ false, '123abc' ], | ||
[ false, '' ], | ||
[ false, '123-abc' ], | ||
[ false, 'abc-123' ], | ||
[ false, '42-test-123' ], | ||
[ false, '3.42' ], | ||
[ true, 123 ], | ||
] )( `should return %s for input "%s"`, ( expected, input ) => { | ||
expect( isNumericID( input ) ).toBe( expected ); | ||
} ); | ||
} ); |
This file contains 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 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 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
Oops, something went wrong.
2155576
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 2155576.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6536842990
📝 Reported issues:
/test/e2e/specs/editor/various/writing-flow.spec.js