Skip to content

Commit

Permalink
Merge pull request #53 from SMUGitGeeks/SBRP-116-solve-issue-for-appl…
Browse files Browse the repository at this point in the history
…ication-quantity-no-longer-showing-up
  • Loading branch information
DarrylSSY authored Nov 6, 2023
2 parents 3873e7c + 95b1e4e commit 68f45a6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 26 deletions.
44 changes: 33 additions & 11 deletions client/src/components/pages/RoleListingManager.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ describe('Role List Manager component tests', () => {

})

describe('Role List Manager loading tests', () => {
beforeAll(() => {
mockMatchMedia();
});

it ("should load data after a few seconds",() => {
render(
<Provider store={store}>
<BrowserRouter>
<RoleListingManager/>
</BrowserRouter>
</Provider>)

expect(screen.getAllByTestId("skeleton-item")[0]).toBeInTheDocument();

waitFor(() => {
expect(screen.queryAllByTestId("skeleton-item")).not.toBeInTheDocument();
expect(screen.getByText('HR Manager')).toBeInTheDocument();
expect(screen.getByText('IT Technician')).toBeInTheDocument();
});
});

})

describe('Role Listings component tests', () => {
beforeAll(() => {
mockMatchMedia();
Expand Down Expand Up @@ -57,16 +81,6 @@ describe('Role Listings component tests', () => {
userEvent.click(screen.getAllByText('Open')[0])
expect(screen.getByLabelText('Open')).toBeChecked()
});

it('should load 3 seconds before displaying data', async () => {
expect(screen.getByTestId("skeleton-list")).toBeInTheDocument();

waitFor(() => {
expect( screen.queryByTestId("skeleton-list")).not.toBeInTheDocument();
expect( screen.getByText('HR Manager')).toBeInTheDocument();
expect( screen.getByText('IT Technician')).toBeInTheDocument();
});
});

it ("able to click edit icon and redirect to update page", async () => {
waitFor(() => {
Expand Down Expand Up @@ -187,7 +201,6 @@ describe('Role Listings component tests', () => {

it ("Engineer Manager should display closed status", async () => {
waitFor(() => {
// screen.debug(undefined, Infinity);
const statusElement = screen.getAllByTestId('status')[3];
const itTechnicianElement = screen.getByText("IT Technician");
const financeStaffElement = screen.getByText("Finance Staff");
Expand Down Expand Up @@ -256,4 +269,13 @@ describe('Role Listings component tests', () => {
expect(departmentElement.compareDocumentPosition(engineeringManagerElement)).toBe(4);
});
});

it ("should display 4 applicants for Engineering Manager", async () => {
waitFor(() => {
const applicantsElement = screen.getAllByTestId('applicant-count')[1];
expect(applicantsElement).toBeInTheDocument();

expect(applicantsElement).toHaveTextContent('4');
}
)});
})
36 changes: 21 additions & 15 deletions client/src/components/pages/RoleListingManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
LoadingOutlined,
BankOutlined,
SearchOutlined,
UserOutlined,
} from '@ant-design/icons';
import {getStaffListings} from "../../actions/staffListings";
import {useNavigate} from "react-router-dom";
Expand Down Expand Up @@ -55,6 +56,7 @@ const RoleListingManager = ({
const getHRName = (id: number) => {
let staff = staffListing.staffListings.find((staffListing: any) => staffListing.staff_id === id);
return staff.fname + " " + staff.lname;
// return "yo"
}

const today = new Date();
Expand Down Expand Up @@ -137,15 +139,24 @@ const RoleListingManager = ({
renderItem={(item: any) => (
<List.Item
key={item.role_name}
extra={ item.role_status === "active" ?
<Space direction="vertical" size={30}>
<Tooltip placement="top" title='Edit'>
<span onClick={() => navigate("/listingManage/update/" + item.rl_id)} data-testid="edit-icon-click">
<FormOutlined style={{fontSize: 20, cursor: "pointer"}}/>
</span>
</Tooltip>
</Space> :
<></>
extra={
<Space direction="vertical" size={30} style={{display: "flex", alignItems: "flex-end"}}>
{ item.role_status === "active" ?
<Tooltip placement="top" title='Edit'>
<span onClick={() => navigate("/listingManage/update/" + item.rl_id)} data-testid="edit-icon-click">
<FormOutlined style={{fontSize: 20, cursor: "pointer"}}/>
</span>
</Tooltip> :
<div></div>
}

<Space direction="vertical" size={0} style={{display: "flex", alignItems: "flex-end"}}>
<div style={{fontSize: 30}} data-testid="applicant-count">
{item.application_count} <UserOutlined color="blue"/>
</div>
Applicants
</Space>
</Space>
}
style={{cursor: "pointer"}}
>
Expand Down Expand Up @@ -189,11 +200,6 @@ const RoleListingManager = ({
</span>
}
</Space>
<br/>
<span>
<strong>Applicants: </strong>
<span> {item.application_count} </span>
</span>
<br/><br/>
<div>{item.rl_desc}</div>
</Link>
Expand All @@ -215,11 +221,11 @@ const RoleListingManager = ({
renderItem={(item: any) => (
<List.Item
key={item}
data-testid="skeleton-item"
>
<Skeleton active title/>
</List.Item>
)}
data-testid="skeleton-list"
/>
)
}
Expand Down

0 comments on commit 68f45a6

Please sign in to comment.