0

Update index.test.ts

This commit is contained in:
Nicolas 2024-05-19 12:50:06 -07:00
parent 614c073af0
commit 18fa15df25

View File

@ -977,43 +977,43 @@ describe("E2E Tests for API Routes", () => {
}, 60000); }, 60000);
}); });
it("should return 429 when rate limit is exceeded for API key", async () => { // it("should return 429 when rate limit is exceeded for API key", async () => {
for (let i = 0; i < parseInt(process.env.RATE_LIMIT_TEST_API_KEY_SCRAPE); i++) { // for (let i = 0; i < parseInt(process.env.RATE_LIMIT_TEST_API_KEY_SCRAPE); i++) {
const response = await request(TEST_URL) // const response = await request(TEST_URL)
.post("/v0/scrape") // .post("/v0/scrape")
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`) // .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
.set("Content-Type", "application/json") // .set("Content-Type", "application/json")
.send({ url: "https://www.scrapethissite.com" }); // .send({ url: "https://www.scrapethissite.com" });
expect(response.statusCode).toBe(200); // expect(response.statusCode).toBe(200);
} // }
const response = await request(TEST_URL) // const response = await request(TEST_URL)
.post("/v0/scrape") // .post("/v0/scrape")
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`) // .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
.set("Content-Type", "application/json") // .set("Content-Type", "application/json")
.send({ url: "https://www.scrapethissite.com" }); // .send({ url: "https://www.scrapethissite.com" });
expect(response.statusCode).toBe(429); // expect(response.statusCode).toBe(429);
}, 60000); // }, 60000);
it("should return 429 when rate limit is exceeded for API key", async () => { // it("should return 429 when rate limit is exceeded for API key", async () => {
for (let i = 0; i < parseInt(process.env.RATE_LIMIT_TEST_API_KEY_CRAWL); i++) { // for (let i = 0; i < parseInt(process.env.RATE_LIMIT_TEST_API_KEY_CRAWL); i++) {
const response = await request(TEST_URL) // const response = await request(TEST_URL)
.post("/v0/crawl") // .post("/v0/crawl")
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`) // .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
.set("Content-Type", "application/json") // .set("Content-Type", "application/json")
.send({ url: "https://www.scrapethissite.com" }); // .send({ url: "https://www.scrapethissite.com" });
expect(response.statusCode).toBe(200); // expect(response.statusCode).toBe(200);
} // }
const response = await request(TEST_URL) // const response = await request(TEST_URL)
.post("/v0/crawl") // .post("/v0/crawl")
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`) // .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
.set("Content-Type", "application/json") // .set("Content-Type", "application/json")
.send({ url: "https://www.scrapethissite.com" }); // .send({ url: "https://www.scrapethissite.com" });
expect(response.statusCode).toBe(429); // expect(response.statusCode).toBe(429);
}, 60000); // }, 60000);
}); });