test(e2e): generate relay fixture types from OpenAPI

This commit is contained in:
2026-08-12 00:24:55 +09:00
parent 8eb299f46d
commit 5406855e1c
8 changed files with 4090 additions and 44 deletions
+35
View File
@@ -0,0 +1,35 @@
import type { TweetLegacy } from '../generated/twitter-openapi/client.ts'
interface TweetLegacyFixtureOptions {
conversationId?: string
inReplyTo?: string
replyCount?: number
}
export const tweetLegacyFixture = (
id: string,
text: string,
{
conversationId = id,
inReplyTo,
replyCount = 1,
}: TweetLegacyFixtureOptions = {},
): TweetLegacy => ({
bookmark_count: 0,
bookmarked: false,
conversation_id_str: conversationId,
created_at: 'Mon Jul 13 00:00:00 +0000 2026',
display_text_range: [0, text.length],
favorite_count: 3,
favorited: false,
full_text: text,
id_str: id,
...(inReplyTo ? { in_reply_to_status_id_str: inReplyTo } : {}),
is_quote_status: false,
lang: 'ja',
quote_count: 0,
reply_count: replyCount,
retweet_count: 2,
retweeted: false,
user_id_str: '42',
})
File diff suppressed because it is too large Load Diff
+6 -9
View File
@@ -1,4 +1,5 @@
import { createServer } from 'node:http'
import { tweetLegacyFixture } from './fixtures/twitter.ts'
const portValue = process.env.TWITTER_LITE_MOCK_RELAY_PORT
const port = Number(portValue)
@@ -30,15 +31,11 @@ const tweetResult = (
{ conversationId = id, inReplyTo, replyCount = 1 } = {},
) => ({
rest_id: id,
legacy: {
full_text: text,
created_at: 'Mon Jul 13 00:00:00 +0000 2026',
reply_count: replyCount,
retweet_count: 2,
favorite_count: 3,
conversation_id_str: conversationId,
...(inReplyTo ? { in_reply_to_status_id_str: inReplyTo } : {}),
},
legacy: tweetLegacyFixture(id, text, {
conversationId,
inReplyTo,
replyCount,
}),
core: {
user_results: {
result: {