Skip to content

Conversation

@SiddanthNayak
Copy link
Member

@SiddanthNayak SiddanthNayak commented Dec 6, 2025

Proposed Changes

Fixes #14116

  • Added collapsible date for past symptoms / diagnosis and medication history
  • Addressed comments / changes requested by @amjithtitus09 in follow-up PR.

Expanded State
Screenshot 2025-12-06 at 5 10 55 PM

Collapsed State
Screenshot 2025-12-06 at 5 11 32 PM

Tagging: @ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate the bug or test the new feature.
  • Update product documentation.
  • Ensure that UI text is placed in I18n files.
  • Prepare a screenshot or demo video for the changelog entry and attach it to the issue.
  • Request peer reviews.
  • Complete QA on mobile devices.
  • Complete QA on desktop devices.
  • Add or update Playwright tests for related changes

Summary by CodeRabbit

  • New Features

    • Collapsible date-grouped historical records with the most recent five groups auto-expanded.
    • Avatars shown alongside user names in diagnosis and symptom history for clearer attribution.
  • Style

    • Refined table cell styling, including improved corner rounding and conditional highlight for selected rows.
  • Tests

    • Added assertions to verify the "Questionnaire submitted successfully" notification after submissions.

✏️ Tip: You can customize this high-level summary in your review settings.

@SiddanthNayak SiddanthNayak requested review from a team and Copilot December 6, 2025 11:42
@netlify
Copy link

netlify bot commented Dec 6, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 1141d43
🔍 Latest deploy log https://app.netlify.com/projects/care-ohc/deploys/69343eb587236b0008b107e8
😎 Deploy Preview https://deploy-preview-14655.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Per-date historical records are now collapsible and auto-expand the first five groups; table cell Tailwind styling was simplified with conditional highlighting for selected "created_by" cells; diagnosis and symptom history rows now show an Avatar plus name. Tests assert success notifications after submissions.

Changes

Cohort / File(s) Summary
Historical Record Selector
src/components/HistoricalRecordSelector/index.tsx, src/components/HistoricalRecordSelector/RecordItem.tsx
Replaced per-date sections with Collapsible wrappers and added expandedDates state (auto-expanding first five dates, handler to toggle). Simplified table cell className logic: removed complex nth-child selectors, applied generalized Tailwind utilities, added conditional emerald background for selected created_by cells, and adjusted cell rounding rules.
Question Type History Rendering
src/components/Questionnaire/QuestionTypes/DiagnosisQuestion.tsx, src/components/Questionnaire/QuestionTypes/SymptomQuestion.tsx
Replaced plain formatted-name rendering for created_by with an Avatar plus truncated name layout using created_by.profile_picture_url.
Tests – Questionnaire E2E
tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts, tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
Added assertions verifying the "Questionnaire submitted successfully" notification is visible after submissions (initial and duplicate submission flows).

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Linked Issues check ❓ Inconclusive The PR implements collapsible date grouping [#14116], adds creator avatars [#14116], and updates styling for history entries [#14116]. However, color-coded badges, duration columns, and E2E tests mentioned in the linked issue requirements are not addressed in this changeset. Verify whether color-coded status/severity badges, duration columns, and deterministic E2E tests for diagnosis/symptom/medication flows are deferred to a separate PR or are expected in this changeset.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Redesigned Past Symptoms / Past Diagnoses and Medication History Tabs #2' is directly related to the changeset, which implements collapsible date grouping, avatar displays, and styling updates for these specific tabs as a follow-up to issue #14116.
Description check ✅ Passed The description includes the linked issue reference (#14116), summarizes the main changes, and provides screenshots. However, the Merge Checklist shows that specs/tests and product documentation updates are not yet completed.
Out of Scope Changes check ✅ Passed All changes focus on collapsible UI, avatar rendering, and styling updates for history tabs. The TableCell className refactoring and conditional background styling are directly related to the historical records redesign scope.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a collapsible date grouping interface for historical records in the Past Symptoms/Diagnoses and Medication History tabs. The changes improve the UI by allowing users to expand/collapse date groups and add avatar displays for record creators.

Key Changes:

  • Added collapsible functionality to date-grouped historical records with the first 5 date groups expanded by default
  • Enhanced the "recorded by" field with avatar display alongside the user's name
  • Refactored CSS class names from pseudo-selector syntax to utility class format

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/components/Questionnaire/QuestionTypes/SymptomQuestion.tsx Added Avatar component to display profile pictures alongside user names in the recorded_by field
src/components/Questionnaire/QuestionTypes/DiagnosisQuestion.tsx Added Avatar component to display profile pictures alongside user names in the recorded_by field
src/components/HistoricalRecordSelector/index.tsx Implemented collapsible date groups with expand/collapse state management and updated CSS classes
src/components/HistoricalRecordSelector/RecordItem.tsx Updated CSS classes for styling and modified background color logic for selected states

Comment on lines 436 to 438
className={
"border border-gray-200 bg-gray-50 [&:nth-last-child(1)]:rounded-r-md w-12"
"border border-gray-200 bg-gray-50 nth-2:rounded-l-md nth-last-1:rounded-r-md min-w-[150px]"
}
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The CSS classes nth-2:rounded-l-md and nth-last-1:rounded-r-md appear to be custom variants that may not exist in the Tailwind CSS configuration. Standard Tailwind uses pseudo-class variants like first:, last:, or arbitrary variants like [&:nth-child(2)]:. Verify these classes are properly configured in your Tailwind config, otherwise use the standard [&:nth-child(2)]:rounded-l-md and [&:last-child]:rounded-r-md syntax.

Copilot uses AI. Check for mistakes.
activeTypeConfig.expandableFields.length > 0 && (
<TableHead
className={
"border border-gray-200 bg-gray-50 nth-last-1:rounded-r-md w-12"
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The CSS class nth-last-1:rounded-r-md appears to be a custom variant that may not exist in the Tailwind CSS configuration. Verify this class is properly configured, otherwise use the standard [&:last-child]:rounded-r-md or last:rounded-r-md syntax.

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +76
"p-2 text-sm whitespace-pre-wrap border border-gray-200 min-w-[150px]",
"nth-2:rounded-l-md",
"nth-last-1:rounded-r-md",
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The CSS classes nth-2:rounded-l-md and nth-last-1:rounded-r-md appear to be custom variants that may not exist in the Tailwind CSS configuration. Verify these classes are properly configured, otherwise use the standard [&:nth-child(2)]:rounded-l-md and [&:last-child]:rounded-r-md syntax.

Copilot uses AI. Check for mistakes.
"nth-2:rounded-l-md",
"nth-last-1:rounded-r-md",
isSelected && field.key === "created_by"
? "bg-emerald-100!"
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The exclamation mark in bg-emerald-100! is non-standard Tailwind syntax. Use the ! prefix for important modifier: !bg-emerald-100. Additionally, the conditional logic should handle the created_by field differently only when selected, but it's unclear why this field needs special treatment compared to other fields.

Suggested change
? "bg-emerald-100!"
? "!bg-emerald-100"

Copilot uses AI. Check for mistakes.
<TableCell
className={
"p-2 w-12 text-sm border border-gray-200 bg-white [&:nth-child(even)]:bg-gray-100 [&:nth-last-child(1)]:rounded-r-md"
"p-2 w-12 text-sm border border-gray-200 bg-white even:bg-gray-100 nth-last-1:rounded-r-md"
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The CSS class nth-last-1:rounded-r-md appears to be a custom variant that may not exist in the Tailwind CSS configuration. Verify this class is properly configured, otherwise use the standard [&:last-child]:rounded-r-md or last:rounded-r-md syntax.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Dec 6, 2025

🎭 Playwright Test Results

Status: ✅ Passed
Test Shards: 3

Metric Count
Total Tests 205
✅ Passed 205
❌ Failed 0
⏭️ Skipped 0

📊 Detailed results are available in the playwright-final-report artifact.

Run: #3110

Copy link
Contributor

@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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8064b44 and 1141d43.

📒 Files selected for processing (2)
  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts (1 hunks)
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Write concise, technical TypeScript code with accurate examples
Use TypeScript for all code; prefer interfaces over types
Avoid enums; use maps instead
Use TanStack Query for data fetching from the API along with query and mutate utilities for the queryFn and mutationFn
Use raviger for routing

**/*.{ts,tsx}: Use TypeScript with strict mode and ES2022 target
Use interface for defining object types in TypeScript
Avoid explicit any type in TypeScript
Use proper nullability annotations in TypeScript types
Use dedicated error handlers and TypeScript strict null checks

**/*.{ts,tsx}: Use TypeScript for all new code
Prefer interfaces over types for object definitions in TypeScript
Avoid using any type; use proper type definitions in TypeScript
Use type inference where possible in TypeScript
Use TanStack Query for API data management
Prefer React Context for global state management

**/*.{ts,tsx}: Use TanStack Query with the query and mutate utilities from @/Utils/request/
Use appropriate query keys following the resource pattern for TanStack Query
Leverage TanStack Query built-in features for pagination and debouncing
Implement proper error handling using the global error handler for TanStack Query operations
Use useQuery hook with queryKey and queryFn parameters, where queryFn wraps the API route with the query() utility
Use useMutation hook with mutationFn parameter wrapping API routes with the mutate() utility, and implement onSuccess callbacks to invalidate related queries
Support path parameters in TanStack Query using the pathParams option in query/mutate utilities
Support query parameters in TanStack Query using the queryParams option in query/mutate utilities
Use the silent: true option to suppress global error notifications when custom error handling is needed

**/*.{ts,tsx}: Use TypeScript with strict mode and ES2022 target
Use interface for defining object types
Avoid explicit any types and maint...

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Use functional and declarative programming patterns; avoid classes
Prefer iteration and modularization over code duplication
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Use the "function" keyword for pure functions
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements

**/*.{ts,tsx,js,jsx}: Use path aliases for imports from src (@/*)
Use double quotes for strings
Semicolons are required at end of statements
Order imports as: 3rd-party → library → CAREUI → UI → components → hooks → utils → relative
Use PascalCase for component and class names
Use camelCase for variable and function names

**/*.{ts,tsx,js,jsx}: Use path aliases @/* for imports from src directory
Use double quotes for strings
Require semicolons at end of statements
Order imports: 3rd-party → library → CAREUI → UI → components → hooks → utils → relative
Use PascalCase for component and class names
Use camelCase for variable and function names

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Use 2-space indentation

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/02-coding-standards.mdc)

Use camelCase for utility file names (e.g., useAuth.ts)

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/02-coding-standards.mdc)

**/*.spec.ts: Write E2E tests in Playwright following https://playwright.dev/docs/writing-tests
Write meaningful test descriptions

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/04-ui-components.mdc)

**/*.{tsx,ts}: Use Shadcn UI components as the primary component library
Follow the component documentation for proper usage
Customize components using Tailwind CSS
Use navigate and useRedirect from raviger for navigation and redirects
Use Tailwind's responsive classes and follow mobile-first approach
Implement proper ARIA attributes for accessibility
Ensure keyboard navigation works in components
Define component props using TypeScript interfaces
Use translation keys from src/Locale/ for internationalization
Support RTL languages in components
Use proper date/time formatting for multiple language support

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
**/*.{ts,tsx,js,jsx,json,css,scss,html}

📄 CodeRabbit inference engine (AGENTS.md)

Use 2-space indentation

Files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
🧠 Learnings (11)
📓 Common learnings
Learnt from: hrit2773
Repo: ohcnetwork/care_fe PR: 11922
File: cypress/pageObject/Patients/PatientEncounter.ts:140-164
Timestamp: 2025-05-19T16:41:44.446Z
Learning: The PatientEncounter class in Cypress tests intentionally uses different element targeting strategies: `position: "first"` for allergies and `position: "last"` for symptoms and diagnoses, reflecting the different UI behaviors of these components.
📚 Learning: 2024-11-18T10:48:08.500Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9145
File: cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts:93-94
Timestamp: 2024-11-18T10:48:08.500Z
Learning: In `cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts`, bed capacity verification assertions after patient admission are already being performed elsewhere, so adding them here is unnecessary.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2024-12-05T04:20:20.231Z
Learnt from: nihal467
Repo: ohcnetwork/care_fe PR: 9301
File: cypress/e2e/facility_spec/FacilityLocation.cy.ts:220-220
Timestamp: 2024-12-05T04:20:20.231Z
Learning: In `FacilityLocation.cy.ts`, ensure not to suggest adding success message verifications if they are already present in the test steps.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{test,spec}.{ts,tsx} : Implement comprehensive testing in CAREUI components including accessibility and medical workflow scenarios

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2024-11-18T10:46:56.270Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9145
File: cypress/e2e/facility_spec/FacilityHomepage.cy.ts:229-317
Timestamp: 2024-11-18T10:46:56.270Z
Learning: In `cypress/e2e/facility_spec/FacilityHomepage.cy.ts`, when verifying the bed capacity badge reflection, the badge remains the same during multiple actions and only updates after a bed is attached to a patient during consultation. Therefore, it's appropriate to keep the test case consolidated rather than splitting it into smaller tests.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Applies to src/{Utils,types,providers}/**/*.{ts,tsx} : Document medical data flows, validation requirements, and healthcare workflows with clinical reasoning in API and utility code comments

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
📚 Learning: 2025-05-19T16:41:44.446Z
Learnt from: hrit2773
Repo: ohcnetwork/care_fe PR: 11922
File: cypress/pageObject/Patients/PatientEncounter.ts:140-164
Timestamp: 2025-05-19T16:41:44.446Z
Learning: The PatientEncounter class in Cypress tests intentionally uses different element targeting strategies: `position: "first"` for allergies and `position: "last"` for symptoms and diagnoses, reflecting the different UI behaviors of these components.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2025-11-20T09:48:26.486Z
Learnt from: yash-learner
Repo: ohcnetwork/care_fe PR: 14108
File: tests/facility/settings/activityDefinitions/activityDefinitionCreate.spec.ts:86-147
Timestamp: 2025-11-20T09:48:26.486Z
Learning: In tests/facility/settings/activityDefinitions/activityDefinitionCreate.spec.ts, detailed verification of selected values (e.g., code from value sets) in the detail view is intentionally deferred to the list spec, as the creation test focuses on the happy path and basic verification only.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2024-12-04T18:58:47.241Z
Learnt from: kihan2518B
Repo: ohcnetwork/care_fe PR: 8956
File: cypress/e2e/facility_spec/FacilityCreation.cy.ts:261-261
Timestamp: 2024-12-04T18:58:47.241Z
Learning: In `cypress/e2e/facility_spec/FacilityCreation.cy.ts`, the test case titled "Create a new facility with no bed and doctor capacity" includes steps to select bed types and specializations before validation. This is done intentionally to verify that error messages are shown properly when no capacity is specified.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts
  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2025-11-25T13:51:23.408Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/context.instructions.md:0-0
Timestamp: 2025-11-25T13:51:23.408Z
Learning: Applies to src/context/**/*.{test,spec}.{ts,tsx} : Verify audit trail completeness in context tests

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
📚 Learning: 2025-12-05T19:05:40.902Z
Learnt from: pratyush07-hub
Repo: ohcnetwork/care_fe PR: 14651
File: src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx:252-257
Timestamp: 2025-12-05T19:05:40.902Z
Learning: In healthcare components handling discharge status (like EncounterQuestion.tsx), maintainers implement defense-in-depth by adding early-return guards in change handlers (e.g., `if (isDischarged) return;`) even when the UI control is also disabled, to ensure business-critical immutability rules are enforced at multiple layers and protect against edge cases like browser extensions or unexpected UI library behavior.

Applied to files:

  • tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: Test
  • GitHub Check: CodeQL-Build

Comment on lines +148 to +151
await expect(
page.getByText("Questionnaire submitted successfully"),
).toBeVisible();

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Success toast assertion makes the duplicate-diagnosis flow more robust

Asserting "Questionnaire submitted successfully" right after the initial submit tightens the precondition for the duplicate check and aligns this test with the primary diagnosis flow.

If you want the locator to be more consistent with the later duplicate-notification check and resilient to other places using the same text, you could scope it to the notifications region (optional):

-    await expect(
-      page.getByText("Questionnaire submitted successfully"),
-    ).toBeVisible();
+    await expect(
+      page
+        .getByRole("region", { name: "Notifications alt+T" })
+        .getByRole("listitem")
+        .filter({ hasText: "Questionnaire submitted successfully" }),
+    ).toBeVisible();
🤖 Prompt for AI Agents
In tests/facility/patient/encounter/structuredQuestions/diagnosis.spec.ts around
lines 148 to 151, the test should assert that the success toast appears
immediately after the first submit to ensure the duplicate-diagnosis flow starts
from a confirmed submission; add an expectation for the "Questionnaire submitted
successfully" toast right after the initial submit. For robustness, scope the
locator to the notifications region (e.g., target a notifications container then
find the text) so the assertion is resilient to the same message appearing
elsewhere, then proceed with the existing duplicate-notification check.

Comment on lines +129 to +132
await expect(
page.getByText("Questionnaire submitted successfully"),
).toBeVisible();

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Success toast assertion correctly tightens the duplicate-symptom scenario

The new expectation confirms the initial symptom submission succeeded before you reload and attempt the duplicate, which makes the test’s assumptions explicit and consistent with the diagnosis tests.

Optionally, you can mirror the notifications scoping used for the duplicate message for extra resilience:

-    await expect(
-      page.getByText("Questionnaire submitted successfully"),
-    ).toBeVisible();
+    await expect(
+      page
+        .getByRole("region", { name: "Notifications alt+T" })
+        .getByRole("listitem")
+        .filter({ hasText: "Questionnaire submitted successfully" }),
+    ).toBeVisible();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await expect(
page.getByText("Questionnaire submitted successfully"),
).toBeVisible();
await expect(
page
.getByRole("region", { name: "Notifications alt+T" })
.getByRole("listitem")
.filter({ hasText: "Questionnaire submitted successfully" }),
).toBeVisible();
🤖 Prompt for AI Agents
tests/facility/patient/encounter/structuredQuestions/symptom.spec.ts lines
129-132: add an explicit assertion that the success notification ("Questionnaire
submitted successfully") is visible before reloading and attempting the
duplicate submission (you already added this expectation); to harden the test,
locate the toast using the same notification-scoping pattern used for the
duplicate-message assertion (e.g. scope by the notifications container or
role/status) rather than a global text search so the check is resilient to other
UI messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant