diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/editMessageButton/newMessageOptions.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/editMessageButton/newMessageOptions.tsx index 3e8a03b5d911..2ec2be4a65c6 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/editMessageButton/newMessageOptions.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/components/editMessageButton/newMessageOptions.tsx @@ -76,6 +76,7 @@ export function EditMessageButton({ size="icon" onClick={() => handleEvaluate(true)} className="h-8 w-8" + data-testid="helpful-button" > handleEvaluate(false)} className="h-8 w-8" + data-testid="not-helpful-button" > New chat -

+

Test your flow with a chat prompt diff --git a/src/frontend/tests/core/features/playground.spec.ts b/src/frontend/tests/core/features/playground.spec.ts index db7eb6c27cd7..7277dbba46d7 100644 --- a/src/frontend/tests/core/features/playground.spec.ts +++ b/src/frontend/tests/core/features/playground.spec.ts @@ -22,7 +22,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat output"); - await page.waitForTimeout(1000); + await page.waitForSelector('[data-testid="outputsChat Output"]', { + timeout: 100000, + }); await page .getByTestId("outputsChat Output") @@ -39,7 +41,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("chat input"); - await page.waitForTimeout(1000); + await page.waitForSelector('[data-testid="inputsChat Input"]', { + timeout: 100000, + }); await page .getByTestId("inputsChat Input") @@ -53,7 +57,9 @@ test( await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").fill("text output"); - await page.waitForTimeout(1000); + await page.waitForSelector('[data-testid="outputsText Output"]', { + timeout: 100000, + }); await page .getByTestId("outputsText Output") @@ -168,7 +174,6 @@ test( .filter({ hasText: /^Usermessage 1$/ }) .getByTestId("icon-Pen") .click(); - await page.waitForTimeout(500); await page.getByTestId("textarea").fill("edit_1"); await page.getByTestId("save-button").click(); @@ -177,8 +182,6 @@ test( // check cancel edit await page.getByTestId("sender_name_user").hover(); await page.getByTestId("icon-Pen").first().click(); - await page.waitForTimeout(500); - await page.getByTestId("textarea").fill("cancel_edit"); await page.getByTestId("cancel-button").click(); await page.getByTestId("chat-message-User-edit_1").click(); @@ -190,7 +193,6 @@ test( .click(); await page.getByTestId("chat-message-AI-message 1").hover(); await page.getByTestId("icon-Pen").last().click(); - await page.waitForTimeout(500); await page.getByTestId("textarea").fill("edit_bot_1"); await page.getByTestId("save-button").click(); @@ -198,7 +200,6 @@ test( // check cancel edit bot await page.getByTestId("chat-message-AI-edit_bot_1").hover(); await page.getByTestId("icon-Pen").last().click(); - await page.waitForTimeout(500); await page.getByTestId("textarea").fill("edit_bot_cancel"); await page.getByTestId("cancel-button").click(); @@ -243,21 +244,59 @@ test( // check new chat await page.getByTestId("new-chat").click(); - await page.waitForTimeout(5000); - await page.getByText("New chat").click(); + await page.waitForSelector('[data-testid="new-chat-text"]', { + timeout: 100000, + }); await page.getByTestId("input-chat-playground").click(); await page.getByTestId("input-chat-playground").fill("second session"); await page.keyboard.press("Enter"); - await page.waitForTimeout(5000); - await page.getByTestId("chat-message-User-second session").click(); await page .getByTestId("chat-message-AI-second session") .getByText("second session") .click(); expect(await page.getByTestId("session-selector").count()).toBe(2); - - const sessionElements = await page.getByTestId("session-selector").all(); - expect(sessionElements.length).toBe(2); + // check helpful button + await page.getByTestId("chat-message-AI-second session").hover(); + await page.getByTestId("helpful-button").click(); + await page.getByTestId("chat-message-AI-second session").hover(); + await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({ + timeout: 10000, + }); + await page.getByTestId("helpful-button").click(); + await page.getByTestId("chat-message-AI-second session").hover(); + await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({ + timeout: 10000, + visible: false, + }); + // check not helpful button + await page.getByTestId("chat-message-AI-second session").hover(); + await page.getByTestId("not-helpful-button").click(); + await page.getByTestId("chat-message-AI-second session").hover(); + await expect(page.getByTestId("icon-ThumbDownIconCustom")).toBeVisible({ + timeout: 10000, + }); + await page.getByTestId("not-helpful-button").click(); + await page.getByTestId("chat-message-AI-second session").hover(); + await expect(page.getByTestId("icon-ThumbDownIconCustom")).toBeVisible({ + timeout: 10000, + visible: false, + }); + // check switch feedback + await page.getByTestId("chat-message-AI-second session").hover(); + await page.getByTestId("helpful-button").click(); + await page.getByTestId("chat-message-AI-second session").hover(); + await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({ + timeout: 10000, + }); + await page.getByTestId("not-helpful-button").click(); + await page.getByTestId("chat-message-AI-second session").hover(); + await expect(page.getByTestId("icon-ThumbDownIconCustom")).toBeVisible({ + timeout: 10000, + }); + await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({ + timeout: 10000, + visible: false, + }); }, );