Skip to content

WEB-1019 Add Playwright E2E spec for create-client CRUD workflow#3699

Merged
IOhacker merged 1 commit into
openMF:devfrom
devvaansh:WEB-1019-add-playwright-e-2-e-spec-for-create-client-crud-workflow
Jul 10, 2026
Merged

WEB-1019 Add Playwright E2E spec for create-client CRUD workflow#3699
IOhacker merged 1 commit into
openMF:devfrom
devvaansh:WEB-1019-add-playwright-e-2-e-spec-for-create-client-crud-workflow

Conversation

@devvaansh

@devvaansh devvaansh commented Jul 2, 2026

Copy link
Copy Markdown
Member

Description

Adds the first Playwright E2E spec for the Create Client workflow as part of the broader WA-3.2 test coverage initiative. The spec validates the complete client creation journey through the Angular mat-stepper UI — from the clients list CTA through General, Family Members, and Preview steps to final submission — and then cross-checks the result directly against the Fineract API to confirm the server stored exactly what the form sent.

A negative-path test covers the required-field validation gate: the Preview step is hidden (areFormvalids()) when a required field is empty, and a mat-error message is shown. Recovery by filling the field restores the Preview
step, proving the guard is driven by the specific validator and not an unrelated form issue.

Three supporting pieces of infrastructure are added that every future spec in
this suite will reuse:

  • createTestClient() payload factory for deterministic, unique test data
  • deleteClient(), getClientFamilyMembers(), deleteClientFamilyMember()
    fixture methods for reliable teardown (Fineract enforces a FK constraint
    that blocks client deletion when family member records exist — the cascade
    guard handles this)
  • slowMo in chromium launchOptions so the UI flow is visible during local
    review without changing test logic

Related issues and discussion

https://mifosforge.jira.com/browse/WEB-1019

Screenshots, if any

Screenshot 2026-07-02 at 5 33 34 AM

UI MODE-

npx playwright test --ui playwright/tests/clients/create-client.spec.ts

client-crud-playwright.mp4

Checklist

  • If you have multiple commits please combine them into one commit by squashing them.
  • Read and understood the contribution guidelines at web-app/.github/CONTRIBUTING.md.

Summary by CodeRabbit

  • New Features

    • Added broader end-to-end coverage for creating clients, including support for family member details during setup.
  • Bug Fixes

    • Improved browser test stability and cleanup so created records are removed more reliably after each run.
    • Adjusted Playwright launch behavior to better control test speed locally while keeping CI runs fast.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@devvaansh, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c25457da-7df9-4495-9956-15ce7dae6e83

📥 Commits

Reviewing files that changed from the base of the PR and between 5b85e40 and 4b530e2.

📒 Files selected for processing (11)
  • eslint.config.js
  • playwright.config.ts
  • playwright/config/routes.ts
  • playwright/config/selectors.ts
  • playwright/factories/client.ts
  • playwright/factories/index.ts
  • playwright/fixtures/fineract-api.ts
  • playwright/pages/clients-list.page.ts
  • playwright/pages/create-client.page.ts
  • playwright/pages/index.ts
  • playwright/tests/clients/create-client.spec.ts

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "pre_merge_checks"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • 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

Walkthrough

Adds Playwright end-to-end testing infrastructure for the create-client flow: a slowMo launch option in Playwright config, a client test-data factory with a barrel export, three new FineractApiClient methods for deleting clients and family members, and a new spec testing happy-path and negative-path create-client stepper flows.

Changes

Create Client E2E test support and spec

Layer / File(s) Summary
Playwright config slowMo option
playwright.config.ts
Adds slowMo to chromium launchOptions, set to 0 in CI or E2E_SLOW_MO/500 otherwise.
Client test data factory
playwright/factories/client.ts, playwright/factories/index.ts
Adds TestClientPayload type and createTestClient factory generating deterministic payloads with unique firstname suffixes, plus a barrel re-export.
Fineract API deletion methods
playwright/fixtures/fineract-api.ts
Adds deleteClient, getClientFamilyMembers, and deleteClientFamilyMember methods to FineractApiClient for test cleanup.
Create-client CRUD spec
playwright/tests/clients/create-client.spec.ts
Adds a new spec with teardown hooks, a happy-path stepper test asserting created client and family member data, and a negative-path test validating required-field enforcement.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Spec as create-client.spec.ts
  participant Factory as createTestClient
  participant UI as Create Client Stepper
  participant API as FineractApiClient

  Spec->>Factory: createTestClient(overrides)
  Spec->>UI: fill General/Family/Address steps
  UI->>API: submit client payload
  API-->>UI: created client + id
  Spec->>API: getClientFamilyMembers(clientId)
  API-->>Spec: family member data
  Spec->>API: deleteClientFamilyMember(clientId, memberId)
  Spec->>API: deleteClient(clientId)
Loading

Suggested reviewers: alberto-art3ch

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a Playwright E2E spec for the create-client CRUD workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@devvaansh
devvaansh force-pushed the WEB-1019-add-playwright-e-2-e-spec-for-create-client-crud-workflow branch from 5b85e40 to 6b85088 Compare July 2, 2026 00:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
playwright/factories/client.ts (1)

64-73: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Uniqueness guarantee can collide across parallel workers.

MODULE_LOAD_EPOCH + testClientSequence are process-local; if two Playwright workers load this module within the same millisecond, their first createTestClient() calls produce identical firstname suffixes, contradicting the "uniquely-named payload" guarantee documented above. No current test submits this payload to the API, but future specs relying on this factory for API creation could hit name collisions under parallel execution.

♻️ Suggested fix: mix in worker index or randomness
-let testClientSequence = 0;
-const MODULE_LOAD_EPOCH = Date.now();
+let testClientSequence = 0;
+const MODULE_LOAD_EPOCH = Date.now();
+const WORKER_SALT = Math.random().toString(36).slice(2, 8);
...
-  const uniqueSuffix = `${MODULE_LOAD_EPOCH}${testClientSequence}`;
+  const uniqueSuffix = `${MODULE_LOAD_EPOCH}${WORKER_SALT}${testClientSequence}`;

Also applies to: 93-102

🤖 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 `@playwright/factories/client.ts` around lines 64 - 73, The `createTestClient`
naming scheme in `playwright/factories/client.ts` can still collide across
parallel Playwright workers because `MODULE_LOAD_EPOCH` and `testClientSequence`
are process-local. Update the firstname/payload generation in `createTestClient`
to mix in a worker-unique value such as the Playwright worker index or a random
component, while keeping the existing `Test...` prefix and uniqueness guarantees
for all callers.
playwright.config.ts (1)

172-175: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Guard against non-numeric E2E_SLOW_MO values.

Number(process.env.E2E_SLOW_MO ?? 500) yields NaN if the env var is set to a non-numeric string, silently passing an invalid slowMo value to Playwright's launch options.

🛠️ Optional fallback
-          slowMo: process.env.CI ? 0 : Number(process.env.E2E_SLOW_MO ?? 500)
+          slowMo: process.env.CI ? 0 : (Number(process.env.E2E_SLOW_MO) || 500)
🤖 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 `@playwright.config.ts` around lines 172 - 175, Guard the Playwright
launchOptions slowMo handling against invalid E2E_SLOW_MO values, since
Number(process.env.E2E_SLOW_MO ?? 500) can produce NaN. Update the slowMo logic
in playwright.config.ts so the value is parsed and validated before being passed
to launchOptions, and fall back to the default delay when E2E_SLOW_MO is missing
or non-numeric. Use the launchOptions block and the slowMo setting as the main
place to fix this.
playwright/tests/clients/create-client.spec.ts (1)

152-157: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Conditional contradicts its own comment.

Comment states the Family Members step is "always present in the wizard," yet the code still gates on .count() > 0. If it's truly always present, the guard is dead code masking a template regression; if it isn't always present, the comment should say so (like the Address-step comment does).

As per path instructions for **/*.spec.ts: "encourage clear Arrange-Act-Assert structure ... and minimal brittle timing dependencies" — an unconditional step assertion would make the happy-path flow more deterministic and easier to follow.

🤖 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 `@playwright/tests/clients/create-client.spec.ts` around lines 152 - 157, The
Family Members step handling in create-client.spec.ts contradicts its own
comment and hides template regressions. Update the happy-path flow around
createClientPage.stepHeader('Family Members'), goToStep('Family Members'), and
fillFamilyStep(...) to assert the step is present unconditionally if it is truly
always part of the wizard; otherwise, revise the comment to match the optional
guard. Keep the spec in a clear Arrange-Act-Assert shape and avoid the
conditional count() check unless the step is genuinely optional.

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.

Inline comments:
In `@playwright/tests/clients/create-client.spec.ts`:
- Around line 135-140: The manually aligned property colons in the
create-client.spec.ts fixture are causing the Prettier check to fail. Update the
FamilyMemberData object in the create-client test to use standard Prettier
formatting with normal spacing/indentation, and let Prettier reflow the object
consistently without manual colon alignment.

---

Nitpick comments:
In `@playwright.config.ts`:
- Around line 172-175: Guard the Playwright launchOptions slowMo handling
against invalid E2E_SLOW_MO values, since Number(process.env.E2E_SLOW_MO ?? 500)
can produce NaN. Update the slowMo logic in playwright.config.ts so the value is
parsed and validated before being passed to launchOptions, and fall back to the
default delay when E2E_SLOW_MO is missing or non-numeric. Use the launchOptions
block and the slowMo setting as the main place to fix this.

In `@playwright/factories/client.ts`:
- Around line 64-73: The `createTestClient` naming scheme in
`playwright/factories/client.ts` can still collide across parallel Playwright
workers because `MODULE_LOAD_EPOCH` and `testClientSequence` are process-local.
Update the firstname/payload generation in `createTestClient` to mix in a
worker-unique value such as the Playwright worker index or a random component,
while keeping the existing `Test...` prefix and uniqueness guarantees for all
callers.

In `@playwright/tests/clients/create-client.spec.ts`:
- Around line 152-157: The Family Members step handling in create-client.spec.ts
contradicts its own comment and hides template regressions. Update the
happy-path flow around createClientPage.stepHeader('Family Members'),
goToStep('Family Members'), and fillFamilyStep(...) to assert the step is
present unconditionally if it is truly always part of the wizard; otherwise,
revise the comment to match the optional guard. Keep the spec in a clear
Arrange-Act-Assert shape and avoid the conditional count() check unless the step
is genuinely optional.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 847036c5-6387-4348-8876-b843186b5007

📥 Commits

Reviewing files that changed from the base of the PR and between c7098e3 and 5b85e40.

📒 Files selected for processing (5)
  • playwright.config.ts
  • playwright/factories/client.ts
  • playwright/factories/index.ts
  • playwright/fixtures/fineract-api.ts
  • playwright/tests/clients/create-client.spec.ts

Comment thread playwright/tests/clients/create-client.spec.ts
@devvaansh
devvaansh force-pushed the WEB-1019-add-playwright-e-2-e-spec-for-create-client-crud-workflow branch 3 times, most recently from 484ccb2 to e3ffae9 Compare July 2, 2026 00:19
- Happy path: drives full mat-stepper (General → Family Members →
  Preview → Submit), asserts redirect to /#/clients/:id/general,
  verifies API echoes displayName, officeId, status=Pending, and
  persists the family member via GET /clients/:id/familymembers
- Negative path: empty lastname blocks Preview step (areFormvalids()),
  mat-error is visible, recovery restores the Preview step header
- playwright/factories/client.ts: createTestClient() payload factory
  with unique-suffix generation and TestClientPayload type
- playwright/factories/index.ts: barrel export
- playwright/fixtures/fineract-api.ts: adds deleteClient(),
  getClientFamilyMembers(), deleteClientFamilyMember() — cascade-
  delete guard in afterEach prevents 403 FK violations on cleanup
- playwright.config.ts: slowMo (default 500ms, CI=0, override via
  E2E_SLOW_MO env var) added to chromium launchOptions

3 tests passing (auth + 2 create-client specs) in ~27s
@devvaansh
devvaansh force-pushed the WEB-1019-add-playwright-e-2-e-spec-for-create-client-crud-workflow branch from e3ffae9 to 4b530e2 Compare July 2, 2026 00:29

@IOhacker IOhacker 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.

LGTM

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.

2 participants