Update index.test.ts
This commit is contained in:
parent
098db17913
commit
80250fb54f
@ -320,50 +320,50 @@ describe("E2E Tests for API Routes", () => {
|
|||||||
});
|
});
|
||||||
}, 120000);
|
}, 120000);
|
||||||
|
|
||||||
it("should return a successful response with a valid API key and valid onlyMainContent option", async () => {
|
// it("should return a successful response with a valid API key and valid limit option", async () => {
|
||||||
const crawlResponse = await request(TEST_URL)
|
// const crawlResponse = 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({
|
// .send({
|
||||||
url: "https://mendable.ai",
|
// url: "https://mendable.ai",
|
||||||
crawlerOptions: { onlyMainContent: true, limit: 10 },
|
// crawlerOptions: { limit: 10 },
|
||||||
});
|
// });
|
||||||
|
|
||||||
const response = await request(TEST_URL)
|
// const response = await request(TEST_URL)
|
||||||
.get(`/v0/crawl/status/${crawlResponse.body.jobId}`)
|
// .get(`/v0/crawl/status/${crawlResponse.body.jobId}`)
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`);
|
// .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`);
|
||||||
expect(response.statusCode).toBe(200);
|
// expect(response.statusCode).toBe(200);
|
||||||
expect(response.body).toHaveProperty("status");
|
// expect(response.body).toHaveProperty("status");
|
||||||
expect(response.body.status).toBe("active");
|
// expect(response.body.status).toBe("active");
|
||||||
|
|
||||||
let isCompleted = false;
|
// let isCompleted = false;
|
||||||
while (!isCompleted) {
|
// while (!isCompleted) {
|
||||||
const statusCheckResponse = await request(TEST_URL)
|
// const statusCheckResponse = await request(TEST_URL)
|
||||||
.get(`/v0/crawl/status/${crawlResponse.body.jobId}`)
|
// .get(`/v0/crawl/status/${crawlResponse.body.jobId}`)
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`);
|
// .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`);
|
||||||
expect(statusCheckResponse.statusCode).toBe(200);
|
// expect(statusCheckResponse.statusCode).toBe(200);
|
||||||
isCompleted = statusCheckResponse.body.status === "completed";
|
// isCompleted = statusCheckResponse.body.status === "completed";
|
||||||
if (!isCompleted) {
|
// if (!isCompleted) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second before checking again
|
// await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second before checking again
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
const completedResponse = await request(TEST_URL)
|
// const completedResponse = await request(TEST_URL)
|
||||||
.get(`/v0/crawl/status/${crawlResponse.body.jobId}`)
|
// .get(`/v0/crawl/status/${crawlResponse.body.jobId}`)
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`);
|
// .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`);
|
||||||
|
|
||||||
expect(completedResponse.statusCode).toBe(200);
|
// expect(completedResponse.statusCode).toBe(200);
|
||||||
expect(completedResponse.body).toHaveProperty("status");
|
// expect(completedResponse.body).toHaveProperty("status");
|
||||||
expect(completedResponse.body.status).toBe("completed");
|
// expect(completedResponse.body.status).toBe("completed");
|
||||||
expect(completedResponse.body).toHaveProperty("data");
|
// expect(completedResponse.body).toHaveProperty("data");
|
||||||
expect(completedResponse.body.data.length).toBe(10);
|
// expect(completedResponse.body.data.length).toBe(10);
|
||||||
expect(completedResponse.body.data[0]).toHaveProperty("content");
|
// expect(completedResponse.body.data[0]).toHaveProperty("content");
|
||||||
expect(completedResponse.body.data[0]).toHaveProperty("markdown");
|
// expect(completedResponse.body.data[0]).toHaveProperty("markdown");
|
||||||
expect(completedResponse.body.data[0]).toHaveProperty("metadata");
|
// expect(completedResponse.body.data[0]).toHaveProperty("metadata");
|
||||||
expect(completedResponse.body.data[0].content).toContain("Mendable");
|
// expect(completedResponse.body.data[0].content).toContain("Mendable");
|
||||||
expect(completedResponse.body.data[0].content).not.toContain("main menu");
|
// expect(completedResponse.body.data[0].content).not.toContain("main menu");
|
||||||
}, 60000); // 60 seconds
|
// }, 60000); // 60 seconds
|
||||||
|
|
||||||
it("should return a successful response for a valid crawl job with includeHtml set to true option", async () => {
|
it("should return a successful response for a valid crawl job with includeHtml set to true option", async () => {
|
||||||
const crawlResponse = await request(TEST_URL)
|
const crawlResponse = await request(TEST_URL)
|
||||||
|
Loading…
Reference in New Issue
Block a user