feat(client): add handle429Backoff method for intelligent rate limit handling
This commit is contained in:
@@ -41,15 +41,17 @@ tap.test('browser: should handle request timeouts', async () => {
|
||||
let timedOut = false;
|
||||
|
||||
const options: ICoreRequestOptions = {
|
||||
timeout: 1000
|
||||
timeout: 100 // Very short timeout
|
||||
};
|
||||
|
||||
try {
|
||||
const request = new CoreRequest('https://httpbin.org/delay/10', options);
|
||||
// Use a URL that will likely take longer than 100ms
|
||||
const request = new CoreRequest('https://jsonplaceholder.typicode.com/photos', options);
|
||||
await request.fire();
|
||||
} catch (error) {
|
||||
timedOut = true;
|
||||
expect(error.message).toContain('timed out');
|
||||
// Different browsers might have different timeout error messages
|
||||
expect(error.message.toLowerCase()).toMatch(/timeout|timed out|aborted/i);
|
||||
}
|
||||
|
||||
expect(timedOut).toEqual(true);
|
||||
@@ -82,21 +84,22 @@ tap.test('browser: should handle POST requests with JSON', async () => {
|
||||
tap.test('browser: should handle query parameters', async () => {
|
||||
const options: ICoreRequestOptions = {
|
||||
queryParams: {
|
||||
foo: 'bar',
|
||||
baz: 'qux'
|
||||
userId: '2'
|
||||
}
|
||||
};
|
||||
|
||||
const request = new CoreRequest('https://httpbin.org/get', options);
|
||||
const request = new CoreRequest('https://jsonplaceholder.typicode.com/posts', options);
|
||||
const response = await request.fire();
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
|
||||
const data = await response.json();
|
||||
expect(data.args).toHaveProperty('foo');
|
||||
expect(data.args.foo).toEqual('bar');
|
||||
expect(data.args).toHaveProperty('baz');
|
||||
expect(data.args.baz).toEqual('qux');
|
||||
expect(Array.isArray(data)).toBeTrue();
|
||||
// Verify we got posts filtered by userId 2
|
||||
if (data.length > 0) {
|
||||
expect(data[0]).toHaveProperty('userId');
|
||||
expect(data[0].userId).toEqual(2);
|
||||
}
|
||||
});
|
||||
|
||||
export default tap.start();
|
Reference in New Issue
Block a user