Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 89 additions & 189 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/app/components/Chat/Chat.style.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const styles = {
container: {
height: "88vh",
height: "86vh",
display: "flex",
flexDirection: "column",
bgcolor: "grey.200",
},
secondContainer: {
width: "500px",
// width: "500px",
alignSelf: "center",
flexGrow: 1,
overflow: "auto",
Expand Down
12 changes: 9 additions & 3 deletions src/app/components/ChatBox/ChatBox.style.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Height } from "@mui/icons-material";

export const styles = {
box: {
p: 2,
backgroundColor: "background.default",
width: "500px",
// backgroundColor: "background.default",
// width: "500px",
height: "15vh",
alignSelf: "center",
marginBottom: 3,
marginBottom: 4,
},
sendIcon: {
color: "primary.main",
},
};
13 changes: 5 additions & 8 deletions src/app/components/ChatBox/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import useInput from "@/app/hooks/useInput";
import useChat from "@/app/hooks/useChat";
import useUpdateMsg from "@/app/hooks/useUpdateMsg";
import useEndChat from "@/app/hooks/useEndChat";

export default function ChatBox({ bot }: ChatBoxProps) {
const [_, setIsQuerySubmit] = useRecoilState(isQuerySubmitAtom);
const [__, setQueryParams] = useRecoilState(queryParamsAtom);
Expand Down Expand Up @@ -81,13 +80,11 @@ export default function ChatBox({ bot }: ChatBoxProps) {
}, [currentMsg.state, isSubmit, endSection.state]);

return (
<Box sx={styles.box}>
<Box component="form" onSubmit={handleSubmit}>
<Grid container spacing={2}>
<ChatInput />
<ChatButton />
</Grid>
</Box>
<Box component="form" onSubmit={handleSubmit} sx={styles.box}>
<Grid container spacing={1}>
<ChatInput />
<ChatButton />
</Grid>
</Box>
);
}
2 changes: 1 addition & 1 deletion src/app/components/ChatButton/ChatButton.style.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const styles = {
button: { width: "120%" },
button: { color: "primary.main" },
};
28 changes: 3 additions & 25 deletions src/app/components/ChatButton/ChatButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,16 @@ import { render, screen } from "@testing-library/react";
import ChatButton from "@/app/components/ChatButton/ChatButton";

describe("ChatButton Component", () => {
it("renders the send button correctly", () => {
it("renders the submit IconButton", () => {
render(<ChatButton />);

// Check if the button with "Send" text is rendered
const button = screen.getByRole("button", { name: /Send/i });
const button = screen.getByRole("button");
expect(button).toBeInTheDocument();
});

it("applies the correct styles to the button", () => {
render(<ChatButton />);

// Check if the button has the correct inline styles
const button = screen.getByRole("button", { name: /Send/i });
expect(button).toHaveStyle("width: 120%");
expect(button).toHaveAttribute("type", "submit");
});

it("renders the Send icon", () => {
render(<ChatButton />);

// Check if the button contains the SendIcon
const icon = screen.getByTestId("SendIcon");
expect(icon).toBeInTheDocument();
});

it("is wrapped inside a Grid component with correct sizing", () => {
render(<ChatButton />);

// Check if the Grid component is rendered with the correct xs prop
const gridItem = screen
.getByRole("button", { name: /Send/i })
.closest(".MuiGrid-item");
expect(gridItem).toBeInTheDocument();
expect(gridItem).toHaveClass("MuiGrid-grid-xs-2");
});
});
15 changes: 5 additions & 10 deletions src/app/components/ChatButton/ChatButton.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
"use client";
import { Grid } from "@mui/material";
import CustomButton from "@/app/components/CustomButton";
import { Grid, IconButton } from "@mui/material";
import SendIcon from "@mui/icons-material/Send";
import { styles } from "./ChatButton.style";
import { GENERAL_BUTTONS_TEXTS } from "@/app/general/constants";

export default function ChatButton() {
return (
<Grid item xs={2}>
<CustomButton
sx={styles.button}
endIcon={<SendIcon />}
type="submit"
text={GENERAL_BUTTONS_TEXTS.send}
/>
<IconButton type="submit" sx={styles.button}>
<SendIcon />
</IconButton>
</Grid>
);
)
}
9 changes: 0 additions & 9 deletions src/app/components/ChatInput/ChatInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,4 @@ describe("ChatInput Component", () => {
expect(input).toHaveAttribute("type", "text");
expect(input).toHaveAttribute("placeholder", "Type a message");
});

it("is wrapped inside a Grid component with correct sizing", () => {
render(<ChatInput />);

// Check if the Grid component is rendered with the correct xs prop
const gridItem = screen.getByRole("textbox").closest(".MuiGrid-item");
expect(gridItem).toBeInTheDocument();
expect(gridItem).toHaveClass("MuiGrid-grid-xs-10");
});
});
3 changes: 2 additions & 1 deletion src/app/components/ChatInput/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { Grid, TextField } from "@mui/material";

export default function ChatInput() {
return (
<Grid item xs={10}>
<Grid item>
<TextField
size="small"
fullWidth
placeholder="Type a message"
variant="outlined"
name="input"
color="primary"
/>
</Grid>
);
Expand Down
8 changes: 7 additions & 1 deletion src/app/components/Footer/Footer.style.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
export const styles = {
box: {
height: "2rem",
backgroundColor: "#f8f9fa",
padding: 1,
textAlign: "center",
position: "fixed",
width: "100%",
bottom: 0,
color: "black",
},
typography: {
textAlign: "center",
color: "black",
fontSize: "1rem",
fontWeight: "bold",
},
};
18 changes: 1 addition & 17 deletions src/app/components/Footer/Footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,12 @@ describe("Footer Component", () => {
expect(screen.getByText("Powered by dbBot")).toBeInTheDocument();
});

it("applies the correct styles to the footer container", () => {
render(<Footer />);

// Check if the Box component has the correct styles
const footerBox = screen.getByRole("contentinfo");
expect(footerBox).toHaveStyle(`
background-color: #f8f9fa;
padding: 8px;
text-align: center;
position: fixed;
width: 100%;
bottom: 0;
color: black;
`);
});

it("renders the correct typography variant", () => {
render(<Footer />);

// Check if Typography is rendered with the correct variant
const typography = screen.getByText("Powered by dbBot");
expect(typography).toBeInTheDocument();
expect(typography).toHaveStyle(`font-size: 0.75rem`);
expect(typography).toHaveStyle(`font-size: 1rem`);
});
});
2 changes: 1 addition & 1 deletion src/app/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Box, Typography } from "@mui/material";
export default function Footer() {
return (
<Box component="footer" sx={styles.box}>
<Typography variant="caption">Powered by dbBot</Typography>
<Typography sx={styles.typography} variant="caption">Powered by dbBot</Typography>
</Box>
);
}
13 changes: 9 additions & 4 deletions src/app/components/Header/Header.style.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
export const styles = {
title: { flexGrow: 1 },
mobileMode: { display: { xs: 'flex', md: 'none' } },
desktopMode: { display: { xs: 'none', md: 'flex' } },
mobileMenuIcon: { display: { xs: 'block', md: 'none' } },
menuButton: { mr: 2 },
box: {
display: "flex",
backgroundColor: "#f8f9fa",
padding: 2,
color: "black",
// display: "flex",
// backgroundColor: "#f8f9fa",
// padding: 2,
// color: "black",
},
typContainer: {
width: "34%",
Expand Down
7 changes: 3 additions & 4 deletions src/app/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe("Header Component", () => {

it("renders the correct typography element", () => {
render(<Header bot={botMock} />);

// Check if Typography is rendered as an h1
const typography = screen.getByRole("heading", { level: 1 });
// Check if Typography is rendered as an h6
const typography = screen.getByRole("heading", { level: 6 });
expect(typography).toBeInTheDocument();
expect(typography.tagName).toBe("H1");
expect(typography.tagName).toBe("H6");
});
});
Loading