-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for the api routes (#3666)
- Loading branch information
Showing
10 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
context("POST /api/ai", () => { | ||
it("gets an ai response for a given prompty", () => { | ||
cy.request("POST", "/api/ai", { | ||
prompt: "How do I create a primary button", | ||
secret: Cypress.env("OPENAI_API_SECRET"), | ||
}).then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body).length.to.be.greaterThan(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
context("GET /api/discussions-search", () => { | ||
it("gets a list of discussions", () => { | ||
cy.request("POST", "/api/discussions-search", { prompt: "creating a button" }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body.data).length.to.be.greaterThan(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
context("GET /api/docs-search", () => { | ||
it("gets a list of docs", () => { | ||
cy.request("POST", "/api/docs-search", { prompt: "creating a button" }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body.data).length.to.be.greaterThan(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
context("GET /api/og-image", () => { | ||
it("gets an image", () => { | ||
cy.request("GET", "/api/og-image?componentRequested=primitives/box").then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.headers["content-type"]).to.eq("image/png"); | ||
console.log(response); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
context("POST /api/paste-assistant-message", () => { | ||
let threadId: string; | ||
|
||
before(() => { | ||
// create a thread for the message | ||
cy.request("POST", "/api/paste-assistant-thread", {}).then((response) => { | ||
threadId = response.body.id; | ||
}); | ||
}); | ||
|
||
after(() => { | ||
// delete the thread | ||
cy.request("DELETE", "/api/paste-assistant-thread", { id: threadId }); | ||
}); | ||
|
||
it("creates an message on an ai thread", () => { | ||
// create a message on the thread | ||
cy.request("POST", "/api/paste-assistant-message", { threadId, message: "create a button" }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
}); | ||
|
||
it("gets messages on an ai thread", () => { | ||
// get messages on the thread | ||
cy.request("GET", `/api/paste-assistant-messages/${threadId}`).then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body.data).length.to.be.greaterThan(0); | ||
expect(response.body.data[0].content[0].text.value).to.eq("create a button"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
context("POST /api/paste-assistant-thread", () => { | ||
let threadId: string; | ||
it("creates an ai thread", () => { | ||
cy.request("POST", "/api/paste-assistant-thread", {}).then((response) => { | ||
expect(response.status).to.eq(200); | ||
threadId = response.body.id; | ||
}); | ||
}); | ||
it("updates an ai thread", () => { | ||
cy.request("PUT", "/api/paste-assistant-thread", { id: threadId, metadata: { testKey: "testData" } }).then( | ||
(response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body.metadata.testKey).to.eq("testData"); | ||
}, | ||
); | ||
}); | ||
it("gets an ai thread", () => { | ||
cy.request("GET", `/api/paste-assistant-thread/${threadId}`).then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body.metadata.testKey).to.eq("testData"); | ||
}); | ||
}); | ||
it("deletes an ai thread", () => { | ||
cy.request("DELETE", "/api/paste-assistant-thread", { id: threadId }).then((response) => { | ||
expect(response.status).to.eq(200); | ||
expect(response.body.deleted).to.eq(true); | ||
}); | ||
}); | ||
}); |
6a4f6e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
paste-remix – ./
paste-remix-theta.vercel.app
paste-remix-git-main-twilio.vercel.app
paste-remix-twilio.vercel.app
remix.twilio.design