Repository navigation
MOSIP-45334 - Automated the testcases of the story ES-2058 - #2304
Conversation
Signed-off-by: Mohanachandran S <mohanachandran.s@technoforte.co.in> # Conflicts: # ui-test/src/main/java/base/BaseTest.java # ui-test/src/main/java/utils/EsignetUtil.java
WalkthroughThe UI test suite now detects plugins from the eSignet actuator, supports Sunbird RC client and policy flows, and adds schema-driven KBI browser tests with localization, validation, offline recovery, and authentication coverage. ChangesUI test runtime and Sunbird RC flows
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Runner
participant BaseTest
participant EsignetUtil
participant LoginOptionsPage
participant KbiPage
Runner->>BaseTest: execute `@kbi` scenario
BaseTest->>EsignetUtil: resolve KBI ACR and ui_locales
BaseTest->>LoginOptionsPage: open KBI login option
LoginOptionsPage->>KbiPage: click KBI
KbiPage->>EsignetUtil: read transaction KBI schema
KbiPage->>KbiPage: validate fields and submit login
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui-test/AGENTS.md`:
- Line 77: Add a single trailing newline at the end of ui-test/AGENTS.md,
preserving all existing content and formatting.
- Around line 19-23: Correct the launch command in AGENTS.md by placing
-Denv.endpoint="$ENV_ENDPOINT" before -jar, and update the README.md tag example
to invoke the suite through runners.Runner.main() rather than mvn test,
consistent with Surefire’s skipTests=true configuration.
In
`@ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java`:
- Around line 161-166: Update the successful-response branch in
SimplePostForAutoGenId around extractSunbirdOsid so a null osid immediately
throws AdminTestException instead of silently continuing. Keep
writeAutoGeneratedId unchanged for valid identifiers, ensuring failed extraction
prevents the suite from proceeding to deletion.
- Around line 143-152: Update the retry loop in SimplePostForAutoGenId around
postWithBodyAndBearerToken so repeated Sunbird RC policy-creation requests are
idempotent by using a supported idempotency key or resolving the existing osid
before retrying. Add bounded backoff between UNSUCCESSFUL retries while
preserving the existing maximum retry limit and success exit behavior.
In `@ui-test/src/main/java/pages/KbiPage.java`:
- Around line 235-237: Update clickLoginButton to replace the exact English-text
XPath with a language-independent, stable locator for the KBI submit button,
such as its ID, test attribute, or form-scoped submit selector. Keep the
interaction routed through clickOnElement and preserve the existing report
message.
In `@ui-test/src/main/java/stepdefinitions/KbiStepDefinition.java`:
- Around line 320-328: The dropdown validation in the relevant KBI step
currently checks only for nonempty text, allowing English values in non-English
runs. Update the loop over dropdownFields to obtain each field’s expected option
values from the schema for lang, then compare the rendered options from
getDropdownOptionTexts against those values and add mismatches to problems while
preserving the existing assertion and reporting.
- Around line 495-515: Update resolveKnownSunBirdRValue to use an explicit
mapping of exact schema field IDs to their corresponding EsignetUtil fixture
values, including policyName mapped to the fixture value “Start Insurance Gold
Premium.” Remove partial lower-case matching and return null for unsupported
field IDs.
In `@ui-test/src/main/java/utils/EsignetUtil.java`:
- Around line 215-221: Update getPluginName to validate the value returned by
getIdentityPluginNameFromEsignetActuator() before assigning pluginName: when the
authenticator property is null, blank, or otherwise unavailable, reject it
without caching the mosipid fallback. Preserve mock detection for values
containing mockauthenticationservice or sunbirdrcauthenticationservice, and only
cache the appropriate plugin name when a valid authenticator value is available.
In `@ui-test/src/main/resources/featurefiles/KbiForm.feature`:
- Around line 68-93: Add distinct Cucumber tags to the four KBI scenarios in the
feature file, with each tag identifying its required schema variant (default,
added-field, removed-field, or single-field). Ensure the corresponding
environment or prerequisite setup selects that schema before execution, and
document or configure runs to execute only the scenario tag matching the active
schema.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: cea8b3e5-29ab-4a03-a243-b8bd3eeed15a
📒 Files selected for processing (31)
ui-test/AGENTS.mdui-test/README.mdui-test/src/main/java/base/BaseTest.javaui-test/src/main/java/constants/ESignetConstants.javaui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/AddIdentity.javaui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/DeleteWithParam.javaui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.javaui-test/src/main/java/pages/ConsentPage.javaui-test/src/main/java/pages/KbiPage.javaui-test/src/main/java/pages/LoginOptionsPage.javaui-test/src/main/java/runners/Runner.javaui-test/src/main/java/stepdefinitions/KbiStepDefinition.javaui-test/src/main/java/utils/ClaimsUtil.javaui-test/src/main/java/utils/EsignetConfigManager.javaui-test/src/main/java/utils/EsignetUtil.javaui-test/src/main/java/utils/UINManager.javaui-test/src/main/resources/config.propertiesui-test/src/main/resources/esignetUI/CreateClientMock/CreateOIDCClient.ymlui-test/src/main/resources/esignetUI/CreateClientMock/CreateOIDCClientV2SunBird/CreateOIDCClientV2SunBird.hbsui-test/src/main/resources/esignetUI/CreateClientMock/CreateOIDCClientV2SunBird/CreateOIDCClientV2SunBird.ymlui-test/src/main/resources/esignetUI/CreateClientMock/CreateOIDCClientV2SunBird/CreateOIDCClientV2SunBirdResult.hbsui-test/src/main/resources/esignetUI/SunBirdR/CreatePolicySunBirdR/CreatePolicySunBirdR.hbsui-test/src/main/resources/esignetUI/SunBirdR/CreatePolicySunBirdR/CreatePolicySunBirdR.ymlui-test/src/main/resources/esignetUI/SunBirdR/CreatePolicySunBirdR/CreatePolicySunBirdRResult.hbsui-test/src/main/resources/esignetUI/SunBirdR/DeletePolicySunBirdR/DeletePolicySunBirdR.hbsui-test/src/main/resources/esignetUI/SunBirdR/DeletePolicySunBirdR/DeletePolicySunBirdR.ymlui-test/src/main/resources/esignetUI/SunBirdR/DeletePolicySunBirdR/DeletePolicySunBirdRResult.hbsui-test/src/main/resources/featurefiles/KbiForm.featureui-test/testNgXmlFiles/MasterTestSuite.xmlui-test/testNgXmlFiles/esignetPostrequisiteSuite.xmlui-test/testNgXmlFiles/esignetPrerequisiteSuite.xml
💤 Files with no reviewable changes (1)
- ui-test/src/main/resources/config.properties
Signed-off-by: Mohanachandran S <mohanachandran.s@technoforte.co.in>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java (1)
149-164: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winFail explicitly when all Sunbird create attempts return no response.
postWithBodyAndBearerTokenreturnsnullafter a transport exception. If every retry does this, Line 202 dereferencesresponseand hides the registry failure behind aNullPointerException.Throw
AdminTestExceptionafter the retry loop whenresponseisnull.Proposed fix
} while (currLoopCount < SUNBIRD_CREATE_MAX_RETRIES); + if (response == null) { + throw new AdminTestException( + "Sunbird RC create request returned no response after " + currLoopCount + " attempts"); + } } else {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java` around lines 149 - 164, After the Sunbird retry loop in the flow using postWithBodyAndBearerToken, explicitly check whether response is still null and throw AdminTestException before any later response dereference. Preserve the existing retry and interruption behavior, and only add this failure path for exhausted attempts with no response.ui-test/src/main/java/pages/KbiPage.java (1)
75-131: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winLog KBI field interactions through the shared reporting helper.
enterFieldValue,blurField, andtouchThenClearFieldchange browser state without an Extent report entry. AddBasePage.logStepcalls after successful actions. Log field IDs only. Do not log field values.Proposed fix
if (dateInput != null) { setNativeInputValue(dateInput, value); + logStep("Entered KBI date field '" + fieldId + "'", dateInput); return; } WebElement el = driver.findElement(fieldInputLocator(fieldId)); clearField(el); if (!value.isEmpty()) { el.sendKeys(value); } + logStep("Entered KBI field '" + fieldId + "'", el);As per coding guidelines, “every interaction helper must log to the Extent report.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/pages/KbiPage.java` around lines 75 - 131, Update KbiPage methods enterFieldValue, blurField, and touchThenClearField to call the shared BasePage.logStep helper after each successful browser interaction, logging only the fieldId and never the field value. Ensure both date and ordinary-field branches log exactly once after completion, while preserving the existing early returns and behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui-test/src/main/java/utils/EsignetUtil.java`:
- Around line 224-230: Update the actuator fallback in EsignetUtil’s
plugin-resolution flow to assign the fallback value to the local pluginName
before returning, while keeping it uncached for subsequent calls. Ensure
isTestCaseValidForExecution() can safely perform its pluginName.equals
comparisons during transient actuator failures.
---
Outside diff comments:
In
`@ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java`:
- Around line 149-164: After the Sunbird retry loop in the flow using
postWithBodyAndBearerToken, explicitly check whether response is still null and
throw AdminTestException before any later response dereference. Preserve the
existing retry and interruption behavior, and only add this failure path for
exhausted attempts with no response.
In `@ui-test/src/main/java/pages/KbiPage.java`:
- Around line 75-131: Update KbiPage methods enterFieldValue, blurField, and
touchThenClearField to call the shared BasePage.logStep helper after each
successful browser interaction, logging only the fieldId and never the field
value. Ensure both date and ordinary-field branches log exactly once after
completion, while preserving the existing early returns and behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d21b4595-7348-4543-ad2d-e9b7b1ae28e8
📒 Files selected for processing (7)
ui-test/AGENTS.mdui-test/README.mdui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.javaui-test/src/main/java/pages/KbiPage.javaui-test/src/main/java/stepdefinitions/KbiStepDefinition.javaui-test/src/main/java/utils/EsignetUtil.javaui-test/src/main/resources/featurefiles/KbiForm.feature
Signed-off-by: Mohanachandran S <mohanachandran.s@technoforte.co.in>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (6)
ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java (2)
136-138: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winValidate the Sunbird base URL before the retry loop.
When
sunBirdBaseURLis unset,getSunBirdBaseURL()returns an empty value. The code then builds an invalid request and consumes the retry budget. Reject a blank base URL before the first attempt.Proposed fix
tempUrl = EsignetConfigManager.getSunBirdBaseURL(); +if (tempUrl == null || tempUrl.isBlank()) { + throw new AdminTestException("sunBirdBaseURL is required for Sunbird RC tests"); +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java` around lines 136 - 138, Validate the value returned by EsignetConfigManager.getSunBirdBaseURL() before entering the retry loop in the request setup flow. Reject blank or unset sunBirdBaseURL immediately and prevent endpoint construction or retry attempts; retain the existing behavior for a nonblank URL.
149-163: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winMake retry decisions status-aware and fail cleanly after exhaustion.
The loop retries only when the raw body contains uppercase
UNSUCCESSFUL. It misses HTTP 5xx responses without that text and can retry a successful response that contains it. If every attempt returnsnull, later output validation dereferencesresponse. Usenull, HTTP 5xx, and the structured Sunbird failure status to decide retries. ThrowAdminTestExceptionwhen no response remains.Proposed fix
- if (response != null && !response.asString().contains("UNSUCCESSFUL")) { + boolean retryable = response == null + || response.getStatusCode() >= 500 + || isSunbirdUnsuccessful(response); + if (!retryable) { break; } ... } while (currLoopCount < SUNBIRD_CREATE_MAX_RETRIES); + + if (response == null) { + throw new AdminTestException( + "Sunbird RC create returned no response after " + SUNBIRD_CREATE_MAX_RETRIES + + " attempts"); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java` around lines 149 - 163, Update the retry loop in the flow around EsignetUtil.postWithBodyAndBearerToken to base retry decisions on a null response, HTTP 5xx status, or the structured Sunbird failure status rather than raw body text, while allowing successful responses even if their body contains “UNSUCCESSFUL.” After SUNBIRD_CREATE_MAX_RETRIES is exhausted without a usable response, throw AdminTestException before any later response validation dereferences response.ui-test/src/main/java/pages/KbiPage.java (3)
29-31: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse the same field-key variants for all field assertions.
fieldInputLocator()supportsid,name, anddata-field-id.getFieldErrorMessage()andisFieldMarkedRequired()use onlyid, whilegetFieldLabel()also depends onidorfor. A field with onlynameordata-field-idcan be entered but can fail label, error, or required-marker assertions. Reuse one field-container locator based on the same field-key predicate.Proposed direction
+private By fieldContainerLocator(String fieldId) { + return By.xpath( + "//*[self::input or self::select or self::textarea]" + + "[`@id`='" + fieldId + "' or `@name`='" + fieldId + + "' or `@data-field-id`='" + fieldId + "']" + + "/ancestor::div[contains(`@class`,'form-field')][1]"); +} + -//*[`@id`='" + fieldId + "']/ancestor::div[contains(`@class`,'form-field')][1] +fieldContainerLocator(fieldId)Also applies to: 47-62, 133-141, 188-193
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/pages/KbiPage.java` around lines 29 - 31, Update KbiPage field assertion methods getFieldErrorMessage(), isFieldMarkedRequired(), and getFieldLabel() to reuse a shared field-container locator with the same id, name, and data-field-id predicate as fieldInputLocator(). Preserve the existing label, error-message, and required-marker behavior while ensuring fields identified only by name or data-field-id resolve consistently.
75-89: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winLog field and network interactions to Extent reports.
enterFieldValue(),blurField(),touchThenClearField(), andsetOffline()perform direct browser mutations without a report entry. This violates the page-object reporting rule and leaves validation failures without an action trace. Log the field ID and action, but do not log field values.Proposed direction
public void blurField(String fieldId) { + ExtentReportManager.logStep("Blurred KBI field '" + fieldId + "'"); driver.findElement(fieldInputLocator(fieldId)).sendKeys(Keys.TAB); }Also applies to: 111-131, 201-205
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/pages/KbiPage.java` around lines 75 - 89, Update enterFieldValue(), blurField(), touchThenClearField(), and setOffline() to add Extent report entries for each browser or network mutation, including the field ID and action name where applicable but never the field value. Preserve the existing mutation behavior and use the page object's established reporting mechanism.Source: Path instructions
75-89: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftHandle non-text KBI controls explicitly.
enterFieldValue()andtouchThenClearField()only branch forDate, but KBI supportsDropdown,Checkbox, andRadioas rendered control types. Required fields of those types skip form submission or validation becauseclearField()clicks aselectand sends key-delete characters, while fixture values are text-based. Use native selection/clicking helpers for these controls atKbiPage.java:75-89andKbiPage.java:119-131.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/pages/KbiPage.java` around lines 75 - 89, Update enterFieldValue() and touchThenClearField() to explicitly handle Dropdown, Checkbox, and Radio controls using the existing native selection/click helpers rather than clearField() and text input. Preserve the current Date handling, and ensure fixture text values are converted into the appropriate select choice or control state before returning.Source: Path instructions
ui-test/src/main/java/stepdefinitions/KbiStepDefinition.java (1)
450-452: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winPreserve the failure cause when validating Try Again reload.
The
catch (Exception e)block discards WebDriver wait/lookup errors and leavesreloaded = false, so the final assertion does not report why reloading failed. Catch only expected timeout conditions here, or rethrow as an assertion that includes the original cause.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui-test/src/main/java/stepdefinitions/KbiStepDefinition.java` around lines 450 - 452, Update the Try Again reload validation around the catch block in KbiStepDefinition so expected timeout conditions still set reloaded to false, while unexpected WebDriver wait or lookup failures are propagated as an assertion retaining the original cause. Ensure the final assertion reports the underlying reload failure instead of silently discarding it.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.java`:
- Around line 136-138: Validate the value returned by
EsignetConfigManager.getSunBirdBaseURL() before entering the retry loop in the
request setup flow. Reject blank or unset sunBirdBaseURL immediately and prevent
endpoint construction or retry attempts; retain the existing behavior for a
nonblank URL.
- Around line 149-163: Update the retry loop in the flow around
EsignetUtil.postWithBodyAndBearerToken to base retry decisions on a null
response, HTTP 5xx status, or the structured Sunbird failure status rather than
raw body text, while allowing successful responses even if their body contains
“UNSUCCESSFUL.” After SUNBIRD_CREATE_MAX_RETRIES is exhausted without a usable
response, throw AdminTestException before any later response validation
dereferences response.
In `@ui-test/src/main/java/pages/KbiPage.java`:
- Around line 29-31: Update KbiPage field assertion methods
getFieldErrorMessage(), isFieldMarkedRequired(), and getFieldLabel() to reuse a
shared field-container locator with the same id, name, and data-field-id
predicate as fieldInputLocator(). Preserve the existing label, error-message,
and required-marker behavior while ensuring fields identified only by name or
data-field-id resolve consistently.
- Around line 75-89: Update enterFieldValue(), blurField(),
touchThenClearField(), and setOffline() to add Extent report entries for each
browser or network mutation, including the field ID and action name where
applicable but never the field value. Preserve the existing mutation behavior
and use the page object's established reporting mechanism.
- Around line 75-89: Update enterFieldValue() and touchThenClearField() to
explicitly handle Dropdown, Checkbox, and Radio controls using the existing
native selection/click helpers rather than clearField() and text input. Preserve
the current Date handling, and ensure fixture text values are converted into the
appropriate select choice or control state before returning.
In `@ui-test/src/main/java/stepdefinitions/KbiStepDefinition.java`:
- Around line 450-452: Update the Try Again reload validation around the catch
block in KbiStepDefinition so expected timeout conditions still set reloaded to
false, while unexpected WebDriver wait or lookup failures are propagated as an
assertion retaining the original cause. Ensure the final assertion reports the
underlying reload failure instead of silently discarding it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 673ffa5a-af25-4048-a580-7beeb67c4ec6
📒 Files selected for processing (6)
ui-test/src/main/java/io/mosip/testrig/apirig/esignetUI/testscripts/SimplePostForAutoGenId.javaui-test/src/main/java/pages/KbiPage.javaui-test/src/main/java/runners/Runner.javaui-test/src/main/java/stepdefinitions/KbiStepDefinition.javaui-test/src/main/java/utils/EsignetUtil.javaui-test/src/main/resources/featurefiles/KbiForm.feature
zesu22
left a comment
There was a problem hiding this comment.
merging because it is already approved
Automated the testcases of the story ES-2058
Summary by CodeRabbit
New Features
Bug Fixes
Documentation