trypost/tests/Unit/PostPlatformMetaRulesTest.php

34 lines
1.1 KiB
PHP
Raw Normal View History

Add optional Pinterest pin title and destination link (#232) * Add optional Pinterest pin title, description, and link. Expose title/description/link across web, API, and MCP; seed description from caption into meta on save, and publish description only from meta. Co-authored-by: Cursor <cursoragent@cursor.com> * Expand Pinterest title/description/link test coverage. Cover web draft persistence and validation bounds, API/MCP update merge and seed, and publisher payload fields on video and carousel pins. Co-authored-by: Cursor <cursoragent@cursor.com> * Simplify Pinterest: description is post content again. Keep optional title and link in meta/settings only. Remove the separate description textarea, seed logic, and meta.description path so Pinterest follows the shared caption pattern. Co-authored-by: Cursor <cursoragent@cursor.com> * Refactor Pinterest meta handling and validation. - Update CreatePost and UpdatePost actions to filter out null values from meta fields. - Introduce a new method in PinterestPublisher to resolve board IDs, ensuring required fields are validated. - Enhance PinterestSettings component to manage title and link inputs, including validation for HTTP URLs. - Update PostPlatformMetaRules to enforce URL validation for Pinterest links. - Add tests for clearing Pinterest title and link, and for rejecting invalid links during scheduling. This refactor improves the handling of Pinterest metadata and enhances user experience by ensuring proper validation and error handling. * Add validation messages and attributes for Pinterest meta fields - Introduced custom validation messages and friendly attribute names for Pinterest link and title fields in PostPlatformMetaRules. - Updated StorePostRequest, UpdatePostRequest, and related tools to utilize these new messages and attributes. - Enhanced tests to assert correct error messages for invalid Pinterest links and title length constraints. This update improves user feedback during post creation and editing, ensuring clarity in validation errors. * Remove click.prevent directive from Pinterest link in PinterestPreview component. This change simplifies the link behavior, allowing default click actions to occur, which may enhance user interaction with the Pinterest link. * Update validation error messages for Pinterest meta fields in tests - Refined the assertions in PostApiPlatformMetaTest to include localized validation messages for Pinterest title and link fields. - Ensured that error messages reflect the updated validation rules, enhancing clarity for users during post creation and editing. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 21:15:50 +00:00
<?php
declare(strict_types=1);
use App\Support\PostPlatformMetaRules;
test('custom meta messages only cover pinterest title and link', function () {
expect(PostPlatformMetaRules::messages())->toBe([
'platforms.*.meta.link.url' => __('posts.form.pinterest.link_invalid'),
'platforms.*.meta.link.max' => __('posts.form.pinterest.link_max'),
'platforms.*.meta.title.max' => __('posts.form.pinterest.title_max'),
]);
});
test('custom meta attributes only rename pinterest title and link', function () {
expect(PostPlatformMetaRules::attributes())->toBe([
'platforms.*.meta.title' => __('posts.form.pinterest.title'),
'platforms.*.meta.link' => __('posts.form.pinterest.link'),
]);
});
test('shared meta rules still include non-pinterest platform fields', function () {
$rules = PostPlatformMetaRules::rules();
expect($rules)->toHaveKeys([
'platforms.*.meta.aspect_ratio',
'platforms.*.meta.privacy_level',
'platforms.*.meta.board_id',
'platforms.*.meta.channel_id',
'platforms.*.meta.title',
'platforms.*.meta.link',
]);
});