Skip to content
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

Show comment count on action list items #1385

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

nmajor25
Copy link
Contributor

@nmajor25 nmajor25 commented Jan 23, 2025

Shortcut Story ID: [sc-58537]

This is based on the action.relationships.comments array. The Icon is shown if length > 0 and hidden if length === 0.

The visibility of the icon and it's count will change when an action's comments change via manual user action in the UI or via websocket nofitications.

Comment icon is shown or incremented when a comment is added. And hidden or decremented when a comment is deleted.

Pages where icon is added:

  • Worklist
  • Patient flow
  • Patient dashboard
  • Patient archive

Screenshot example of new icon:

Screenshot 2025-01-23 at 5 26 39 PM

Shown/hidden based on length of action.relationships.comments array

Adjustment of header & section css widths is needed
Adjustment of section css widths is needed
…ia action sidebar

action.relationships.comments must be updated to trigger UI render and show correct comment count
… via action sidebar

action.relationships.comments must be updated to trigger UI render and show correct comment count
@nmajor25 nmajor25 requested a review from paulfalgout January 23, 2025 23:29
Copy link

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces comprehensive comment functionality across multiple components of the patient management system. The changes span various files, including package.json, JavaScript entities, views, and test files. The implementation adds support for comment management, including adding, removing, and displaying comments for actions, with updates to the user interface to reflect the number of comments associated with each action item.

Changes

File Change Summary
package.json Added "comment" icon to FontAwesome far array
src/js/apps/patients/sidebar/action-sidebar_app.js Modified ActivitiesView instantiation, added event listener for remove:comment, updated onPostNewComment, and introduced onRemoveComment method
src/js/entities-service/comments.js Added new radio request: 'comments:collection': 'getCollection'
src/js/entities-service/entities/actions.js Added methods: getComments(), commentCount(), addComment(), removeComment()
src/js/entities-service/entities/comments.js Updated CommentRemoved handler to remove comments from actions
src/js/views/patients/*/action-item.hbs Added conditional rendering for comment count and icon across multiple view templates
src/js/views/patients/*/dashboard_views.js, flow_views.js, action_views.js Updated templateContext() to include commentCount
src/js/views/patients/patient/patient.scss, worklist-list.scss Added styling for comment icons and text
test/integration/patients/* Added tests for comment functionality, including WebSocket interactions and UI verification

Possibly related PRs

Suggested reviewers

  • paulfalgout
  • shadowhand

Poem

🐰 Hop, hop, hooray! Comments are here to stay!
With icons bright and count so clear,
Our patient actions now bring cheer.
A rabbit's tale of code so neat,
Where comments make the view complete! 📝

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

}

.patient__action-attachment {
.patient__action-attachment,
.patient__action-comment {
color: #999;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use $black-60 for these I believe...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated these to use $black-60.

@@ -140,14 +140,22 @@
}

.patient__list-meta {
width: 510px;
width: 562px;
Copy link
Contributor Author

@nmajor25 nmajor25 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to play around with these widths a little more on the patient flow page. When this meta section is at it's maximum potential width, things look a little funky to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be a min-width?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Min-width breaks the layout on smaller width browser windows.

I think what we have is fine right now, but I'll make a note on the card for Mark so he can take a look when this is up on QA. And see if it looks good to him and we can make adjustments if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're really reaching our limits on the worklist when it comes to horizontal spacing for these action list items.

}

.patient__action-attachment {
.patient__action-attachment,
.patient__action-comment {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this now, I think these two could be consolidated into one class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consolidated these into one patient__action-display-icon class.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/js/entities-service/comments.js (1)

8-8: Ensure naming consistency for radio requests.
Adding 'comments:collection': 'getCollection' is clear, but consider renaming it to match the pattern of 'fetch:comments:collection:byAction'. For example, 'fetch:comments:collection' could more clearly convey that a collection is being fetched.

src/js/views/patients/patient/flow/action-item.hbs (1)

18-20: Add optional aria-label for paperclip icon
Consider adding aria-label="Attachments" (or similar accessible text) to improve screen reader support.

src/js/views/patients/worklist/action-item.hbs (1)

31-33: Consider adding aria-label to comment icon
Improve accessibility by adding an aria-label="Comments" or wrapping it with <span class="sr-only">Comments</span>.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8b6d45 and c21e9ab.

📒 Files selected for processing (22)
  • package.json (1 hunks)
  • src/js/apps/patients/sidebar/action-sidebar_app.js (3 hunks)
  • src/js/entities-service/comments.js (1 hunks)
  • src/js/entities-service/entities/actions.js (4 hunks)
  • src/js/entities-service/entities/comments.js (1 hunks)
  • src/js/views/patients/patient/archive/action-item.hbs (1 hunks)
  • src/js/views/patients/patient/archive/archive_views.js (1 hunks)
  • src/js/views/patients/patient/dashboard/action-item.hbs (1 hunks)
  • src/js/views/patients/patient/dashboard/dashboard_views.js (1 hunks)
  • src/js/views/patients/patient/flow/action-item.hbs (1 hunks)
  • src/js/views/patients/patient/flow/flow_views.js (1 hunks)
  • src/js/views/patients/patient/flow/patient-flow.scss (1 hunks)
  • src/js/views/patients/patient/patient.scss (1 hunks)
  • src/js/views/patients/sidebar/action/action-sidebar-activity-views.js (2 hunks)
  • src/js/views/patients/worklist/action-item.hbs (1 hunks)
  • src/js/views/patients/worklist/action_views.js (1 hunks)
  • src/js/views/patients/worklist/worklist-list.scss (2 hunks)
  • test/integration/patients/patient/archive.js (4 hunks)
  • test/integration/patients/patient/dashboard.js (3 hunks)
  • test/integration/patients/patient/patient-flow.js (6 hunks)
  • test/integration/patients/sidebar/action-sidebar.js (1 hunks)
  • test/integration/patients/worklist/worklist.js (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/js/views/patients/patient/flow/patient-flow.scss
🔇 Additional comments (47)
src/js/entities-service/entities/comments.js (1)

17-19: Guard against undefined or missing parent Action.
this.getAction() may return undefined if a comment has no associated action. Consider verifying that action is defined before calling removeComment(this) to avoid potential runtime errors.

src/js/views/patients/patient/archive/action-item.hbs (1)

14-19: Display comment icon only when count is positive.
Using {{#if commentCount}} works as long as the property is 0 when there are no comments. Ensure commentCount is always numeric to avoid accidental string values like "0" that evaluate to truthy.

src/js/views/patients/patient/dashboard/action-item.hbs (1)

17-22: Match behavior with archive view for consistency.
The logic and styling for displaying attachments and comments align with the archive view. Confirm consistent presentation across all other pertinent views (e.g., Patient Flow, Worklist) to maintain a uniform user experience.

✅ Verification successful

Verified: Implementation matches across views
The dashboard implementation perfectly aligns with archive and flow views. The worklist view uses view-specific class names while maintaining the same visual structure and behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for all `{{#if commentCount}}` references to verify consistency across relevant Handlebars templates.
rg -A 5 $'\\{\\{#if commentCount\\}\\}'

Length of output: 2497


Script:

#!/bin/bash
# Description: Search for all `{{#if hasAttachments}}` references to verify consistency across relevant Handlebars templates
rg -A 3 $'\\{\\{#if hasAttachments\\}\\}'

Length of output: 1612

src/js/views/patients/patient/flow/action-item.hbs (1)

21-23: Double-check zero count scenario
Ensure commentCount correctly evaluates to 0 or a positive integer. If you intend to hide the icon at 0, the logic is fine. Otherwise, consider {{#if (gt commentCount 0)}}.

src/js/views/patients/worklist/action-item.hbs (1)

28-30: Good margin usage
Using margin classes for the paperclip icon ensures clear visual separation.

src/js/views/patients/worklist/action_views.js (1)

50-50: Exposes commentCount to the template
This addition properly surfaces the comment count for display.

src/js/views/patients/patient/dashboard/dashboard_views.js (1)

91-91: Consistent addition of commentCount
Aligns well with similar contexts in other views for consistent UI updates.

src/js/views/patients/patient/archive/archive_views.js (1)

87-87: Show comment count in template context
Adding the commentCount property is consistent with the rest of the codebase and provides a straightforward way to display the current comment count on the UI.

src/js/entities-service/entities/actions.js (4)

43-43: Ensure proper resource linkage and model updates
Defining _action: this.getResource() and immediately calling this.addComment(commentModel); correctly associates the comment with the action. Good job linking the comment resource to the action so it can be managed consistently.

Also applies to: 46-47


87-89: Consistent approach to retrieving comments
getComments() provides a single source of truth for the action’s comments. Centralizing comment retrieval here helps ensure consistent handling across the application.


158-160: Clear helper method for comment count
commentCount() cleanly wraps the usage of getComments().length. Straightforward implementation that makes it easy to display the count in the UI.


253-264: Robust comment add/remove logic
addComment and removeComment reassign _comments after updating the collection, ensuring state remains in sync. Verify concurrency scenarios (like multiple simultaneous additions) to avoid race conditions.

src/js/apps/patients/sidebar/action-sidebar_app.js (4)

177-180: Better lifecycle handling for ActivitiesView
Storing the activitiesView instance in a variable before rendering allows for more flexible event binding. This is a good design choice for future extensibility.


183-187: Propagate remove:comment event
Listening to 'remove:comment' on activitiesView provides a clear, centralized way to handle the removal action at the parent level. Good approach for decoupled event handling.


209-209: Add newly created comment to action
Calling this.action.addComment(model) right after saving the comment ensures the action's comment collection is immediately updated, keeping the UI in sync.


221-225: Clean removal of comment and websocket unsubscription
this.action.removeComment(model) plus Radio.request('ws', 'unsubscribe', model) neatly removes the comment from the collection and stops receiving updates for it. This prevents stale subscriptions.

src/js/views/patients/sidebar/action/action-sidebar-activity-views.js (2)

176-176: Trigger event before model destruction
Emitting remove:comment prior to this.model.destroy() allows external views to handle comment removal logic (e.g., updating the action). Great for decoupled design.


252-254: Proper event propagation
Forwarding 'remove:comment' from the child view to the collection view ensures higher-level components can handle comment removal. This pattern keeps code modular and maintainable.

src/js/views/patients/patient/flow/flow_views.js (1)

166-166: Ensure the commentCount property is handled consistently
Great addition to pass the commentCount property to the template. Confirm that this.model.commentCount() is always defined before using it to avoid potential undefined errors. Otherwise, looks good.

test/integration/patients/patient/archive.js (4)

2-2: Importing uuid
Using uuid here makes sense for generating unique comment IDs. No issues noted.


60-60: Verify comment relationship parameter
The code uses 'files' instead of 'comments' for the second parameter in getRelationship. This might be a copy-paste mistake. Verify that 'files' is the intended relationship name for comments.


227-233: Testing absence of comment icon
These lines correctly verify that the .fa-comment selector doesn’t exist for the third item, ensuring coverage for actions lacking comments.


384-391: Verifying presence of comment icon and count
Excellent test asserting the comment icon exists and checking its displayed count is 1, ensuring UI is updated correctly.

test/integration/patients/patient/dashboard.js (4)

72-72: Consistent use of the comments relationship
Using 'comments' is more intuitive when defining comment relationships. This is consistent with the PR’s overall intent.


412-415: Verifying empty form region
These lines confirm there’s no rendered content for the form region. Straightforward coverage with no issues.


416-427: Ensuring attachments and comments do not exist
This block validates the non-existence of .fa-paperclip and .fa-comment icons, clarifying UI behavior for items without attachments or comments.


446-453: Ensuring the first item has a comment icon and count
Good test coverage verifying the icon’s presence and the comment count is correctly displayed as “1.”

test/integration/patients/sidebar/action-sidebar.js (1)

1518-1694: Comprehensive test for comment icon show/hide behavior
These lines thoroughly test the logic for displaying and removing the comment icon and its count. The sequence of adding and deleting comments, updating the icon’s visibility and count, is well covered.

test/integration/patients/patient/patient-flow.js (6)

621-621: Good integration of a comment relationship for testing
This ensures that the action under test is initialized with an existing comment, aligning well with the PR objective to display comment counts.


688-689: Effective check for displayed comment icon and count
This test step confirms that the comment icon and the “1” count appear when there is exactly one associated comment, which matches the PR’s purpose of showing comment counts.


701-701: Proper validation for absence of comment icon
This line verifies that the comment icon is not displayed if there are zero comments, ensuring correct UI behavior.


2638-2638: UUID usage for test comment ID
Using uuid() to generate a unique comment ID is a solid approach for realistic websocket tests, preventing ID collisions.


2666-2667: Initialization with empty files and comments
Defining empty relationships helps test the absence of attachments/comments. This setup accurately reflects a scenario with no comments or files.


2993-3031: Robust test for realtime comment addition/removal
These lines thoroughly test websocket-driven comment events, ensuring the UI displays the correct comment icon and count, and subsequently hides them upon removal. Great coverage for the PR’s dynamic comment-count feature.

test/integration/patients/worklist/worklist.js (4)

3-3: Use of NIL_UUID and uuid
Importing NIL as NIL_UUID and v4 as uuid extends flexibility in test scenarios, enabling “no-owner” cases and unique ID creation for comments.


392-392: Adding a comment relationship in test actions
Supplying a UUID-based comment ensures a test scenario for a single comment, which is crucial for verifying comment count displays in the worklist.


764-770: Verifying presence of comment icon and count
The test ensures that the icon and count “1” appear in the first row. This precisely matches the PR’s functionality to show the current comment total.


771-775: Ensuring no comment icon for the second row
These lines confirm that items with zero comments do not display a comment icon, preserving accurate UI consistency.

src/js/views/patients/worklist/worklist-list.scss (5)

33-39: New .worklist-list__display-icon-text class
This style block neatly positions and formats icon-adjacent text. It aligns with the UI need to display concise numeric comment counts.


83-83: Adjusted name column width
The decrease to 17% can help accommodate additional icons or columns. Ensure no unintended text overflow at narrower screen sizes.


88-88: Broadening .worklist-list__meta
Increased to 48% widens metadata space; continue monitoring columns to ensure text remains properly truncated or wrapped.
[approve]


93-93: Expanding .worklist-list__action-meta-header
Consistent with the previous width change, this ensures meta columns line up for actions.


98-98: Expanding .worklist-list__flow-meta-header
Maintaining consistency with action meta headers by matching the 48% width helps unify the layout.

src/js/views/patients/patient/patient.scss (3)

143-143: Wider .patient__list-meta container
Adjusting from 510px to 562px can better accommodate new icon text (e.g., comment count). Validate responsiveness on smaller displays.


146-152: Consolidated attachment/comment styling
These rules unify the icon styling for attachments and comments, simplifying maintenance while visually aligning icon usage.


154-158: Dedicated .patient__action-comment-text styling
Adding a distinct class for comment text clarifies layout intentions and helps maintain consistent text formatting near icons.

package.json (1)

115-115: Perfect alignment with the PR objective.

The newly added "comment" icon is well-suited for displaying the comment count. There are no concerns with this change.

Copy link
Contributor Author

@nmajor25 nmajor25 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in this I'm testing the following when a user manually adds or removes comments via the action sidebar:

  • The comment icon is either shown or incremented when a comment is created.
  • The comment icon is either hidden or decremented when a comment is deleted.

I wanted the test sequence to be this:

  1. Initiate test with an action that has no comments.
  2. Add comment and verify icon shows.
  3. Add second comment and verify icon count increments.
  4. Delete a comment and verify icon decrements.
  5. Delete remaining comment and verify icon becomes hidden.

But in our tests, newly added comments remain as .isNew() === true because their model isn't assigned an id after creation. And therefore, their Delete button remains hidden in the UI. I couldn't figure out how to fix this.

So I switched the test sequence around to be this:

  1. Initiate test with an action that has two comments.
  2. Delete a comment and verify icon decrements.
  3. Delete remaining comment and verify icon becomes hidden.
  4. Add comment and verify icon shows.
  5. Add second comment and verify icon count increments.

Doesn't seem like a big deal to me. But it may be a head scratcher for someone in the future when they look at this test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the isNew issue. We should resolve this. The comment should get an id when the POST resolves. This is in our FE code... it should POST with the id and have the id after the save is complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I confirmed this works as expected on QA/production. It's only an issue in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is no longer in reverse sequence. In a306185, the isNew() problem is fixed and the test is refactored to be in the desired order.

this.action.removeComment(model);

Radio.request('ws', 'unsubscribe', model);
},
Copy link
Contributor Author

@nmajor25 nmajor25 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a modal.destroy() here? I don't think we do. It already happens in the view.

But the onRemoveAttachment() function in this file has it, which makes me unsure.

Copy link
Member

@paulfalgout paulfalgout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks close

@@ -140,14 +140,22 @@
}

.patient__list-meta {
width: 510px;
width: 562px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be a min-width?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the isNew issue. We should resolve this. The comment should get an id when the POST resolves. This is in our FE code... it should POST with the id and have the id after the save is complete.

.type('Test comment');

cy
.intercept('POST', '/api/actions/*/relationships/comments', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible I suppose that the 204 is preventing the id, but I don't think it does.. we could check that though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 204 code was the problem. Switched them to 201 and the response body worked 👍 thanks!

Copy link

cypress bot commented Jan 24, 2025

RoundingWell Care Ops Frontend    Run #7197

Run Properties:  status check passed Passed #7197  •  git commit a3061855c9: Refactor `action-sidebar => action comments - show/hide icon in action list item...
Project RoundingWell Care Ops Frontend
Branch Review action-comment-count
Run status status check passed Passed #7197
Run duration 02m 41s
Commit git commit a3061855c9: Refactor `action-sidebar => action comments - show/hide icon in action list item...
Committer Nick Major
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 314
View all changes introduced in this branch ↗︎

@coveralls
Copy link

coveralls commented Jan 24, 2025

Pull Request Test Coverage Report for Build 1723a621-1d9c-4b20-9385-200190ae412d

Details

  • 18 of 18 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 26e0f078-849d-4415-b91f-1fde05769b2c: 0.0%
Covered Lines: 6099
Relevant Lines: 6099

💛 - Coveralls

@nmajor25 nmajor25 requested a review from paulfalgout January 24, 2025 21:54
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
test/integration/patients/sidebar/action-sidebar.js (2)

1567-1637: Consider extracting repeated selectors into constants.

The test uses the same selector .table-list__item .fa-comment multiple times. Consider extracting it into a constant for better maintainability.

+const COMMENT_ICON_SELECTOR = '.table-list__item .fa-comment';
+
 specify('action comments - show/hide icon in action list items', function() {
   // ... test setup ...
   
   cy
     .get('.patient__list')
-    .find('.table-list__item .fa-comment')
+    .find(COMMENT_ICON_SELECTOR)
     .should('exist')
     .next()
     .should('contain', '1');
     
   // ... rest of the test ...

1639-1692: Extract repeated delete comment sequence into a helper function.

The comment deletion sequence is duplicated. Consider extracting it into a helper function to improve maintainability and readability.

+const deleteComment = () => {
+  cy
+    .get('[data-activity-region]')
+    .find('.comment__item')
+    .first()
+    .find('.js-edit')
+    .click();
+
+  cy
+    .get('[data-activity-region]')
+    .find('.js-delete')
+    .click();
+
+  cy
+    .get('.modal--small')
+    .find('.js-submit')
+    .click()
+    .wait('@routeDeleteComment');
+};
+
 specify('action comments - show/hide icon in action list items', function() {
   // ... test setup ...
   
-  cy
-    .get('[data-activity-region]')
-    .find('.comment__item')
-    .first()
-    .find('.js-edit')
-    .click();
-
-  cy
-    .get('[data-activity-region]')
-    .find('.js-delete')
-    .click();
-
-  cy
-    .get('.modal--small')
-    .find('.js-submit')
-    .click()
-    .wait('@routeDeleteComment');
+  deleteComment();
   
   // ... verify UI updates ...
   
-  cy
-    .get('[data-activity-region]')
-    .find('.comment__item')
-    .first()
-    .find('.js-edit')
-    .click();
-
-  cy
-    .get('[data-activity-region]')
-    .find('.js-delete')
-    .click();
-
-  cy
-    .get('.modal--small')
-    .find('.js-submit')
-    .click()
-    .wait('@routeDeleteComment');
+  deleteComment();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d355c2e and a306185.

📒 Files selected for processing (1)
  • test/integration/patients/sidebar/action-sidebar.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-build
🔇 Additional comments (2)
test/integration/patients/sidebar/action-sidebar.js (2)

1518-1560: Well-structured test setup with proper isolation!

The test initialization is thorough with proper route mocking and isolated test data.


1518-1693: Consider adding error case test coverage.

The test thoroughly covers the happy path but doesn't verify the behavior when a comment fails to be added (e.g., server error). Consider adding a test case to verify error handling.

Example test case to add:

cy
  .intercept('POST', '/api/actions/*/relationships/comments', {
    statusCode: 500,
    body: {
      errors: [{
        status: '500',
        title: 'Internal Server Error'
      }]
    }
  })
  .as('routePostCommentError');

cy
  .get('[data-comment-region]')
  .find('.js-input')
  .type('Test comment that will fail');

cy
  .get('[data-comment-region]')
  .find('.js-post')
  .click()
  .wait('@routePostCommentError');

cy
  .get('.alert-box')
  .should('contain', 'Error posting comment');

cy
  .get('.patient__list')
  .find('.table-list__item .fa-comment')
  .should('not.exist');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants