Skip to content

Commit

Permalink
96894 - cypress and linter error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jquispe-oddball committed Dec 27, 2024
1 parent 6aa9833 commit 7bf54af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ const POARequestsPage = () => {
: 'poa-request__tab-link'
}
role="tab"
aria-controls="panel-pending"
id="pending"
>
Pending requests
</NavLink>
Expand All @@ -41,8 +39,6 @@ const POARequestsPage = () => {
: 'poa-request__tab-link'
}
role="tab"
aria-controls="panel-completed"
id="completed"
>
Completed requests
</NavLink>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,25 @@
import { expect } from 'chai';
import upperFirst from 'lodash/upperFirst';
import React from 'react';
import { formatDateParsedZoneLong } from 'platform/utilities/date/index';
import POARequestsCard from '../../../components/POARequestsCard/POARequestsCard';
import { render } from '@testing-library/react';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import POARequestsPage from '../../../components/POARequestsCard/POARequestsCard';
// import { poaRequestsLoader } from '../../../containers/POARequestsPage';
import mockPOARequestsResponse from '../../../mocks/mockPOARequestsResponse.json';
import { renderTestApp } from '../helpers';

const MOCK_POA_REQUESTS = mockPOARequestsResponse.data;
import ErrorMessage from '../../../components/common/ErrorMessage';

describe('POARequestsTable', () => {
it('renders card', () => {
const { getByTestId } = renderTestApp(
<POARequestsCard poaRequests={MOCK_POA_REQUESTS} />,
);
expect(getByTestId('poa-requests-card')).to.exist;
});

it('renders POA requests', () => {
const { getByTestId } = renderTestApp(
<POARequestsCard poaRequests={MOCK_POA_REQUESTS} />,
);

MOCK_POA_REQUESTS.forEach(({ id, attributes }) => {
expect(getByTestId(`poa-request-card-${id}-status`).textContent).to.eq(
upperFirst(attributes.status),
);
expect(getByTestId(`poa-request-card-${id}-name`).textContent).to.eq(
`${attributes.claimant.lastName}, ${attributes.claimant.firstName}`,
);
it('loads error component on POA requests page', async () => {
const routes = [
{
path: '/representative/poa-requests',
element: <POARequestsPage />,
loader: mockPOARequestsResponse,
errorElement: <ErrorMessage />,
},
];
const router = createMemoryRouter(routes);

expect(getByTestId(`poa-request-card-${id}-city`).textContent).to.eq(
attributes.claimantAddress.city,
);
expect(getByTestId(`poa-request-card-${id}-state`).textContent).to.eq(
attributes.claimantAddress.state,
);
expect(getByTestId(`poa-request-card-${id}-zip`).textContent).to.eq(
attributes.claimantAddress.zip,
);
if (attributes.status === 'Declined') {
expect(
getByTestId(`poa-request-card-${id}-declined`).textContent,
).to.eq(formatDateParsedZoneLong(attributes.acceptedOrDeclinedAt));
} else if (attributes.status === 'Accepted') {
expect(
getByTestId(`poa-request-card-${id}-accepted`).textContent,
).to.eq(formatDateParsedZoneLong(attributes.acceptedOrDeclinedAt));
} else {
expect(
getByTestId(`poa-request-card-${id}-received`).textContent,
).to.eq(formatDateParsedZoneLong(attributes.expiresAt));
}
});
const { getByTestId } = await render(<RouterProvider router={router} />);
await expect(getByTestId('error-message')).to.exist;
});
});

0 comments on commit 7bf54af

Please sign in to comment.