feat: add polar x tts and storage integration adapters with tests

This commit is contained in:
Codex
2026-02-18 13:35:03 +00:00
parent de2ddf258f
commit d68ccc70bf
10 changed files with 678 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const { createXAdapter, findParentReplyId } = require("../src/integrations/x-client");
test("findParentReplyId returns replied_to reference id", () => {
const id = findParentReplyId({
referenced_tweets: [
{ type: "quoted", id: "q1" },
{ type: "replied_to", id: "p1" },
],
});
assert.equal(id, "p1");
});
test("listMentions fetches mention timeline", async () => {
const calls = [];
const adapter = createXAdapter({
botUserId: "bot-1",
client: {
v2: {
async userMentionTimeline(userId, opts) {
calls.push({ userId, opts });
return { data: [{ id: "m1" }] };
},
},
},
});
const mentions = await adapter.listMentions({ sinceId: "100" });
assert.equal(mentions.length, 1);
assert.equal(calls[0].userId, "bot-1");
assert.equal(calls[0].opts.since_id, "100");
});
test("fetchParentPostFromMention resolves parent tweet", async () => {
const adapter = createXAdapter({
botUserId: "bot-1",
client: {
v2: {
async singleTweet(id) {
if (id === "mention-1") {
return {
data: {
id,
referenced_tweets: [{ type: "replied_to", id: "parent-1" }],
},
};
}
return { data: { id, article: { title: "A", body: "B" } } };
},
},
},
});
const parent = await adapter.fetchParentPostFromMention("mention-1");
assert.equal(parent.id, "parent-1");
assert.equal(parent.article.title, "A");
});
test("replyToMention posts a reply", async () => {
const calls = [];
const adapter = createXAdapter({
botUserId: "bot-1",
client: {
v2: {
async reply(text, mentionId) {
calls.push({ text, mentionId });
return { data: { id: "reply-1" } };
},
},
},
});
const result = await adapter.replyToMention({ mentionTweetId: "m1", text: "done" });
assert.equal(result.data.id, "reply-1");
assert.equal(calls[0].mentionId, "m1");
});