fix: adapt upstream commands to relay client
This commit is contained in:
@@ -6,10 +6,8 @@ import { TwitterClient } from '../src/lib/twitter-client.js';
|
||||
|
||||
const baseCtx = {
|
||||
resolveTimeoutFromOptions: () => undefined,
|
||||
resolveCredentialsFromOptions: async () => ({
|
||||
cookies: { authToken: 'auth', ct0: 'ct0', cookieHeader: 'auth=auth; ct0=ct0' },
|
||||
warnings: [],
|
||||
}),
|
||||
resolveRelayBaseUrlFromOptions: () => 'http://relay.test',
|
||||
resolveProfileNameFromOptions: () => undefined,
|
||||
p: () => '',
|
||||
} as unknown as CliContext;
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ import { TwitterClient } from '../src/lib/twitter-client.js';
|
||||
|
||||
const baseCtx = {
|
||||
resolveTimeoutFromOptions: () => undefined,
|
||||
resolveCredentialsFromOptions: async () => ({
|
||||
cookies: { authToken: 'auth', ct0: 'ct0', cookieHeader: 'auth=auth; ct0=ct0' },
|
||||
warnings: [],
|
||||
}),
|
||||
resolveRelayBaseUrlFromOptions: () => 'http://relay.test',
|
||||
resolveProfileNameFromOptions: () => undefined,
|
||||
p: () => '',
|
||||
l: () => '',
|
||||
printTweets: () => undefined,
|
||||
|
||||
@@ -2,8 +2,6 @@ import { spawn } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { resolveCredentials } from '../../src/lib/cookies.js';
|
||||
import { TwitterClient } from '../../src/lib/twitter-client.js';
|
||||
|
||||
type RunResult = { exitCode: number; stdout: string; stderr: string; signal: NodeJS.Signals | null };
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ import { spawn } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { resolveCredentials } from '../../src/lib/cookies.js';
|
||||
import { TwitterClient } from '../../src/lib/twitter-client.js';
|
||||
|
||||
type RunResult = { exitCode: number; stdout: string; stderr: string; signal: NodeJS.Signals | null };
|
||||
|
||||
|
||||
@@ -202,18 +202,19 @@ describe('TwitterClient getUserAboutAccount', () => {
|
||||
}),
|
||||
});
|
||||
|
||||
const client = new TwitterClient({ cookies: validCookies });
|
||||
const client = new TwitterClient({ relayBaseUrl: 'http://relay.test', profileName: 'test-profile' });
|
||||
await client.getUserAboutAccount('testuser');
|
||||
|
||||
expect(mockFetch).toHaveBeenCalledTimes(1);
|
||||
const [url, options] = mockFetch.mock.calls[0] as [string, RequestInit];
|
||||
|
||||
expect(url).toContain('http://relay.test/i/api/graphql/');
|
||||
expect(url).toContain('/AboutAccountQuery?');
|
||||
expect(url).toContain('variables=');
|
||||
expect(url).toContain('testuser');
|
||||
expect(options.method).toBe('GET');
|
||||
expect(options.headers).toMatchObject({
|
||||
'x-csrf-token': 'test_ct0_token',
|
||||
'x-profile-name': 'test-profile',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user