Skip to content

Add comprehensive e2e tests for Grievance module - #84

Merged
weilu merged 45 commits into
developfrom
feature/coremis-e2e-grievance
Mar 23, 2026
Merged

Add comprehensive e2e tests for Grievance module#84
weilu merged 45 commits into
developfrom
feature/coremis-e2e-grievance

Conversation

@Shahzaibahmad97

@Shahzaibahmad97 Shahzaibahmad97 commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR adds comprehensive end-to-end tests for the Grievance module, covering grievance creation, comments, filtering, resolution, and navigation workflows.

Dependencies

⚠️ This PR depends on #79 (Base e2e tests infrastructure) and should be merged after #79 is merged.
⚠️ Depends on openimis/openimis-fe-core_js#301
⚠️ Depends on openimis/openimis-fe-grievance_social_protection_js#27

What's Changed

Custom Cypress Commands Added

  • selectDropdownByLabel(label, value) - Generic MUI dropdown selection with optional value parameter (selects first element by default if no value is provided)
  • createGrievance(grievanceData) - Create grievances with all reporter types
  • addGrievanceComment(commentText, commentData) - Add comments with optional reporter types
  • checkGrievanceFieldValues(...) - Verify field values on detail page
  • checkGrievanceFieldValuesInListView(title, category) - Verify fields in list view
  • getGrievanceCodeFromList(title) - Retrieve grievance code for cleanup
  • searchAndOpenGrievanceForEdit(grievanceCode) - Open grievance for editing

Test Coverage

✅ Grievance Creation with Reporter Types

  • Creates an anonymous grievance (None reporter type)
  • Creates a grievance with Individual reporter type
  • Creates a grievance with Beneficiary reporter type
  • Creates a grievance with Attending Staff reporter type

✅ Grievance List View and Filters

  • Displays grievance list with all created grievances
  • Filters grievances by title
  • Filters grievances by category
  • Filters grievances by priority
  • Filters grievances by code
  • Shows historical grievances when Show History is checked
  • Clears all filters when Clear button is clicked

✅ Grievance Navigation and UI Elements

  • Navigates to grievance creation page from menu
  • Navigates to grievance list page from menu
  • Displays required field validation on empty form submission
  • Verifies the create button is available on the list page

Grievance Comments with Reporter Types

  • Adds a comment without reporter type
  • Adds a comment with Individual reporter type
  • Adds a comment with Beneficiary reporter type
  • Adds a comment with Attending Staff reporter type

Grievance Resolution

  • Resolve grievance
  • Reopen a resolved grievance

weilu added 30 commits August 6, 2025 12:43
As it is all Dockerfiles and configs
As suggested by sonar scan’s security results
Also maps auth tests to UAT test numbers
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3 Security Hotspots

See analysis details on SonarQube Cloud

@Shahzaibahmad97
Shahzaibahmad97 marked this pull request as draft December 12, 2025 14:48
- Add JWT cookie check for idempotent login command
- Use unique program codes with timestamps to avoid conflicts
- Move ensureSufficientIndividuals to before hook
- Update navigation selectors to use MUI accordion IDs
- Add update, status, and detail view test suites
- Remove non-existent flag/channel filter tests
- Fix checkGrievanceFieldValues to use correct assertions
Extends grievance tests with full workflow coverage:

- Grievance update: edit title, category, priority and details
- Grievance status workflow: resolve with comment, reopen (unlock)
- Detail view: verify all field values persisted correctly
- Additional filters: flag, channel, and combined multi-filter search
- Comment suite: move ensureSufficientIndividuals to before() hook
  to avoid redundant uploads across tests
- Commands: resolveGrievance now uses comment-based resolution flow
  (add comment → click resolve button on comment)
- Commands: unlockGrievance uses paperHeaderAction lock icon
- Commands: addGrievanceComment reloads page after save to confirm persistence
- Commands: login skips credentials form when JWT cookie already present
- Navigation tests: use #Grievance-header and "Add Grievance" selectors
  matching the actual rendered DOM
…e-grievance

# Conflicts:
#	.github/workflows/ci.yaml
#	cypress/e2e/admin.cy.js
#	cypress/support/commands.js
#	cypress/support/utils.js
- Fix DOM detachment during comment input by using native HTMLInputElement
  value setter instead of cy.type(), avoiding per-keystroke React re-renders
- Fix TicketFilter category filter tests to use specific title assertions
  instead of iterating all rows (DropDownCategoryPicker sends object to filter)
- Fix priority filter tests with positive/negative title assertions for reliability
- Fix openProgramForEditFromList to search by name before finding row,
  resolving pagination-related failures in Beneficiary before hooks
- Fix status workflow tests: add tfoot wait before enterMuiInput to prevent
  DOM detachment from initial page load re-renders in full suite runs
- Update unlockGrievance to reuse searchAndOpenGrievanceForEdit and include
  journal check; use cy.unlockGrievance() in Reopen test
- Replace cy.wait(2000) in addGrievanceComment with deterministic progress
  bar wait matching the pattern used by createGrievance and updateGrievance
- Remove dead testGrievanceCodes array and redundant getGrievanceCodeFromList
  calls from creation tests (codes were collected but never used)
- Remove redundant inner beforeEach cy.login() in update workflow describe
  block (outer beforeEach already covers all tests)
- Remove duplicate cy.login() call inside detail view test body
@Shahzaibahmad97
Shahzaibahmad97 marked this pull request as ready for review February 27, 2026 13:27
Comment thread cypress/e2e/cash-trasfer.cy.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Cypress E2E test suite for the Grievance module and extends shared Cypress commands to support common Grievance workflows (create/update/comment/resolve/filter/navigation), alongside a couple of small test/support cleanups.

Changes:

  • Added cypress/e2e/grievance.cy.js covering grievance creation, list filters, comments, status transitions, detail view checks, and navigation.
  • Extended cypress/support/commands.js with Grievance-specific custom commands and a more “session-aware” cy.login().
  • Minor cleanup/adjustments in existing admin E2E test and README formatting.

Reviewed changes

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

File Description
cypress/support/commands.js Adds Grievance helpers (create/update/comment/resolve/etc.) and modifies cy.login() behavior.
cypress/e2e/grievance.cy.js New end-to-end test suite covering Grievance module workflows.
cypress/e2e/admin.cy.js Removes unused import and updates expected menu text for “Programs”.
README.md Removes trailing blank line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cypress/support/commands.js Outdated
Comment thread cypress/support/commands.js Outdated
Comment thread cypress/support/commands.js Outdated
Comment thread cypress/e2e/grievance.cy.js
Comment thread cypress/e2e/grievance.cy.js
Comment thread cypress/e2e/grievance.cy.js
Comment thread cypress/support/commands.js Outdated
Comment thread cypress/support/commands.js Outdated
Comment thread cypress/support/commands.js Outdated
Comment on lines +797 to +802
// Select first available staff
cy.contains('label', 'Complainant')
.siblings('.MuiInputBase-root')
.find('input')
.click();
cy.get('[role="menu"] li, [role="presentation"] li').first().click();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider extracting a shared command chooseMuiSelectFirstAvailable and use here and above, given it's been used 3 times.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

refactored and used chooseMuiAutocomplete command

cy.get('button[title="Edit"]').click();
});

// Update fields (excluding reporter type and reporter info)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these two fields expected to be disabled for edit? If so, consider adding asserts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added the assert

Comment thread cypress/support/commands.js Outdated
Cypress.Commands.add('addGrievanceComment', (commentText, commentData = {}) => {
cy.contains('button', 'Add Comment').click();
// Use native HTMLInputElement value setter to avoid DOM detachment caused by
// React's per-keystroke re-renders in TicketCommentsPanel (setInterval + controlled input).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this react or us misusing react? Should the input be debounced in the FE code? I'm not suggesting the fix (if any) block this PR. Just wanted to flag if it's an issue, we should log a ticket & fix it, then we can simplify the test code here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don’t think this is a React issue or something that should be solved by debouncing the comment input. The bigger issue seems to be that TicketCommentsPanel keeps polling/refetching comments every 5 seconds even while the add-comment dialog is open, which can cause the dialog subtree to rerender while Cypress is typing. The current test code is working around that instability. I don’t think it should block this PR, but I agree it’s worth logging a follow-up FE ticket so we can pause polling while editing and then simplify the Cypress command back to a normal .type() flow.

Here is the link to the code which does continous polling after every 5 seconds: fe-grievance-module/ticketcommentspanel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see. It was @jdolkowski 's commit as part of openimis/openimis-fe-grievance_social_protection_js#7. The intend was probably just to get the updated status for when the ticket is resolved. As you pointed @Shahzaibahmad97 it's not the most efficient way to achieve it. Please go ahead and log a ticket

Comment thread cypress/support/commands.js
Comment thread README.md
@Shahzaibahmad97
Shahzaibahmad97 requested a review from weilu March 17, 2026 02:20

@weilu weilu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Shahzaibahmad97 LGTM, with one thing I missed in the previous round of review.


cy.updateGrievance(grievanceCode, updateData, {
reporterFieldLabel: 'User',
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check priority & details updated as expected?

@sonarqubecloud

Copy link
Copy Markdown

@weilu
weilu merged commit 0d2de8a into develop Mar 23, 2026
5 of 7 checks passed
@weilu
weilu deleted the feature/coremis-e2e-grievance branch March 23, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request next-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add integration tests on creating/editing/deleting Grievances

4 participants