This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { TwitterClient } from '../src/lib/twitter-client.js';
|
import { TwitterClient } from '../src/lib/twitter-client.js';
|
||||||
import { validCookies } from './twitter-client-fixtures.js';
|
import { testRelayBaseUrl } from './twitter-client-fixtures.js';
|
||||||
|
|
||||||
const originalFetch = global.fetch;
|
const originalFetch = global.fetch;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
json: async () => ({ data: { favorite_tweet: 'Done' } }),
|
json: async () => ({ data: { favorite_tweet: 'Done' } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.like('1234567890');
|
const result = await client.like('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -45,7 +45,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
text: async () => 'Forbidden',
|
text: async () => 'Forbidden',
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.like('1234567890');
|
const result = await client.like('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -61,7 +61,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.like('1234567890');
|
const result = await client.like('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -75,7 +75,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
json: async () => ({ data: { favorite_tweet: 'Done' } }),
|
json: async () => ({ data: { favorite_tweet: 'Done' } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.like('1234567890');
|
const result = await client.like('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -91,7 +91,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
json: async () => ({ data: { unfavorite_tweet: 'Done' } }),
|
json: async () => ({ data: { unfavorite_tweet: 'Done' } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.unlike('1234567890');
|
const result = await client.unlike('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -111,7 +111,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
json: async () => ({ data: { create_retweet: { retweet_results: { result: {} } } } }),
|
json: async () => ({ data: { create_retweet: { retweet_results: { result: {} } } } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.retweet('1234567890');
|
const result = await client.retweet('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -131,7 +131,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
json: async () => ({ data: { unretweet: { source_tweet_results: {} } } }),
|
json: async () => ({ data: { unretweet: { source_tweet_results: {} } } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.unretweet('1234567890');
|
const result = await client.unretweet('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -154,7 +154,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
json: async () => ({ data: { tweet_bookmark_put: 'Done' } }),
|
json: async () => ({ data: { tweet_bookmark_put: 'Done' } }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.bookmark('1234567890');
|
const result = await client.bookmark('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -170,7 +170,7 @@ describe('TwitterClient engagement', () => {
|
|||||||
it('catches network errors', async () => {
|
it('catches network errors', async () => {
|
||||||
mockFetch.mockRejectedValueOnce(new Error('Network error'));
|
mockFetch.mockRejectedValueOnce(new Error('Network error'));
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.like('1234567890');
|
const result = await client.like('1234567890');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { TwitterClient } from '../src/lib/twitter-client.js';
|
import { TwitterClient } from '../src/lib/twitter-client.js';
|
||||||
import { validCookies } from './twitter-client-fixtures.js';
|
import { testRelayBaseUrl } from './twitter-client-fixtures.js';
|
||||||
|
|
||||||
const originalFetch = global.fetch;
|
const originalFetch = global.fetch;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -67,7 +67,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('@testuser');
|
const result = await client.getUserAboutAccount('@testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
@@ -75,7 +75,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns error for invalid username', async () => {
|
it('returns error for invalid username', async () => {
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('');
|
const result = await client.getUserAboutAccount('');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -95,7 +95,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -111,7 +111,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -125,7 +125,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
text: async () => 'Not Found',
|
text: async () => 'Not Found',
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -139,7 +139,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
text: async () => 'Internal Server Error',
|
text: async () => 'Internal Server Error',
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -149,7 +149,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
it('handles network errors', async () => {
|
it('handles network errors', async () => {
|
||||||
mockFetch.mockRejectedValueOnce(new Error('Network error'));
|
mockFetch.mockRejectedValueOnce(new Error('Network error'));
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(false);
|
expect(result.success).toBe(false);
|
||||||
@@ -174,7 +174,7 @@ describe('TwitterClient getUserAboutAccount', () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new TwitterClient({ cookies: validCookies });
|
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||||
const result = await client.getUserAboutAccount('testuser');
|
const result = await client.getUserAboutAccount('testuser');
|
||||||
|
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
|
|||||||
@@ -5,3 +5,4 @@
|
|||||||
- When the user asks to investigate odd API counts, do not change client-side limiting behavior unless they explicitly approve the behavior change.
|
- When the user asks to investigate odd API counts, do not change client-side limiting behavior unless they explicitly approve the behavior change.
|
||||||
- When adding package registry publishing for this repository, use the `@yuta` package scope unless the user explicitly asks for another namespace.
|
- When adding package registry publishing for this repository, use the `@yuta` package scope unless the user explicitly asks for another namespace.
|
||||||
- Gitea Actions secret and variable names are case-insensitive, alphanumeric or underscore only, and cannot start with `GITEA_` or `GITHUB_`; use names like `PACKAGE_TOKEN`.
|
- Gitea Actions secret and variable names are case-insensitive, alphanumeric or underscore only, and cannot start with `GITEA_` or `GITHUB_`; use names like `PACKAGE_TOKEN`.
|
||||||
|
- When adapting upstream tests to this fork, run tests with `TWITTER_RELAY_BASE_URL` unset; local relay environment variables can hide missing explicit `relayBaseUrl` fixtures.
|
||||||
|
|||||||
Reference in New Issue
Block a user