CFE-1 complete test of all parts of callHistory part of Call Widget

This commit is contained in:
2023-10-25 13:11:15 +03:30
parent 8e85be3970
commit 8ee736f278
10 changed files with 53 additions and 16 deletions

View File

@@ -258,6 +258,7 @@
"date": "تاریخ", "date": "تاریخ",
"call_history_of": "تاریخچه تماس های", "call_history_of": "تاریخچه تماس های",
"call_history_not_found": "تاریخچه ای برای تماس دریافتی یافت نشد", "call_history_not_found": "تاریخچه ای برای تماس دریافتی یافت نشد",
"call_history_error_fetching": "خطا در دریافت تاریخچه تماس دریافتی" "call_history_error_fetching": "خطا در دریافت تاریخچه تماس دریافتی",
"show_more": "نمایش موارد بیشتر"
} }
} }

View File

@@ -12,7 +12,7 @@ describe("HistoryHeader Component From call history", () => {
const textHeader = screen.queryByText(/تاریخچه تماس های/i); const textHeader = screen.queryByText(/تاریخچه تماس های/i);
expect(textHeader).toBeInTheDocument(); expect(textHeader).toBeInTheDocument();
}); });
it("number of caller in header rendered", () => { it("caller number in header rendered", () => {
render(<MockAppWithProviders><HistoryHeader tab={tab}/></MockAppWithProviders>); render(<MockAppWithProviders><HistoryHeader tab={tab}/></MockAppWithProviders>);
const callerNumber = screen.queryByText(/09111111111/i); const callerNumber = screen.queryByText(/09111111111/i);
expect(callerNumber).toBeInTheDocument(); expect(callerNumber).toBeInTheDocument();

View File

@@ -0,0 +1,22 @@
import {render, screen} from "@testing-library/react";
import MockAppWithProviders from "../../../../../../../../../../../../mocks/AppWithProvider";
import PreviousOperatorData from "../../PreviousOperatorData";
describe("PreviousOperatorData Component From call history", () => {
describe("Rendering", () => {
const historyItem = {
operator_name: "test name",
answer_date: "test date"
}
it("operator name rendered", () => {
render(<MockAppWithProviders><PreviousOperatorData historyItem={historyItem}/></MockAppWithProviders>);
const operatorName = screen.queryByText("test name");
expect(operatorName).toBeInTheDocument();
});
it("operator answer date rendered", () => {
render(<MockAppWithProviders><PreviousOperatorData historyItem={historyItem}/></MockAppWithProviders>);
const operatorAnswerDate = screen.queryByText("test date");
expect(operatorAnswerDate).toBeInTheDocument();
});
});
});

View File

@@ -2,7 +2,7 @@ import {useTranslations} from "next-intl";
import {Avatar, Box, ListItem, ListItemAvatar, ListItemText, Typography} from "@mui/material"; import {Avatar, Box, ListItem, ListItemAvatar, ListItemText, Typography} from "@mui/material";
import HeadsetMicIcon from '@mui/icons-material/HeadsetMic'; import HeadsetMicIcon from '@mui/icons-material/HeadsetMic';
const PreviusOperatorData = ({historyItem}) => { const PreviousOperatorData = ({historyItem}) => {
const t = useTranslations(); const t = useTranslations();
return ( return (
<ListItem> <ListItem>
@@ -25,4 +25,4 @@ const PreviusOperatorData = ({historyItem}) => {
) )
} }
export default PreviusOperatorData export default PreviousOperatorData

View File

@@ -0,0 +1,22 @@
import {render, screen} from "@testing-library/react";
import MockAppWithProviders from "../../../../../../../../../../../../mocks/AppWithProvider";
import Topics from "../../Topics";
describe("Topics Component From call history", () => {
describe("Rendering", () => {
const historyItem = {
category_name: "test category",
subcategory_name: "test sub category"
}
it("operator name rendered", () => {
render(<MockAppWithProviders><Topics historyItem={historyItem}/></MockAppWithProviders>);
const operatorName = screen.queryByText("test category");
expect(operatorName).toBeInTheDocument();
});
it("operator answer date rendered", () => {
render(<MockAppWithProviders><Topics historyItem={historyItem}/></MockAppWithProviders>);
const operatorAnswerDate = screen.queryByText("test sub category");
expect(operatorAnswerDate).toBeInTheDocument();
});
});
});

View File

@@ -1,6 +1,6 @@
import {useTranslations} from "next-intl"; import {useTranslations} from "next-intl";
import {Grow, List} from "@mui/material"; import {Grow, List} from "@mui/material";
import PreviusOperatorData from "./PreviusOperatorData"; import PreviousOperatorData from "./PreviousOperatorData";
import Topics from "./Topics"; import Topics from "./Topics";
const ListItemOfCalls = ({historyItem}) => { const ListItemOfCalls = ({historyItem}) => {
@@ -11,7 +11,7 @@ const ListItemOfCalls = ({historyItem}) => {
return ( return (
<Grow in={true}> <Grow in={true}>
<List sx={{width: '100%', bgcolor: 'rgba(222,234,215,0.11)'}}> <List sx={{width: '100%', bgcolor: 'rgba(222,234,215,0.11)'}}>
<PreviusOperatorData historyItem={historyItem}/> <PreviousOperatorData historyItem={historyItem}/>
<Topics historyItem={historyItem}/> <Topics historyItem={historyItem}/>
</List> </List>
</Grow> </Grow>

View File

@@ -39,7 +39,7 @@ const LoadingHistory = () => {
/> />
}/> }/>
</Box> </Box>
<Box timeout="auto" unmountOnExit sx={{py: 2}}> <Box timeout="auto" sx={{py: 2}}>
<List component="div" disablePadding> <List component="div" disablePadding>
<ListItem data-testid="loading-listItem-cat" sx={{px: 4}}> <ListItem data-testid="loading-listItem-cat" sx={{px: 4}}>
<Box sx={{width: "100%", display: "flex", justifyContent: "space-between"}}> <Box sx={{width: "100%", display: "flex", justifyContent: "space-between"}}>

View File

@@ -1,8 +0,0 @@
describe("CreateForm Component From Expert Management", () => {
describe("Rendering", () => {
});
describe("Behavioral", () => {
});
});

View File

@@ -40,7 +40,7 @@ const CallHistory = ({tab}) => {
<Chip <Chip
icon={<HeadphonesIcon/>} icon={<HeadphonesIcon/>}
onClick={() => setShowRestOfHistory(true)} onClick={() => setShowRestOfHistory(true)}
label="نمایش موارد بیشتر" label={t("show_more")}
disabled={showRestOfHistory} disabled={showRestOfHistory}
/> />
</Divider> </Divider>