-
-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BugFix : Fixed Improper Handling for Non-Numeric Values in Allotted hours section of Create Action item modal #3417
Changes from 5 commits
aa497c0
e3b3c78
72a38cc
e2d3428
c7f325c
fb17e1a
b8d2a93
17a2583
7890cbd
9c9e7bd
3f3d0b6
47937e8
88cd7ea
3fe3580
c52ca6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -778,6 +778,48 @@ describe('Testing ItemModal', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should not allow letters or negative values in allotted hours', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const allottedHours = screen.getByLabelText(t.allottedHours); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test letter input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: 'abc' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test negative value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: '-5' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test valid positive number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: '5' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue('5'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('validates allottedHours edge cases', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const allottedHours = screen.getByLabelText(t.allottedHours); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test invalid string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: 'invalid' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test NaN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: NaN } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test negative number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: -5 } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should fail to Create Action Item', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link2, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Click Submit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -802,6 +844,148 @@ describe('Testing ItemModal', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//checking for empty and null values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('handles empty and null form values correctly', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const allottedHours = screen.getByLabelText(t.allottedHours); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const preCompletionNotes = screen.getByLabelText(t.preCompletionNotes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: '' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(preCompletionNotes, { target: { value: '' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(preCompletionNotes).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(allottedHours, { target: { value: null } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(allottedHours).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// validation of catergory selection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('validates category selection', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const categorySelect = await screen.findByTestId('categorySelect'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const inputField = within(categorySelect).getByRole('combobox'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const submitButton = screen.getByTestId('submitBtn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(submitButton); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(inputField).toBeRequired(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.mouseDown(inputField); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const categoryOption = await screen.findByText('Category 1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(categoryOption); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(inputField).toHaveValue('Category 1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(inputField, { target: { value: '' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(inputField).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// changing of assignee type handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('handles assignee type changes correctly', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const groupRadio = await screen.findByText(t.groups); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const individualRadio = await screen.findByText(t.individuals); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(individualRadio); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(await screen.findByTestId('volunteerSelect')).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(groupRadio); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await screen.findByTestId('volunteerGroupSelect'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(individualRadio); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(await screen.findByTestId('volunteerSelect')).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// validating when dates are due | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('validates due date handling', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const dateInput = screen.getByLabelText(t.dueDate); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(dateInput, { target: { value: 'invalid date' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(dateInput).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(dateInput, { target: { value: '01/01/2020' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(dateInput).toHaveValue('01/01/2020'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(dateInput, { target: { value: '01/01/2025' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(dateInput).toHaveValue('01/01/2025'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for past dates. The test should verify that past dates are not accepted as valid due dates. it('validates due date handling', async () => {
renderItemModal(link1, itemProps[0]);
await waitFor(async () => {
const dateInput = screen.getByLabelText(t.dueDate);
fireEvent.change(dateInput, { target: { value: 'invalid date' } });
expect(dateInput).toHaveValue('');
- fireEvent.change(dateInput, { target: { value: '01/01/2020' } });
- expect(dateInput).toHaveValue('01/01/2020');
+ // Test past date
+ const pastDate = '01/01/2020';
+ fireEvent.change(dateInput, { target: { value: pastDate } });
+ expect(dateInput).toHaveValue('');
+ expect(screen.queryByText(/date must be in the future/i)).toBeInTheDocument();
fireEvent.change(dateInput, { target: { value: '01/01/2025' } });
expect(dateInput).toHaveValue('01/01/2025');
});
}); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// for testing network handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('handles network errors gracefully', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link2, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const categorySelect = await screen.findByTestId('categorySelect'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const inputField = within(categorySelect).getByRole('combobox'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.mouseDown(inputField); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const categoryOption = await screen.findByText('Category 1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(categoryOption); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const memberSelect = await screen.findByTestId('memberSelect'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const memberInput = within(memberSelect).getByRole('combobox'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.mouseDown(memberInput); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const memberOption = await screen.findByText('Harve Lance'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(memberOption); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const submitButton = screen.getByTestId('submitBtn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.click(submitButton); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(toast.error).toHaveBeenCalledWith('Mock Graphql Error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('handles null date change', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const dateInput = screen.getByLabelText(t.dueDate); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(dateInput, { target: { value: null } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(dateInput).toHaveValue(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// for handling edge cases in timezone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('handles timezone edge cases', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link1, itemProps[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await waitFor(async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const dateInput = screen.getByLabelText(t.dueDate); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test dates around DST changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const dstDates = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'03/12/2025', // Spring forward | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'11/05/2025', // Fall back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for (const date of dstDates) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(dateInput, { target: { value: date } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(dateInput).toHaveValue(date); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Test midnight boundary dates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fireEvent.change(dateInput, { target: { value: '01/01/2025' } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(dateInput).toHaveValue('01/01/2025'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// For testing failure of updating action item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
it('should fail to Update Action Item', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
renderItemModal(link2, itemProps[2]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(screen.getAllByText(t.updateActionItem)).toHaveLength(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add assertions for form submission with empty values.
While the test verifies that empty/null values are handled correctly in the UI, it should also verify the form submission behavior with these values.