Skip to content

Commit

Permalink
refine message_history test
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed May 16, 2023
1 parent 38f3214 commit 8d453b4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
16 changes: 13 additions & 3 deletions cypress/e2e/message_history/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { openHistory, submitMessage } from "../../support/testUtils";
import {
closeHistory,
openHistory,
submitMessage,
} from "../../support/testUtils";

describe("Message History", () => {
before(() => {
Expand All @@ -9,15 +13,21 @@ describe("Message History", () => {
});

it("should be able to show the last message in the message history", () => {
openHistory();

cy.get(".history-item").should("have.length", 0);
cy.get("#history-empty").should("exist");

closeHistory();

const timestamp = Date.now().toString();

submitMessage(timestamp);
cy.wait(["@message"]);

cy.get(".history-item").should("have.length", 0);

openHistory();

cy.get("#history-empty").should("not.exist");
cy.get(".history-item").should("have.length", 1);
cy.get(".history-item").eq(0).should("contain", timestamp).click();
cy.get(".history-item").should("have.length", 0);
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export function openHistory() {
cy.get(`#chat-input`).should("not.be.disabled");
cy.get(`#chat-input`).type(`{upArrow}`);
}

export function closeHistory() {
cy.get(`body`).click();
}
5 changes: 2 additions & 3 deletions src/chainlit/frontend/src/components/chat/history/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function HistoryButton({ onClick, onOpen, chats }: Props) {
const empty =
chats?.length === 0 ? (
// @ts-ignore
<div key="empty" disabled>
<div key="empty" id="history-empty" disabled>
<Typography
color="text.secondary"
sx={{
Expand All @@ -112,7 +112,7 @@ export default function HistoryButton({ onClick, onOpen, chats }: Props) {

const loading = !chats ? (
// @ts-ignore
<div key="loading" disabled>
<div key="loading" id="history-loading" disabled>
<Typography
color="text.secondary"
sx={{
Expand Down Expand Up @@ -198,7 +198,6 @@ export default function HistoryButton({ onClick, onOpen, chats }: Props) {
<Menu
autoFocus
anchorEl={anchorEl}
id="account-menu"
open={open}
onClose={() => setOpen(false)}
PaperProps={{
Expand Down
2 changes: 1 addition & 1 deletion src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chainlit"
version = "0.1.101"
version = "0.1.102"
keywords = ['LLM', 'Agents', 'gen ai', 'chat ui', 'chatbot ui', 'langchain']
description = "A faster way to build chatbot UIs."
authors = ["Chainlit"]
Expand Down

0 comments on commit 8d453b4

Please sign in to comment.