diff --git a/frontend/src/components/__tests__/DeleteReportModal.js b/frontend/src/components/__tests__/DeleteReportModal.js
index 92f42d6b1d..bfedf09546 100644
--- a/frontend/src/components/__tests__/DeleteReportModal.js
+++ b/frontend/src/components/__tests__/DeleteReportModal.js
@@ -41,7 +41,7 @@ describe('DeleteReportModal', () => {
expect(buttons.length).toBe(2);
});
- it('exits when escapse key is pressed', async () => {
+ it('exits when escape key is pressed', async () => {
// Given a page with a modal
render();
@@ -56,4 +56,20 @@ describe('DeleteReportModal', () => {
userEvent.type(modal, '{esc}', { skipClick: true });
expect(screen.queryByTestId('modal')).not.toBeTruthy();
});
+
+ it('does not escape when any other key is pressed', async () => {
+ // Given a page with a modal
+ render();
+
+ // When the modal is triggered
+ const button = await screen.findByText('Open');
+ userEvent.click(button);
+
+ const modal = await screen.findByTestId('modal');
+ expect(modal).toBeVisible();
+
+ // And the modal can closeclose the modal via the escape key
+ userEvent.type(modal, '{enter}', { skipClick: true });
+ expect(screen.queryByTestId('modal')).toBeTruthy();
+ });
});
diff --git a/frontend/src/pages/ActivityReport/Pages/components/__tests__/Goal.js b/frontend/src/pages/ActivityReport/Pages/components/__tests__/Goal.js
index c6a5aaaaa1..2c1c2fde12 100644
--- a/frontend/src/pages/ActivityReport/Pages/components/__tests__/Goal.js
+++ b/frontend/src/pages/ActivityReport/Pages/components/__tests__/Goal.js
@@ -140,6 +140,28 @@ describe('Goal', () => {
}]);
});
+ it('cant be removed', async () => {
+ const onUpdate = jest.fn();
+ const objectives = [
+ {
+ id: 'a', title: 'first', ttaProvided: '
This is the TTA Desc
', status: 'Not Started',
+ },
+ ];
+ render();
+
+ const optionsObjBtn = screen.getByRole('button', { name: /edit or delete objective 1 on goal 1/i });
+ fireEvent.click(optionsObjBtn);
+
+ const deleteObjBtn = await screen.findByRole('button', { name: 'Delete' });
+ fireEvent.click(deleteObjBtn);
+
+ const objName = screen.getByText(/first/i);
+ expect(objName).toBeVisible();
+
+ const objDesc = screen.getByText(/this is the tta desc/i);
+ expect(objDesc).toBeVisible();
+ });
+
it('can be updated', async () => {
const onUpdate = jest.fn();
const objectives = [{
diff --git a/frontend/src/pages/ActivityReport/Pages/components/__tests__/GoalPicker.js b/frontend/src/pages/ActivityReport/Pages/components/__tests__/GoalPicker.js
index b1d1d877d0..2a5dd69d8a 100644
--- a/frontend/src/pages/ActivityReport/Pages/components/__tests__/GoalPicker.js
+++ b/frontend/src/pages/ActivityReport/Pages/components/__tests__/GoalPicker.js
@@ -154,6 +154,80 @@ describe('GoalPicker', () => {
expect(screen.queryByText('test goal edited')).toBeVisible();
expect(screen.queryByText('another goal')).toBeVisible();
});
+
+ it('cant be updated, if new name is blank', async () => {
+ const availableGoals = [];
+ const selectedGoals = [
+ {
+ id: 1, name: 'goal to edit', new: true, objectives: [],
+ },
+ { id: 2, name: 'another goal', objectives: [] },
+ ];
+
+ render(
+ ,
+ );
+
+ const menuButton = await screen.findByRole('button', { name: /actions for goal 1/i });
+ fireEvent.click(menuButton);
+
+ const editButton = await screen.findByRole('button', { name: 'Edit' });
+ fireEvent.click(editButton);
+
+ const goalNameInput = await screen.findByLabelText('Edit goal');
+ await waitFor(() => expect(goalNameInput).toBeVisible());
+
+ fireEvent.change(goalNameInput, { target: { value: '' } });
+
+ const updateButton = await screen.findByRole('button', { name: 'Update Goal' });
+ fireEvent.click(updateButton);
+
+ // Old goal name should exist, new blank goal name should not
+ expect(screen.queryByText('goal to edit')).toBeVisible();
+ expect(screen.queryByText('another goal')).toBeVisible();
+ });
+
+ it('objective can be updated', async () => {
+ const availableGoals = [];
+ const selectedGoals = [
+ {
+ id: 1,
+ name: 'goal to edit',
+ new: true,
+ objectives: [{
+ id: 1,
+ title: 'orig objective 1',
+ ttaProvided: 'objective 1 desc',
+ status: 'In Progress',
+ }],
+ },
+ ];
+
+ render(
+ ,
+ );
+
+ const optionsObjBtn = screen.getByRole('button', { name: /edit or delete objective 1 on goal 1/i });
+ fireEvent.click(optionsObjBtn);
+
+ const editObjBtn = await screen.findByRole('button', { name: 'Edit' });
+ fireEvent.click(editObjBtn);
+
+ const objectiveTitleTxtBx = screen.getByDisplayValue(/objective 1/i);
+ fireEvent.change(objectiveTitleTxtBx, { target: { value: 'updated objective 1' } });
+
+ const saveObjectiveBtn = screen.getByRole('button', { name: /save objective 1 on goal 1/i });
+ userEvent.click(saveObjectiveBtn);
+
+ expect(screen.queryByText('orig objective 1')).not.toBeInTheDocument();
+ expect(screen.queryByText('updated objective 1')).toBeVisible();
+ });
});
describe('input box', () => {
diff --git a/frontend/src/pages/ActivityReport/Pages/components/__tests__/ObjectiveFormItem.js b/frontend/src/pages/ActivityReport/Pages/components/__tests__/ObjectiveFormItem.js
new file mode 100644
index 0000000000..cc1db22beb
--- /dev/null
+++ b/frontend/src/pages/ActivityReport/Pages/components/__tests__/ObjectiveFormItem.js
@@ -0,0 +1,49 @@
+/* eslint-disable react/jsx-props-no-spreading */
+import '@testing-library/jest-dom';
+import {
+ render,
+ screen,
+} from '@testing-library/react';
+import React from 'react';
+import { TextInput } from '@trussworks/react-uswds';
+import ObjectiveFormItem from '../ObjectiveFormItem';
+
+const RenderObjectiveFormItem = ({
+ // eslint-disable-next-line react/prop-types
+ isValid, formItemValue, onChange = () => { },
+}) => (
+
+
+
+);
+
+describe('ObjectiveFormItem', () => {
+ it('renders correctly', async () => {
+ const onChange = jest.fn();
+ render();
+ const save = await screen.findByText('Objective');
+ expect(save).toBeVisible();
+ const errorMessage = screen.queryByText('objective form item required');
+ expect(errorMessage).toBeNull();
+ });
+
+ it('renders with required message', async () => {
+ const onChange = jest.fn();
+ render();
+ const save = await screen.findByText('Objective');
+ expect(save).toBeVisible();
+ const errorMessage = await screen.findByText('objective form item required');
+ expect(errorMessage).toBeVisible();
+ });
+});