2026-07-11 11:38:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Enums\SocialAccount\Platform;
|
|
|
|
|
|
|
|
|
|
test('altTextMaxLength returns the documented cap for supporting platforms', function () {
|
|
|
|
|
expect(Platform::Bluesky->altTextMaxLength())->toBe(2000)
|
|
|
|
|
->and(Platform::X->altTextMaxLength())->toBe(1000)
|
|
|
|
|
->and(Platform::Mastodon->altTextMaxLength())->toBe(1500)
|
|
|
|
|
->and(Platform::LinkedIn->altTextMaxLength())->toBe(4086)
|
2026-07-11 13:34:57 +00:00
|
|
|
->and(Platform::LinkedInPage->altTextMaxLength())->toBe(4086)
|
2026-07-11 11:38:42 +00:00
|
|
|
->and(Platform::Instagram->altTextMaxLength())->toBe(1000)
|
2026-07-11 13:34:57 +00:00
|
|
|
->and(Platform::InstagramFacebook->altTextMaxLength())->toBe(1000)
|
2026-07-11 11:38:42 +00:00
|
|
|
->and(Platform::Pinterest->altTextMaxLength())->toBe(500)
|
|
|
|
|
->and(Platform::Discord->altTextMaxLength())->toBe(1024)
|
|
|
|
|
->and(Platform::Facebook->altTextMaxLength())->toBe(1000)
|
|
|
|
|
->and(Platform::Threads->altTextMaxLength())->toBe(1000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('altTextMaxLength is null for platforms without alt-text support', function () {
|
|
|
|
|
expect(Platform::TikTok->altTextMaxLength())->toBeNull()
|
|
|
|
|
->and(Platform::Telegram->altTextMaxLength())->toBeNull()
|
|
|
|
|
->and(Platform::YouTube->altTextMaxLength())->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('supportsAltText mirrors altTextMaxLength', function () {
|
|
|
|
|
expect(Platform::Bluesky->supportsAltText())->toBeTrue()
|
2026-07-11 13:34:57 +00:00
|
|
|
->and(Platform::LinkedInPage->supportsAltText())->toBeTrue()
|
|
|
|
|
->and(Platform::InstagramFacebook->supportsAltText())->toBeTrue()
|
2026-07-11 11:38:42 +00:00
|
|
|
->and(Platform::TikTok->supportsAltText())->toBeFalse();
|
|
|
|
|
});
|
Harden per-image alt text across publishers, validation, and attach paths
Publishing:
- Only send alt text for images (isImage guards on LinkedIn, X, Discord, Mastodon); never inject altText into video/document payloads.
- X sets alt via a best-effort media/metadata call so a metadata failure no longer blocks the tweet.
Validation:
- Validate media alt_text with a closure on media.*.meta so width/height/duration/slide_* survive a post update (Laravel's excludeUnvalidatedArrayKeys was stripping them).
- Add ALT_TEXT_MAX_LENGTH constant, a proper string-type error, and a localized attribute name.
Media attach (REST + MCP):
- Support per-image alt on attach-media-from-url via structured urls: [{url, alt?}] and on the MCP upload tool via an optional alt; alt is stored only for images.
- Carry submitted meta onto hosted external-URL media so alt is no longer dropped.
Composer:
- Alt-text dialog disables Save and reddens the counter over the limit, counting code points of the trimmed value to match the backend.
- Autosave shows 'Saved' only on a successful response; the lightbox alt overlay renders for images only.
Adds unit, feature, MCP, and browser tests covering every path above.
2026-07-16 16:55:33 +00:00
|
|
|
|
|
|
|
|
test('altTextMaxLength is defined for every platform so a new case cannot slip through', function () {
|
|
|
|
|
foreach (Platform::cases() as $platform) {
|
|
|
|
|
$max = $platform->altTextMaxLength();
|
|
|
|
|
|
|
|
|
|
expect($max === null || (is_int($max) && $max > 0))->toBeTrue();
|
|
|
|
|
}
|
|
|
|
|
});
|