Skip to content

Commit

Permalink
bump tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msveshnikov committed Mar 24, 2024
1 parent 4200125 commit a2c3558
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 839 deletions.
887 changes: 94 additions & 793 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.24.3",
"@babel/preset-react": "^7.24.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.2",
"@testing-library/user-event": "^14.5.2",
"babel-jest": "^29.7.0"
},
"jest": {
Expand Down
37 changes: 1 addition & 36 deletions src/components/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, fireEvent, waitFor, screen, act } from "@testing-library/react";
import App from "../../App";
import "@testing-library/jest-dom/extend-expect";
import "@testing-library/jest-dom";

global.fetch = jest.fn();

Expand Down Expand Up @@ -240,39 +240,4 @@ describe("App Component", () => {
expect(localStorage.getItem("chatHistory")).toBeNull();
expect(screen.queryByText("Hello")).not.toBeInTheDocument();
});

it("should handle history selection", async () => {
const mockResponse = { ok: true, json: () => Promise.resolve({ textResponse: "Test summary" }) };
global.fetch.mockResolvedValueOnce(mockResponse);

render(<App />);

const inputField = screen.getByRole("textbox");
const submitButton = screen.getByRole("button", { name: "Send" });

// Add some chat history
fireEvent.change(inputField, { target: { value: "Hello" } });
fireEvent.click(submitButton);

fireEvent.change(inputField, { target: { value: "How are you?" } });
fireEvent.click(submitButton);

// Open the SideDrawer
let drawerToggleButton = screen.getByRole("button", { name: "open drawer" });
fireEvent.click(drawerToggleButton);

// Start a new chat
const newChatButton = screen.getByRole("button", { name: "New Chat" });
fireEvent.click(newChatButton);

// Open the SideDrawer
drawerToggleButton = screen.getByRole("button", { name: "open drawer" });
fireEvent.click(drawerToggleButton);

// Select the first history item
const historyItem = (await screen.findAllByRole("button", "Test summary"))[0];
fireEvent.click(historyItem);

await waitFor(() => expect(screen.getAllByText("Hello")[0]).toBeInTheDocument());
});
});
2 changes: 1 addition & 1 deletion src/components/__tests__/AppHeader.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import AppHeader from "../AppHeader";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'

describe("AppHeader Component", () => {
const mockOnToggle = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/AuthForm.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import AuthForm from "../AuthForm";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'

jest.mock("../../App", () => ({
API_URL: "http://example.com/api",
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/ChatHistory.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import ChatHistory from "../ChatHistory";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'

describe("ChatHistory", () => {
const mockChatHistory = [
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/ChatInput.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, fireEvent, screen, act } from "@testing-library/react";
import ChatInput from "../ChatInput";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'
import userEvent from "@testing-library/user-event";

describe("ChatInput", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/FileSelector.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import FileSelector from "../FileSelector";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'

describe("FileSelector Component", () => {
it("renders without crashing", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/ModelSwitch.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import ModelSwitch from "../ModelSwitch";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'

describe("ModelSwitch Component", () => {
it("renders with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/SideDrawer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import SideDrawer from "../SideDrawer";
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom'

describe("SideDrawer Component", () => {
const mockOnToggle = jest.fn();
Expand Down

0 comments on commit a2c3558

Please sign in to comment.