test: add selector control attribute validation tests#261
Merged
Conversation
Add comprehensive unit and e2e tests covering selector control value sanitization in Visual_Portfolio_Security: 1. Invalid selector values fall back to defaults - tests for select and icons_selector controls (posts_order_by, items_style, sort) 2. String 'true' option values work correctly - validates PR #208 fix for show_date and show_read_more controls 3. Dynamic value_callback selectors accept arbitrary values without resetting (post_types_set) PHPUnit: 20 new test cases covering sanitize_selector, sanitize_icons_selector, reset_control_attribute_to_default, and sanitize_attributes integration. Playwright E2E: 14 tests covering preview endpoint rendering and block rendering with invalid/valid selector values.
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
Add comprehensive unit and e2e tests to validate selector control attribute sanitization in
Visual_Portfolio_Security.Test Scenarios
1. Invalid selector values fall back to defaults
selecttype controls (posts_order_by) with invalid values reset to defaultsicons_selectortype controls (items_style,sort) with invalid values reset to defaults2. String
'true'option values work correctly (PR #208)show_datewith value'true'renders date metashow_datewith value'human'renders human-readable datesshow_datewith value'false'hides datesshow_datewith invalid value falls back to default'false'show_read_morewith value'true'renders read-more buttonsshow_read_morewith invalid value falls back to default3. Dynamic
value_callbackselectors accept arbitrary valuespost_types_set(which has avalue_callback) accepts arbitrary values without resettingTests Added
PHPUnit (
tests/phpunit/unit/test-class-security-selector.php)20 new test cases covering:
sanitize_selector()- valid/invalid values, boolean string mappingsanitize_icons_selector()- valid/invalid valuesreset_control_attribute_to_default()- default retrievalsanitize_attributes()- integration test with mixed valid/invalid valuesvalue_callbackcontrols bypass validationPlaywright E2E (
tests/e2e/specs/selector-control-values.spec.js)14 tests covering:
show_dateandshow_read_morecontrolsTest Results