Repository navigation
test(Tasks): add unit tests for annotation editing flow and state transitions - #480
Open
Aspirant200715 wants to merge 1 commit into
Open
Aspirant200715 wants to merge 1 commit into
Aspirant200715 wants to merge 1 commit into
Conversation
|
Thank you for opening this PR! Before a maintainer takes a look, it would be really helpful if you could walk through your changes using GitHub's review tools. Please take a moment to:
More information on how to conduct a self review: This helps make the review process smoother and gives us a clearer understanding of your thought process. Once you've added your self-review, we'll continue from our side. Thank you! |
Author
Self-Review
Ready for review. Thanks! Full Test Suite ResultsThe complete Tasks test suite has been executed successfully across all three test files. |
1 of 9 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds unit test coverage for the Annotation Editing workflow within the
Taskscomponent, addressing the remaining checklist item in tracking issue #433.Following the modular testing pattern established in #461 and #479, these tests validate the interaction between
Tasks.tsx,TaskDialog.tsx, and the shared test utilities (test-utils/setup.tsxandtest-utils/helper.ts).Technical Context & Component Workflow
1. Dialog & Input Management (
TaskDialog.tsx)editState.isEditingAnnotations, mounting an input field with the placeholder"Add an annotation (press enter to add)".Enter:new Date().toISOString().editState.editedAnnotations.editState.annotationInput.✖), which removes the corresponding item fromeditState.editedAnnotations.2. Persistence & Backend Dispatch (
Tasks.tsx)handleSaveAnnotations(task, editState.editedAnnotations).task.annotations.unsyncedTaskUuids.handleEditTaskOnBackend, forwarding the updated annotations array tohooks.editTaskOnBackend.Cancel editing annotations) resetsisEditingAnnotationstofalse, restoreseditedAnnotationstotask.annotations || [], and clears any uncommitted input without triggering a backend call.Tests Implemented
Test file:
frontend/src/components/HomeComponents/Tasks/__tests__/Tasks/Annotation.test.tsxFour test cases have been added:
should add a new annotation and save to backendeditTaskOnBackendwith the new annotation in the payload.should remove an added annotation before saving✖) removes the annotation fromeditedAnnotationsbefore the updated data is sent to the backend.should not add an annotation when input is empty or whitespaceshould cancel editing annotations without calling backendRelated issue: #433
Checklist
npm test -- src/components/HomeComponents/Tasks/__tests__/Tasks/Annotation.test.tsx(4 tests passed).npm test -- --runInBand src/components/HomeComponents/Tasks/__tests__/Tasks/(9 tests passed)..githooks/pre-commit.Test Plan & Verification
All tests were executed locally using Jest from the
frontend/directory.Summary
This PR focuses exclusively on testing the existing annotation editing functionality without introducing production code changes.
It covers annotation creation, removal, input validation, backend persistence, and cancellation to ensure the workflow behaves as expected.