Skip to content

Commit

Permalink
Added Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyVA committed Oct 4, 2024
1 parent 5f23231 commit f254577
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const AttachmentsList = props => {

useEffect(
() => {
const alertButton = attachFileAlertRef?.current?.shadowRoot.querySelector(
const alertButton = attachFileAlertRef?.current?.shadowRoot?.querySelector(
'#close-success-alert-button',
);
if (attachFileSuccess && alertButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import triageTeams from '../../fixtures/recipients.json';
import categories from '../../fixtures/categories-response.json';
import reducer from '../../../reducers';
import ComposeForm from '../../../components/ComposeForm/ComposeForm';
import { Paths } from '../../../util/constants';
import { Paths, Alerts } from '../../../util/constants';
import noBlockedRecipients from '../../fixtures/json-triage-mocks/triage-teams-mock.json';
import AttachmentsList from '../../../components/AttachmentsList';

Expand Down Expand Up @@ -204,10 +204,64 @@ describe('Attachments List component', () => {
'http://127.0.0.1:3000/my_health/v1/messaging/messages/2664846/attachments/2664842',
},
],
attachmentScanError: false,
attachmentScanError: true,
editingEnabled: true,
};
const screen = setup(initialState, Paths.COMPOSE, customProps);
const screen = renderWithStoreAndRouter(
<AttachmentsList {...customProps} />,
{
initialState,
reducers: reducer,
path: Paths.MESSAGE_THREAD,
},
);

expect(screen.findByTestId('attachment-virus-alert')).to.exist;
expect(screen.getByText(Alerts.Message.ATTACHMENT_SCAN_FAIL)).to.exist;
});

it('renders error message when multiple attachments contain a virus', async () => {
const customProps = {
attachments: [
{
id: 2664842,
messageId: 2664846,
name: 'BIRD 1.gif',
attachmentSize: 31127,
download:
'http://127.0.0.1:3000/my_health/v1/messaging/messages/2664846/attachments/2664842',
},
{
id: 2664843,
messageId: 2664846,
name: 'BIRD 2.gif',
attachmentSize: 31138,
download:
'http://127.0.0.1:3000/my_health/v1/messaging/messages/2664846/attachments/2664843',
},
],
attachmentScanError: true,
editingEnabled: true,
};
const screen = renderWithStoreAndRouter(
<AttachmentsList {...customProps} />,
{
initialState,
reducers: reducer,
path: Paths.MESSAGE_THREAD,
},
);

expect(screen.findByTestId('attachment-virus-alert')).to.exist;
expect(
screen.getByText(
'One or more of the files you attached has a virus. You’ll need to remove it to send your message.',
),
).to.exist;

const removeAllAttachments = await screen.findByTestId(
'remove-all-attachments-button',
);
expect(removeAllAttachments).to.exist;
});
});

0 comments on commit f254577

Please sign in to comment.