feat: support relay profile selection
CI / test (push) Successful in 10m2s

This commit is contained in:
2026-06-24 18:30:24 +09:00
parent 7a036e244d
commit 3f370cc4b6
24 changed files with 160 additions and 25 deletions
@@ -124,6 +124,41 @@ describe('TwitterClient core coverage', () => {
expect(headers).toEqual({});
});
it('adds x-profile-name header when profileName is set', () => {
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl, profileName: 'work' });
const clientPrivate = client as unknown as TwitterClientPrivate;
expect(clientPrivate.getHeaders()).toEqual({ 'x-profile-name': 'work' });
});
it('ignores blank profileName values', () => {
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl, profileName: ' ' });
const clientPrivate = client as unknown as TwitterClientPrivate;
expect(clientPrivate.getHeaders()).toEqual({});
});
it('adds x-profile-name to JSON headers when profileName is set', () => {
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl, profileName: 'work' });
const clientPrivate = client as unknown as TwitterClientPrivate & {
getJsonHeaders: () => Record<string, string>;
};
expect(clientPrivate.getJsonHeaders()).toEqual({
'content-type': 'application/json',
'x-profile-name': 'work',
});
});
it('adds x-profile-name to upload headers when profileName is set', () => {
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl, profileName: 'work' });
const clientPrivate = client as unknown as TwitterClientPrivate & {
getUploadHeaders: () => Record<string, string>;
};
expect(clientPrivate.getUploadHeaders()).toEqual({ 'x-profile-name': 'work' });
});
describe('fetchUserArticlePlainText failures', () => {
it('returns empty object when response is not ok', async () => {
const mockFetch = vi.fn().mockResolvedValueOnce(makeResponse({ ok: false, status: 500 }));