Skip to content

Commit

Permalink
Code Rabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
yugal07 committed Jan 26, 2025
1 parent 9c9e7bd commit 3f3d0b6
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/screens/OrganizationActionItems/ItemModal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -912,20 +912,59 @@ describe('Testing ItemModal', () => {
it('handles extremely long text input', async () => {
renderItemModal(link1, itemProps[0]);

// Select Category
const categorySelect = screen.getByTestId('categorySelect');
fireEvent.mouseDown(within(categorySelect).getByRole('combobox'));
fireEvent.click(await screen.findByText('Category 1'));

// Select assignee
const memberSelect = screen.getByTestId('memberSelect');
fireEvent.mouseDown(within(memberSelect).getByRole('combobox'));
fireEvent.click(await screen.findByText('Harve Lance'));

const preCompletionNotes = screen.getByLabelText(t.preCompletionNotes);
fireEvent.change(preCompletionNotes, {
target: { value: 'a'.repeat(1000) },
});
expect(preCompletionNotes).toHaveValue('a'.repeat(1000));

// Verify form submission with long text
const submitButton = screen.getByTestId('submitBtn');
fireEvent.click(submitButton);
await waitFor(() => {
expect(toast.success).toHaveBeenCalledWith(t.successfulCreation);
});
});

it('handles rapid form field changes', async () => {
renderItemModal(link1, itemProps[0]);

// Required fields setup
const categorySelect = screen.getByTestId('categorySelect');
fireEvent.mouseDown(within(categorySelect).getByRole('combobox'));
fireEvent.click(await screen.findByText('Category 1'));

const memberSelect = screen.getByTestId('memberSelect');
fireEvent.mouseDown(within(memberSelect).getByRole('combobox'));
fireEvent.click(await screen.findByText('Harve Lance'));

const hoursInput = screen.getByLabelText(t.allottedHours);
const values = ['1', '2', '3', '4', '5'];

values.forEach((value) => {
fireEvent.change(hoursInput, { target: { value } });
expect(hoursInput).toHaveValue(value);
});

// Verify final value persists
await waitFor(() => {
expect(hoursInput).toHaveValue('5');
});

const submitButton = screen.getByTestId('submitBtn');
fireEvent.click(submitButton);
await waitFor(() => {
expect(toast.success).toHaveBeenCalledWith(t.successfulCreation);
});
});

Expand Down

0 comments on commit 3f3d0b6

Please sign in to comment.