From 1512edfe1807c15d8db6d15dbc4297f1403632d7 Mon Sep 17 00:00:00 2001 From: SDaniV <33451448+SDaniV@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:15:52 +0200 Subject: [PATCH] Add integration test cases showing and dismissing of toasts (#280) --- cypress/e2e/tests.cy.ts | 10 +++++++--- cypress/fixtures/templates/ChatBotApp.tsx | 7 +++++-- src/App.tsx | 7 +++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/tests.cy.ts b/cypress/e2e/tests.cy.ts index 9e6c0214..70358e95 100644 --- a/cypress/e2e/tests.cy.ts +++ b/cypress/e2e/tests.cy.ts @@ -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", () => { @@ -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", () => { diff --git a/cypress/fixtures/templates/ChatBotApp.tsx b/cypress/fixtures/templates/ChatBotApp.tsx index 23ef3211..69f65905 100644 --- a/cypress/fixtures/templates/ChatBotApp.tsx +++ b/cypress/fixtures/templates/ChatBotApp.tsx @@ -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!", diff --git a/src/App.tsx b/src/App.tsx index a83dfce7..ceef700a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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!",