Skip to content

Commit

Permalink
add: tests for quick collapse edit func in company offers management …
Browse files Browse the repository at this point in the history
…widget
  • Loading branch information
tomaspalma committed Sep 14, 2023
1 parent 9e433e6 commit 29c39a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,15 @@ import {
GenerateTableCellFromField,
} from "../../../../utils/Table/utils";
import { columns } from "./CompanyOffersManagementSchema";
import PropTypes from "prop-types";
import useSession from "../../../../hooks/useSession";
import {
OfferTitleFilter,
PublishDateFilter,
PublishEndDateFilter,
LocationFilter,
} from "../Filters/index";
import { Edit as EditIcon } from "@material-ui/icons";
import { Link } from "react-router-dom";
import { addSnackbar } from "../../../../actions/notificationActions";
import { connect } from "react-redux";
import { RowActions } from "./CompanyOffersActions";
import Offer from "../../../HomePage/SearchResultsArea/Offer/Offer";
import { OfferConstants } from "../../../Offers/Form/OfferUtils";
import { LocationFilter, OfferTitleFilter, PublishDateFilter, PublishEndDateFilter } from "../Filters/index";
import { RowActions } from "./CompanyOffersActions";
import { columns } from "./CompanyOffersManagementSchema";
import OfferTitle from "./CompanyOffersTitle";
import CompanyOffersVisibilityActions from "./CompanyOffersVisibilityActions";
import CollapsedQuickOfferEdit from "./CollapsedQuickOfferEdit";
Expand Down Expand Up @@ -220,7 +211,12 @@ const CompanyOffersManagementWidget = ({ addSnackbar, isMobile }) => {
</Typography>
</Grid>
<Grid item xs={6} justifyContent="center">
<CompanyOffersVisibilityActions offer={row?.payload.offer} />
<CompanyOffersVisibilityActions
offer={row?.payload.offer}
getOfferVisibility={row?.payload.getOfferVisibility}
setOfferVisibility={row?.payload.setOfferVisibility}
offerId={row?.payload.offerId}
/>
<Tooltip title="Edit Offer">
<Link to={offerRoute}>
<IconButton aria-label="Edit Offer">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import React from "react";
import {
screen,
waitFor,
queryByText,
getByLabelText,
fireEvent,
act,
getByTestId,
queryByTestId,
queryByTitle,
screen, waitFor, queryByText, getByLabelText,
fireEvent, act, getByTestId, queryByTestId, queryByTitle,
} from "@testing-library/react";

import CompanyOffersManagementWidget from "./CompanyOffersManagementWidget";
Expand All @@ -19,6 +12,7 @@ import * as companyOffersService from "../../../../services/companyOffersService
import {
hideOffer as hideOfferService,
enableOffer as enableOfferService,
editOffer as editOfferService,
} from "../../../../services/offerService";
import useSession from "../../../../hooks/useSession";
import { BrowserRouter } from "react-router-dom";
Expand Down Expand Up @@ -267,30 +261,6 @@ describe("App", () => {
expect(addSnackbar).toHaveBeenCalledTimes(1);
});

it("Loads Empty Offers", async () => {
companyOffersService.fetchCompanyOffers.mockImplementationOnce(
() => new Promise((resolve) => resolve([])),
);
// By waiting for act it executes all the async code at once
renderWithStoreAndTheme(
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<CompanyOffersManagementWidget />
</MuiPickersUtilsProvider>,
{ initialState: {}, theme },
);

await waitFor(
() => {
expect(screen.getByText("Offers Management")).toBeInTheDocument();

expect(screen.getByText("No offers here.")).toBeInTheDocument();
},
{
timeout: 1000,
},
);
});

it("Error fetching offers", async () => {
addSnackbar.mockImplementationOnce(() => ({ type: "" }));

Expand Down

0 comments on commit 29c39a8

Please sign in to comment.