This commit is contained in:
@@ -15,7 +15,7 @@ type TwitterClientPrivate = TwitterClient & {
|
||||
refreshQueryIds: () => Promise<void>;
|
||||
fetchWithTimeout: (url: string, init: RequestInit) => Promise<ResponseLike>;
|
||||
ensureClientUserId: () => Promise<void>;
|
||||
getBaseHeaders: () => Record<string, string>;
|
||||
getHeaders: () => Record<string, string>;
|
||||
fetchUserArticlePlainText: (userId: string, tweetId: string) => Promise<{ title?: string; plainText?: string }>;
|
||||
fetchTweetDetail: (tweetId: string) => Promise<{ success: true } | { success: false; error: string }>;
|
||||
postStatusUpdate: (input: { text: string }) => Promise<{ success: boolean; error?: string }>;
|
||||
@@ -108,7 +108,7 @@ describe('TwitterClient core coverage', () => {
|
||||
expect(result.error).toBe('Tweet not found in response');
|
||||
});
|
||||
|
||||
it('adds client user id header after ensureClientUserId', async () => {
|
||||
it('does not add Twitter headers after ensureClientUserId', async () => {
|
||||
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
@@ -119,9 +119,9 @@ describe('TwitterClient core coverage', () => {
|
||||
|
||||
const clientPrivate = client as unknown as TwitterClientPrivate;
|
||||
await clientPrivate.ensureClientUserId();
|
||||
const headers = clientPrivate.getBaseHeaders();
|
||||
const headers = clientPrivate.getHeaders();
|
||||
|
||||
expect(headers['x-twitter-client-user-id']).toBe('42');
|
||||
expect(headers).toEqual({});
|
||||
});
|
||||
|
||||
describe('fetchUserArticlePlainText failures', () => {
|
||||
|
||||
@@ -68,9 +68,7 @@ describe('TwitterClient tweet', () => {
|
||||
expect(String(url)).toContain(`${testRelayBaseUrl}/i/api/graphql/`);
|
||||
expect(String(url)).toContain('CreateTweet');
|
||||
expect(options.method).toBe('POST');
|
||||
expect(options.headers).not.toHaveProperty('cookie');
|
||||
expect(options.headers).not.toHaveProperty('authorization');
|
||||
expect(options.headers).not.toHaveProperty('x-csrf-token');
|
||||
expect(options.headers).toEqual({ 'content-type': 'application/json' });
|
||||
|
||||
const body = JSON.parse(options.body);
|
||||
expect(body.variables.tweet_text).toBe('Hello world!');
|
||||
@@ -392,9 +390,10 @@ describe('TwitterClient reply', () => {
|
||||
const [, options] = mockFetch.mock.calls[1];
|
||||
expect(String(mockFetch.mock.calls[1][0])).toContain('statuses/update.json');
|
||||
expect(options.method).toBe('POST');
|
||||
expect(options.body).toContain('status=This+is+a+reply');
|
||||
expect(options.body).toContain('in_reply_to_status_id=1234567890');
|
||||
expect(options.body).toContain('auto_populate_reply_metadata=true');
|
||||
expect(options.body).toContain('media_ids=111%2C222');
|
||||
const body = String(options.body);
|
||||
expect(body).toContain('status=This+is+a+reply');
|
||||
expect(body).toContain('in_reply_to_status_id=1234567890');
|
||||
expect(body).toContain('auto_populate_reply_metadata=true');
|
||||
expect(body).toContain('media_ids=111%2C222');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user