Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

Lock lexicon values and the URL paren-keep branch in tests

Paulo Castellano444d5220122f
diff --git a/tests/Feature/Services/Social/BlueskyPublisherTest.php b/tests/Feature/Services/Social/BlueskyPublisherTest.php
index 25de1134c..136c7b757 100644
--- a/tests/Feature/Services/Social/BlueskyPublisherTest.php
+++ b/tests/Feature/Services/Social/BlueskyPublisherTest.php
@@ -123,6 +123,27 @@ test('bluesky publisher strips trailing punctuation from URL facets', function (
});
});
+test('bluesky publisher keeps a closing paren that has a matching open paren', function () {
+ $this->post->update(['content' => 'see https://en.wikipedia.org/wiki/Foo_(bar)']);
+
+ Http::fake([
+ config('trypost.platforms.bluesky.default_service').'/xrpc/com.atproto.repo.createRecord' => Http::response([
+ 'uri' => 'at://did:plc:testuser123/app.bsky.feed.post/3abc123xyz',
+ 'cid' => 'bafyreiabc123',
+ ], 200),
+ ]);
+
+ $this->publisher->publish($this->postPlatform);
+
+ Http::assertSent(function ($request) {
+ $link = collect($request['record']['facets'] ?? [])
+ ->first(fn ($facet) => $facet['features'][0]['$type'] === 'app.bsky.richtext.facet#link');
+
+ // The trailing ')' is part of the URL because it has a matching '('.
+ return $link && $link['features'][0]['uri'] === 'https://en.wikipedia.org/wiki/Foo_(bar)';
+ });
+});
+
test('bluesky publisher computes byte offsets after multibyte characters', function () {
$this->post->update(['content' => 'Olá 🎉 #café']);
diff --git a/tests/Unit/Services/Social/BlueskyLexiconTest.php b/tests/Unit/Services/Social/BlueskyLexiconTest.php
new file mode 100644
index 000000000..47916f27e
--- /dev/null
+++ b/tests/Unit/Services/Social/BlueskyLexiconTest.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Services\Social\BlueskyLexicon;
+
+test('bluesky lexicon constants match their AT Protocol NSIDs', function (string $constant, string $nsid) {
+ expect($constant)->toBe($nsid);
+})->with([
+ [BlueskyLexicon::RESOLVE_HANDLE, 'com.atproto.identity.resolveHandle'],
+ [BlueskyLexicon::CREATE_RECORD, 'com.atproto.repo.createRecord'],
+ [BlueskyLexicon::UPLOAD_BLOB, 'com.atproto.repo.uploadBlob'],
+ [BlueskyLexicon::CREATE_SESSION, 'com.atproto.server.createSession'],
+ [BlueskyLexicon::REFRESH_SESSION, 'com.atproto.server.refreshSession'],
+ [BlueskyLexicon::FEED_POST, 'app.bsky.feed.post'],
+ [BlueskyLexicon::GET_POSTS, 'app.bsky.feed.getPosts'],
+ [BlueskyLexicon::GET_PROFILE, 'app.bsky.actor.getProfile'],
+ [BlueskyLexicon::EMBED_IMAGES, 'app.bsky.embed.images'],
+ [BlueskyLexicon::FACET_LINK, 'app.bsky.richtext.facet#link'],
+ [BlueskyLexicon::FACET_MENTION, 'app.bsky.richtext.facet#mention'],
+ [BlueskyLexicon::FACET_TAG, 'app.bsky.richtext.facet#tag'],
+]);