Skip to content

Commit

Permalink
Add integration test cases showing and dismissing of toasts (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
SDaniV authored Dec 4, 2024
1 parent 3bdd5a4 commit 1512edf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 7 additions & 3 deletions cypress/e2e/tests.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Chat Bot Test Suite", () => {

it("Opens the chat window", () => {
cy.get(".rcb-toggle-button").click();
cy.get(".rcb-window-open").should("exist");
cy.get(".rcb-window-open").should("exist");
});

it("Sends name and verifies bot reply", () => {
Expand Down Expand Up @@ -116,20 +116,24 @@ describe("Chat Bot Test Suite", () => {

it("Send food and verifies bot reply", () => {
cy.get(".bold").should('have.css', 'font-weight')
.then((fontWeight) => +fontWeight).and('be.gte', 700)
.then((fontWeight) => +fontWeight).and('be.gte', 700)
cy.get(".rcb-chat-input-textarea")
.should("be.visible")
.type("pasta{enter}");
cy.get(".rcb-bot-message").contains("pasta? Interesting.").should("be.visible");
});

it("Send image and verifies bot reply", () => {
it("Sends image and verifies bot reply, checks the toast message and clicks on it", () => {
const filePath = path.resolve("./assets/logo.png");
cy.get(".rcb-attach-input").should("exist").attachFile(filePath);
cy.get(".rcb-bot-message").should(
"contain.text",
"Thank you for sharing! See you again!"
);

cy.get(".rcb-toast-prompt").should("be.visible");
cy.get(".rcb-toast-prompt").click();
cy.get(".rcb-toast-prompt").should("not.exist");
});

it("Sends goodbye, scrolls away, and verifies new message prompt", () => {
Expand Down
7 changes: 5 additions & 2 deletions cypress/fixtures/templates/ChatBotApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ function App() {
path: "ask_image"
},
ask_image: {
message: (params: Params) => `${params.userInput}? Interesting. Could you share an image of that?`,
message: (params: Params) =>
`${params.userInput}? Interesting. Could you share an image of that?`,
file: (params: Params) => console.log(params.files),
path: "end"
function: (params: Params) =>
params.showToast("Image is uploaded successfully!"),
path: "end",
},
end: {
message: "Thank you for sharing! See you again!",
Expand Down
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ function App() {
path: "ask_image"
},
ask_image: {
message: (params: Params) => `${params.userInput}? Interesting. Could you share an image of that?`,
message: (params: Params) =>
`${params.userInput}? Interesting. Could you share an image of that?`,
file: (params: Params) => console.log(params.files),
path: "end"
function: (params: Params) =>
params.showToast("Image is uploaded successfully!"),
path: "end",
},
end: {
message: "Thank you for sharing! See you again!",
Expand Down

0 comments on commit 1512edf

Please sign in to comment.