From 576fe9f1555ba3e2d410d3ccef8bfa55026bf7bd Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Sun, 30 Aug 2026 18:47:06 -0700 Subject: [PATCH] Use named Atproto API exports Atproto 0.20 no longer includes BskyAgent or RichText on its default ESM export, which made BlueskyAgent construction fail at runtime. --- app/social/clients/BlueskyClient.mjs | 4 +--- app/social/clients/BlueskyClient.test.mjs | 25 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 app/social/clients/BlueskyClient.test.mjs diff --git a/app/social/clients/BlueskyClient.mjs b/app/social/clients/BlueskyClient.mjs index 147680a..cb12d86 100644 --- a/app/social/clients/BlueskyClient.mjs +++ b/app/social/clients/BlueskyClient.mjs @@ -1,9 +1,7 @@ -import atprotoApi from '@atproto/api'; +import { BskyAgent, RichText } from '@atproto/api'; import sharp from 'sharp'; import Client from './Client.mjs'; -const { BskyAgent, RichText } = atprotoApi; - export default class BlueskyClient extends Client { key = 'bluesky'; diff --git a/app/social/clients/BlueskyClient.test.mjs b/app/social/clients/BlueskyClient.test.mjs new file mode 100644 index 0000000..b00eb0f --- /dev/null +++ b/app/social/clients/BlueskyClient.test.mjs @@ -0,0 +1,25 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { BskyAgent } from '@atproto/api'; +import BlueskyClient from './BlueskyClient.mjs'; + +describe('BlueskyClient', () => { + afterEach(() => { + vi.restoreAllMocks(); + vi.unstubAllEnvs(); + }); + + it('logs in with the current Atproto agent API', async () => { + vi.stubEnv('BLUESKY_SERVICE', 'https://bsky.social'); + vi.stubEnv('BLUESKY_IDENTIFIER', 'test.bsky.social'); + vi.stubEnv('BLUESKY_PASSWORD', 'test-password'); + const login = vi.spyOn(BskyAgent.prototype, 'login').mockResolvedValue(); + const client = new BlueskyClient; + + await client.login(); + + expect(login).toHaveBeenCalledWith({ + identifier: 'test.bsky.social', + password: 'test-password', + }); + }); +});