| "yup": "^0.32.9" | "yup": "^0.32.9" | ||||
| }, | }, | ||||
| "scripts": { | "scripts": { | ||||
| "start": "react-scripts start", | |||||
| "start": "react-scripts --openssl-legacy-provider start", | |||||
| "build": "react-scripts build", | "build": "react-scripts build", | ||||
| "test": "react-scripts test", | "test": "react-scripts test", | ||||
| "eject": "react-scripts eject", | "eject": "react-scripts eject", |
| import { fireEvent, render, screen, waitFor } from "@testing-library/react"; | |||||
| import * as redux from "react-redux"; | |||||
| import store from "../../store"; | |||||
| import { Router } from "react-router-dom"; | |||||
| import history from "../../store/utils/history"; | |||||
| import { mockState } from "../../mockState"; | |||||
| import ColorModeProvider from "../../context/ColorModeContext"; | |||||
| import CandidateFilters from "../../components/Candidates/CandidateFilters"; | |||||
| describe("Add ad modals ui tests", () => { | |||||
| const props = { | |||||
| open: true, | |||||
| handleClose: jest.fn(), | |||||
| pageSize: 3, | |||||
| currentPage: 1, | |||||
| isTableView: false, | |||||
| technologies: [ | |||||
| { | |||||
| technologyId: 1, | |||||
| name: ".NET", | |||||
| technologyType: "Backend", | |||||
| isChecked: true, | |||||
| }, | |||||
| ], | |||||
| }; | |||||
| const cont = ( | |||||
| <redux.Provider store={store}> | |||||
| <Router history={history}> | |||||
| <ColorModeProvider> | |||||
| <CandidateFilters {...props} /> | |||||
| </ColorModeProvider> | |||||
| </Router> | |||||
| </redux.Provider> | |||||
| ); | |||||
| let spyOnUseSelector; | |||||
| beforeEach(() => { | |||||
| spyOnUseSelector = jest.spyOn(redux, "useSelector"); | |||||
| }); | |||||
| afterEach(() => { | |||||
| jest.restoreAllMocks(); | |||||
| }); | |||||
| it("Should check checkbox", async () => { | |||||
| const { container } = render(cont); | |||||
| const a = container.getElementsByClassName( | |||||
| "ad-filters-technologies-checkboxes-checkbox" | |||||
| )[0]; | |||||
| waitFor(() => { | |||||
| fireEvent.click(a); | |||||
| expect(a).toBeDefined(); | |||||
| }); | |||||
| }); | |||||
| it("Should click type of employment button", async () => { | |||||
| const { container } = render(cont); | |||||
| const btn = container.getElementsByClassName("type-of-employment-btn"); | |||||
| waitFor(() => { | |||||
| fireEvent.click(btn[1]); | |||||
| expect(btn).toBeDefined(); | |||||
| }); | |||||
| }); | |||||
| it("Should change ending date", async () => { | |||||
| render(cont); | |||||
| const input = screen.getByTestId("filter-date-container-ending-date"); | |||||
| waitFor(() => { | |||||
| fireEvent.change(input, { target: { value: "2024-05-24" } }); | |||||
| expect(input).toBeDefined(); | |||||
| }); | |||||
| }); | |||||
| }); |
| container.getElementsByClassName("pattern-card-parent").length | container.getElementsByClassName("pattern-card-parent").length | ||||
| ).toBeGreaterThan(0); | ).toBeGreaterThan(0); | ||||
| }); | }); | ||||
| it("Should submit filters handler", async () => { | |||||
| const { container } = render(cont); | |||||
| fireEvent.click( | |||||
| container.getElementsByClassName("custom-filter-button")[0] | |||||
| ); | |||||
| waitFor(() => { | |||||
| fireEvent.click( | |||||
| container.getElementsByClassName("pattern-filters-checkbox")[0] | |||||
| ); | |||||
| fireEvent.change( | |||||
| container.getElementsByClassName( | |||||
| "custom-drawer-sub-card-content-input-1" | |||||
| )[0], | |||||
| { target: { value: "2024-05-05" } } | |||||
| ); | |||||
| fireEvent.change( | |||||
| container.getElementsByClassName( | |||||
| "custom-drawer-sub-card-content-input-2" | |||||
| )[0], | |||||
| { target: { value: "2025-05-05" } } | |||||
| ); | |||||
| const searchBtn = screen.getByTestId("custom-drawer-submit-search"); | |||||
| fireEvent.click(searchBtn); | |||||
| expect(searchBtn).toBeDefined(); | |||||
| }); | |||||
| }); | |||||
| }); | }); |
| } | } | ||||
| .add-ad-modal-stage-sub-card { | .add-ad-modal-stage-sub-card { | ||||
| border: none; | |||||
| box-sizing: border-box; | |||||
| outline: 0; | |||||
| position: relative; | |||||
| width: 100%; | |||||
| display: flex; | display: flex; | ||||
| flex-direction: column; | flex-direction: column; | ||||
| margin-bottom: 9px; | margin-bottom: 9px; | ||||
| } | } | ||||
| .add-ad-modal-stage-sub-card input[type="date"]::-webkit-calendar-picker-indicator { | |||||
| background: transparent; | |||||
| bottom: 0; | |||||
| color: transparent; | |||||
| cursor: pointer; | |||||
| height: auto; | |||||
| left: 0; | |||||
| position: absolute; | |||||
| right: 0; | |||||
| top: 0; | |||||
| width: auto; | |||||
| } | |||||
| .add-ad-modal-stage-sub-card-third { | .add-ad-modal-stage-sub-card-third { | ||||
| display: flex; | display: flex; | ||||
| flex-direction: column; | flex-direction: column; |
| } | } | ||||
| .filter-date-container { | .filter-date-container { | ||||
| border: none; | |||||
| box-sizing: border-box; | |||||
| outline: 0; | |||||
| position: relative; | |||||
| width: 100%; | |||||
| display: flex; | display: flex; | ||||
| flex-direction: column; | flex-direction: column; | ||||
| margin-top: 10px; | margin-top: 10px; | ||||
| } | } | ||||
| .filter-date-container input[type="date"]::-webkit-calendar-picker-indicator { | |||||
| background: transparent; | |||||
| bottom: 0; | |||||
| color: transparent; | |||||
| cursor: pointer; | |||||
| height: auto; | |||||
| left: 0; | |||||
| position: absolute; | |||||
| right: 0; | |||||
| top: 0; | |||||
| width: auto; | |||||
| } | |||||
| .filter-date-container input { | .filter-date-container input { | ||||
| border: 1px solid gray; | border: 1px solid gray; | ||||
| border-radius: 4px; | border-radius: 4px; | ||||
| top: 100px; | top: 100px; | ||||
| right: 9px; | right: 9px; | ||||
| z-index: 1000; | z-index: 1000; | ||||
| &.smaller{ | |||||
| &.smaller { | |||||
| min-width: 250px !important; | min-width: 250px !important; | ||||
| } | } | ||||
| } | } |
| <Checkbox | <Checkbox | ||||
| checked={technology.isChecked} | checked={technology.isChecked} | ||||
| name={technology.name} | name={technology.name} | ||||
| className="ad-filters-technologies-checkboxes-checkbox" | |||||
| onChange={handleTechologiesChange} | onChange={handleTechologiesChange} | ||||
| /> | /> | ||||
| } | } | ||||
| key={index} | key={index} | ||||
| className={ | className={ | ||||
| type.isChecked === false | type.isChecked === false | ||||
| ? "c-btn c-btn--primary-outlined" | |||||
| : "c-btn c-btn--primary" | |||||
| ? "c-btn c-btn--primary-outlined type-of-employment-btn" | |||||
| : "c-btn c-btn--primary type-of-employment-btn" | |||||
| } | } | ||||
| onClick={() => handleChangeTypeOfEmployment(type.name)} | onClick={() => handleChangeTypeOfEmployment(type.name)} | ||||
| > | > | ||||
| <input | <input | ||||
| type="date" | type="date" | ||||
| id="start" | id="start" | ||||
| data-testid="filter-date-container-ending-date" | |||||
| max={formatDateInput(new Date())} | max={formatDateInput(new Date())} | ||||
| value={endingDate} | value={endingDate} | ||||
| onChange={handleChangeEndingDate} | onChange={handleChangeEndingDate} |
| const [toDate, setToDate] = useState(""); | const [toDate, setToDate] = useState(""); | ||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| console.log("OVDE",selectionLevelFilter) | |||||
| const submitFiltersHandler = (e) => { | const submitFiltersHandler = (e) => { | ||||
| e.preventDefault(); | e.preventDefault(); | ||||
| <div className="custom-drawer-submit"> | <div className="custom-drawer-submit"> | ||||
| <button | <button | ||||
| className="c-btn c-btn--primary" | className="c-btn c-btn--primary" | ||||
| data-testid="custom-drawer-submit-search" | |||||
| disabled={!hasSelectedFilters()} | disabled={!hasSelectedFilters()} | ||||
| > | > | ||||
| Pretrazi | Pretrazi |