-
Notifications
You must be signed in to change notification settings - Fork 59
feat(AddTask): Add entry date field to Add Task dialog #267
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
Author
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. added the entry field to this struct to accept it from frontend |
|
Contributor
Author
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. update the function to accept entrydate parameter |
|
Contributor
Author
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. added entry-date ui |
|
Contributor
Author
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. added entry field to new task state and pass it to addTaskToBackend when submitting, and after submission, reset it. |
|
Contributor
Author
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. added new test cases for entry field |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,13 @@ import { AddTaskdialog } from '../AddTaskDialog'; | |
| import '@testing-library/jest-dom'; | ||
|
|
||
| jest.mock('date-fns', () => ({ | ||
|
Contributor
Author
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. changed date-fns mock from static to dynamic, now returns the actual formatted date based on input. |
||
| format: jest.fn(() => '2024-12-25'), | ||
| format: jest.fn((date) => { | ||
| const d = new Date(date); | ||
| const year = d.getFullYear(); | ||
| const month = String(d.getMonth() + 1).padStart(2, '0'); | ||
| const day = String(d.getDate()).padStart(2, '0'); | ||
| return `${year}-${month}-${day}`; | ||
| }), | ||
| })); | ||
|
|
||
| jest.mock('@/components/ui/date-picker', () => ({ | ||
|
|
@@ -59,6 +65,7 @@ describe('AddTaskDialog Component', () => { | |
| project: '', | ||
| due: '', | ||
| start: '', | ||
| entry: '', | ||
| wait: '', | ||
| end: '', | ||
| recur: '', | ||
|
|
@@ -224,6 +231,7 @@ describe('AddTaskDialog Component', () => { | |
| project: 'Work', | ||
| due: '2024-12-25', | ||
| start: '', | ||
| entry: '2025-12-20', | ||
| wait: '2025-12-20', | ||
| end: '', | ||
| recur: '', | ||
|
|
@@ -313,7 +321,7 @@ describe('AddTaskDialog Component', () => { | |
|
|
||
| expect(mockProps.setNewTask).toHaveBeenCalledWith({ | ||
| ...mockProps.newTask, | ||
| wait: '2024-12-25', // Mocked format() always returns this value regardless of input | ||
| wait: '2025-12-20', | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -342,4 +350,65 @@ describe('AddTaskDialog Component', () => { | |
|
|
||
| expect(mockProps.onSubmit).toHaveBeenCalledWith(mockProps.newTask); | ||
| }); | ||
|
|
||
| test('renders entry date picker with correct placeholder', () => { | ||
| mockProps.isOpen = true; | ||
| render(<AddTaskdialog {...mockProps} />); | ||
|
|
||
| const entryDatePicker = | ||
| screen.getByPlaceholderText(/select an entry date/i); | ||
| expect(entryDatePicker).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('updates entry when user selects a date', () => { | ||
| mockProps.isOpen = true; | ||
| render(<AddTaskdialog {...mockProps} />); | ||
|
|
||
| const entryDatePicker = | ||
| screen.getByPlaceholderText(/select an entry date/i); | ||
| fireEvent.change(entryDatePicker, { target: { value: '2025-12-20' } }); | ||
|
|
||
| expect(mockProps.setNewTask).toHaveBeenCalledWith({ | ||
| ...mockProps.newTask, | ||
| entry: '2025-12-20', | ||
| }); | ||
| }); | ||
|
|
||
| test('submits task with entry date when provided', () => { | ||
| mockProps.isOpen = true; | ||
| mockProps.newTask = { | ||
| description: 'Test task', | ||
| priority: 'H', | ||
| project: 'Work', | ||
| due: '2024-12-25', | ||
| entry: '2025-12-20', | ||
| tags: ['urgent'], | ||
| annotations: [], | ||
| }; | ||
| render(<AddTaskdialog {...mockProps} />); | ||
|
|
||
| const submitButton = screen.getByRole('button', { name: /add task/i }); | ||
| fireEvent.click(submitButton); | ||
|
|
||
| expect(mockProps.onSubmit).toHaveBeenCalledWith(mockProps.newTask); | ||
| }); | ||
|
|
||
| test('allows empty entry date (optional field)', () => { | ||
| mockProps.isOpen = true; | ||
| mockProps.newTask = { | ||
| description: 'Test task', | ||
| priority: 'M', | ||
| project: '', | ||
| due: '', | ||
| entry: '', | ||
| tags: [], | ||
| annotations: [], | ||
| }; | ||
| render(<AddTaskdialog {...mockProps} />); | ||
|
|
||
| const submitButton = screen.getByRole('button', { name: /add task/i }); | ||
| fireEvent.click(submitButton); | ||
|
|
||
| expect(mockProps.onSubmit).toHaveBeenCalledWith(mockProps.newTask); | ||
| }); | ||
| }); | ||
|
Contributor
Author
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. added entry field to addTaskToBackend function parameter, type definition and request body. |
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.
extract entryDate from request body and passed it to the function