Skip to content

ocom-verify package changes#242

Open
jasonmorais wants to merge 41 commits into
mainfrom
jason/e2e-with-dev
Open

ocom-verify package changes#242
jasonmorais wants to merge 41 commits into
mainfrom
jason/e2e-with-dev

Conversation

@jasonmorais
Copy link
Copy Markdown
Contributor

@jasonmorais jasonmorais commented May 5, 2026

Summary by Sourcery

Align verification test infrastructure, community UI flows, and coverage tooling around the ocom-verification packages and shared timeout/server abstractions.

New Features:

  • Add centralized timeout configuration and shared TestServer interface for in-process and subprocess-backed test servers.
  • Introduce acceptance UI community create feature tests using React, Apollo, and Ant Design in a jsdom-based environment.
  • Add React/GraphQL/Ant Design wiring for mounting and testing the community create form in acceptance UI tests.

Bug Fixes:

  • Ensure community creation UI keeps the submit button loading state in sync with async onSave handlers.
  • Improve jsdom-based interaction handling by wrapping events in React Testing Library act and correctly setting input values.
  • Harden E2E community creation flows by validating GraphQL responses, list updates, and member list completion, with detailed error reporting.

Enhancements:

  • Restrict merged coverage collection to the ocom-verification packages and add package-level coverage scripts for acceptance API and UI.
  • Refactor portless-based test servers into a generic subprocess-backed PortlessServer that uses centralized timeouts, detached process groups, and health probes.
  • Update TestApiServer, OAuth2 mock server, and Vite dev server to use the new PortlessServer model, adjusted env vars, and GraphQL health checks.
  • Replace direct mongodb-memory-server usage with the shared MongoDB memory mock seedwork, reusing cosmos configuration and improving startup/reachability checks.
  • Unify Cucumber default timeouts for acceptance and E2E tests via shared timeout settings.
  • Improve shared infrastructure startup/shutdown for E2E tests, including pruning stale portless locks and registering process signal handlers.
  • Simplify acceptance UI community tasks to rely on DOM state rather than Serenity notes, and extend page interfaces to expose validation and error elements.
  • Refine GraphQL test server startup/shutdown behavior with centralized timeouts and startup duration logging.
  • Align staff UI dev script with the portless CLI and update local settings to distinguish the community UI directory.

Build:

  • Scope monorepo coverage runs to the verification acceptance packages and add a top-level test:e2e step into the verify pipeline.
  • Add package-level coverage scripts for acceptance API and UI packages and update TypeScript config for acceptance UI to support TS extensions without emit.

Tests:

  • Add new acceptance UI Cucumber step definitions and questions for community creation success and validation error scenarios.
  • Improve E2E test environment orchestration for API, OAuth2, MongoDB, and community Vite servers with more robust lifecycle management.

…ome, and using the dev call of the actual servers, like in the case of auth, to further decrease decoupling
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 5, 2026

Reviewer's Guide

Refactors the verification test infrastructure to use centralized timeout settings and new test server abstractions, tightens the ocom-verification coverage and e2e pipelines, and adds richer community-create UI/API/e2e tests with more robust GraphQL and UI handling while scoping coverage merging to the verification package.

Sequence diagram for community create acceptance UI flow

sequenceDiagram
    actor Tester
    participant CucumberRunner
    participant StepDefinitions
    participant SerenityActor
    participant ReactRender
    participant CommunityCreateComponent
    participant CreateCommunityTask
    participant JsdomPageAdapter
    participant CommunityPage
    participant CommunityUiNotes

    Tester->>CucumberRunner: run_scenario
    CucumberRunner->>StepDefinitions: execute_Given_is_an_authenticated_community_owner
    StepDefinitions->>SerenityActor: actorCalled(actorName)
    StepDefinitions->>ReactRender: mountComponent(CommunityCreate)
    ReactRender-->>StepDefinitions: rendered_container
    StepDefinitions->>CreateCommunityTask: setContainer(container)
    StepDefinitions->>SerenityActor: set_initial_CommunityUiNotes
    SerenityActor-->>StepDefinitions: notes_initialized

    CucumberRunner->>StepDefinitions: execute_When_creates_a_community_with
    StepDefinitions->>SerenityActor: attemptsTo(CreateCommunityTask)
    SerenityActor->>CreateCommunityTask: run(name)
    CreateCommunityTask->>CreateCommunityTask: getContainer()
    CreateCommunityTask->>JsdomPageAdapter: new(container)
    CreateCommunityTask->>CommunityPage: new(adapter)
    CreateCommunityTask->>CommunityPage: fillName(name)
    CommunityPage->>JsdomPageAdapter: fill(selector,name)
    CreateCommunityTask->>CommunityPage: clickCreate()
    CommunityPage->>JsdomPageAdapter: click(selector)
    CreateCommunityTask->>CreateCommunityTask: flushAsync()

    par React_onSubmit_chain
        CommunityCreateComponent-->>StepDefinitions: onSave(values)
        StepDefinitions->>SerenityActor: attemptsTo(update_CommunityUiNotes)
        SerenityActor-->>StepDefinitions: notes_updated
    end

    CucumberRunner->>StepDefinitions: execute_Then_community_should_be_created_successfully
    StepDefinitions->>SerenityActor: answer(CommunityCreatedFlag)
    SerenityActor->>CommunityUiNotes: read(formSubmitted)
    CommunityUiNotes-->>SerenityActor: true_or_false
    SerenityActor-->>StepDefinitions: submitted_flag
    StepDefinitions-->>CucumberRunner: assertion_result
Loading

Class diagram for centralized timeout settings and usage

classDiagram
    class TimeoutSettingsModule {
        +timeouts scenario
        +timeouts serverStartup
        +timeouts serverShutdown
        +timeouts healthProbe
        +timeouts healthProbeInterval
        +timeouts uiInit
        +timeouts uiCleanup
        +getTimeout(key)
    }

    class TimeoutKey {
    }

    class AcceptanceApiHooksModule {
        +setDefaultTimeout(timeout)
    }

    TimeoutSettingsModule --> TimeoutKey : defines
    AcceptanceApiHooksModule --> TimeoutSettingsModule : uses_getTimeout
Loading

Class diagram for community create UI and acceptance helpers

classDiagram
    class CommunityCreateProps {
        +onSave(values)
    }

    class CommunityCreate {
        +props onSave
        +state formLoading
        +onFinish(values)
    }

    class CommunityUiNotes {
        +communityName string
        +formSubmitted boolean
        +lastValidationError string
    }

    class ReactRender {
        +mountComponent(ui, options)
        +unmountComponent()
        +getRendered()
    }

    class CreateCommunityTask {
        +setContainer(container)
        +getContainer()
        +flushAsync()
        +CreateCommunity(name)
    }

    class UiCommunityPage {
        +fillName(name)
        +clickCreate()
        +firstValidationError
        +errorToast
    }

    class CommunityPage {
        +fillName(name)
        +clickCreate()
        +firstValidationError
        +errorToast
    }

    class JsdomPageAdapter {
        +fill(selector, value)
        +click(selector)
        +getText(selector)
    }

    class JsdomElementHandle {
        +fill(value)
        +click()
        +check()
    }

    class CommunityCreateStepDefinitions {
        +Given_is_an_authenticated_community_owner(actorName)
        +When_creates_a_community_with(actorName, dataTable)
        +When_attempts_to_create_a_community_with(actorName, dataTable)
        +Then_community_should_be_created_successfully()
        +Then_community_name_should_be(expectedName)
        +Then_should_see_a_community_error_for(actorName, fieldName)
        +Then_no_community_should_be_created()
    }

    CommunityCreate ..> CommunityCreateProps : implements
    CommunityCreateStepDefinitions --> CommunityCreate : mounts
    CommunityCreateStepDefinitions --> ReactRender : uses_mountComponent

    CommunityCreateStepDefinitions --> CreateCommunityTask : uses
    CreateCommunityTask --> UiCommunityPage : drives
    UiCommunityPage ..> CommunityPage : alias_of
    UiCommunityPage --> JsdomPageAdapter : constructed_with

    JsdomPageAdapter --> JsdomElementHandle : creates

    CommunityCreateStepDefinitions --> CommunityUiNotes : stores_form_state
    CreateCommunityTask --> CreateCommunityTask : uses_getContainer

    CommunityCreate --> CommunityUiNotes : onSave_updates_via_notes
Loading

File-Level Changes

Change Details Files
Scope coverage merging and test scripts to verification packages and adjust monorepo verify pipeline to include e2e tests.
  • Reformatted merge-coverage.js and restricted LCOV discovery to packages/ocom-verification for coverage merging.
  • Updated root package.json test:coverage and verify scripts to only run verification acceptance packages and to invoke e2e tests explicitly.
  • Added test:coverage scripts to acceptance-api and acceptance-ui to participate in merged coverage.
build-pipeline/scripts/merge-coverage.js
package.json
packages/ocom-verification/acceptance-api/package.json
packages/ocom-verification/acceptance-ui/package.json
Introduce centralized timeout configuration and a shared TestServer abstraction for all verification servers.
  • Added timeout-settings module exporting named timeouts and getTimeout with env overrides.
  • Added TestServer/TestServerOptions interfaces and wired them into GraphQLTestServer and PortlessServer.
  • Replaced hard-coded Cucumber timeouts in acceptance-api and e2e hooks with getTimeout('scenario').
packages/ocom-verification/verification-shared/src/settings/timeout-settings.ts
packages/ocom-verification/verification-shared/src/settings/index.ts
packages/ocom-verification/verification-shared/src/servers/test-server.interface.ts
packages/ocom-verification/verification-shared/src/servers/graphql-test-server.ts
packages/ocom-verification/e2e-tests/src/shared/support/servers/portless-server.ts
packages/ocom-verification/acceptance-api/src/shared/support/hooks.ts
packages/ocom-verification/e2e-tests/src/shared/support/hooks.ts
Modernise test infrastructure servers to use pnpm scripts directly, new env layout, and safer lifecycle/shutdown behaviour.
  • Refactored PortlessServer from a portless-proxy wrapper to a generic pnpm subprocess TestServer with health probing, configurable executable, graceful shutdown, and process-group aware signal handling.
  • Updated TestApiServer and TestOAuth2Server to extend the new PortlessServer capabilities, including GraphQL health checks, updated spawn commands (pnpm run dev), and revised env variables for account and staff OIDC.
  • Replaced TestViteServer with TestCommunityViteServer that targets the community UI dev server via pnpm run dev and new uiCommunityDir setting.
  • Added orphaned route-lock pruning in test-environment init and adjusted shared servers export barrel and local settings paths.
  • Updated apps/ui-staff dev script to call portless via pnpm exec with --force.
packages/ocom-verification/e2e-tests/src/shared/support/servers/portless-server.ts
packages/ocom-verification/e2e-tests/src/shared/support/servers/test-api-server.ts
packages/ocom-verification/e2e-tests/src/shared/support/servers/test-oauth2-server.ts
packages/ocom-verification/e2e-tests/src/shared/support/servers/test-community-vite-server.ts
packages/ocom-verification/e2e-tests/src/shared/support/servers/test-environment.ts
packages/ocom-verification/e2e-tests/src/shared/support/servers/index.ts
packages/ocom-verification/verification-shared/src/settings/local-settings.ts
apps/ui-staff/package.json
Switch MongoDB test server to use the shared Cellix memory replica-set seedwork and align settings with apiSettings.
  • Replaced direct mongodb-memory-server usage with @cellix/server-mongodb-memory-mock-seedwork, storing a disposer rather than MongoMemoryReplSet.
  • Build connectionString from apiSettings.cosmosDbPort/Name and replicaSetName parsed from cosmosDbConnectionString with fallback to a default name.
  • Updated start/stop logic to prefer an existing reachable instance and only dispose the memory server when started locally, with seeding based on the constructed connection string.
  • Exported the TestServer types from the verification-shared servers barrel and added the new seedwork dependency while dropping mongodb-memory-server.
packages/ocom-verification/verification-shared/src/servers/test-mongodb-server.ts
packages/ocom-verification/verification-shared/src/servers/index.ts
packages/ocom-verification/verification-shared/package.json
Strengthen E2E community create flow to be GraphQL-aware and validate follow-up queries and UI state.
  • Changed CreateCommunity E2E task to navigate directly to the create route, removed reliance on a create button, and added Playwright Response-based helpers for GraphQL operation detection and payload selection.
  • Added typed GraphQL payload models, GraphQL error extraction, and logic to validate mutation success, created name, downstream list query membership, and members list health, with detailed error messages and notes updates.
  • Improved validation error handling by waiting briefly for inline errors, falling back to toast messages when no GraphQL response arrives, and asserting that the created community appears in the table cell grid.
packages/ocom-verification/e2e-tests/src/contexts/community/tasks/create-community.ts
packages/ocom-verification/verification-shared/src/pages/page-interfaces/community.page-interface.ts
Rework acceptance UI community-create tests to run against the real React component with Apollo/AntD/Helmet context and simpler notes.
  • Introduced mountComponent/unmountComponent helpers that render components wrapped in HelmetProvider, AntD Config/App, and Apollo MockedProvider.
  • Replaced the previous notes-driven container passing with module-level container setters/getters and a CreateCommunity task that only interacts via the UI, plus an async flush utility.
  • Added new cucumber step definitions for community creation using the real CommunityCreate component, shared questions for created flag/name/error, and more robust validation-error assertions that inspect both Serenity notes and the DOM.
  • Simplified CommunityUiNotes by removing the container field and updated jsdom global setup to support SVGElement and ShadowRoot.
packages/ocom-verification/acceptance-ui/src/shared/support/ui/react-render.ts
packages/ocom-verification/acceptance-ui/src/contexts/community/tasks/create-community.ts
packages/ocom-verification/acceptance-ui/src/contexts/community/step-definitions/create-community.steps.tsx
packages/ocom-verification/acceptance-ui/src/contexts/community/abilities/community-types.ts
packages/ocom-verification/acceptance-ui/src/shared/support/ui/jsdom-setup.ts
packages/ocom-verification/acceptance-ui/src/contexts/community/step-definitions/index.ts
packages/ocom-verification/acceptance-ui/src/shared/support/hooks.ts
Update the CommunityCreate UI component and jsdom adapter to better support async form submission and React 18+/Testing Library behaviour.
  • Changed CommunityCreate onSave prop to allow async handlers and made onFinish await onSave before clearing the loading state.
  • Updated the JsdomElementHandle adapter to use React Testing Library act() around fill/click/check and to manipulate input values via the native value setter to trigger React-controlled inputs correctly.
packages/ocom/ui-community-route-accounts/src/components/community-create.tsx
packages/ocom-verification/verification-shared/src/pages/adapters/jsdom-adapter.ts
Align verification packages’ tooling and dependencies for acceptance UI/API tests and add centralized shutdown handling for E2E infrastructure.
  • Added Apollo, React, AntD, Helmet, GraphQL, and Serenity console reporter to acceptance-ui runtime deps and rebalanced devDependencies; widened tsconfig rootDir and enabled TS 5.6+ options like allowImportingTsExtensions and noEmit.
  • Registered SIGINT/SIGTERM handlers in shared-infrastructure to stop all servers and browser instances on test process shutdown, and switched to TestCommunityViteServer naming.
  • Adjusted acceptance API mock application services to return a more accurate generic type for the noop Apollo service.
packages/ocom-verification/acceptance-ui/package.json
packages/ocom-verification/acceptance-ui/tsconfig.json
packages/ocom-verification/e2e-tests/src/shared/support/shared-infrastructure.ts
packages/ocom-verification/acceptance-api/src/shared/support/application-services/mock-application-services.ts
Minor documentation and config tweaks related to verification and tooling.
  • Tweaked README spacing around a preserved setup-notes code block for clearer formatting.
  • Adjusted .snyk, c8, and turbo configs and pnpm-lock to reflect new verification tooling (no behavioural code paths).
readme.md
.snyk
packages/ocom-verification/acceptance-api/.c8rc.json
packages/ocom-verification/acceptance-api/turbo.json
packages/ocom-verification/acceptance-ui/.c8rc.json
packages/ocom-verification/acceptance-ui/turbo.json
pnpm-lock.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jasonmorais jasonmorais changed the title initial commit for verify ocom-verify package changes May 5, 2026
@jasonmorais jasonmorais marked this pull request as ready for review May 6, 2026 14:36
@jasonmorais jasonmorais requested a review from a team May 6, 2026 14:36
@jasonmorais jasonmorais requested a review from a team as a code owner May 6, 2026 14:36
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="build-pipeline/scripts/merge-coverage.js" line_range="55" />
<code_context>
+				if (entry.name !== 'node_modules' && entry.name !== '.git') {
+					findLcovFiles(fullPath);
+				}
+			} else if (entry.name === 'lcov.info' && fullPath.includes('/coverage/')) {
+				lcovFiles.push(fullPath);
+			}
</code_context>
<issue_to_address>
**issue (bug_risk):** Path check for coverage directory is POSIX-only and will miss files on Windows

`fullPath.includes('/coverage/')` relies on POSIX path separators, so it won’t match on Windows where `fullPath` uses `\`. Normalize the path first (e.g. `const normalized = fullPath.replace(/\\/g, '/')`) before checking `includes`, or use `path.normalize`/`path.sep` to keep this cross‑platform.
</issue_to_address>

### Comment 2
<location path="packages/ocom-verification/acceptance-ui/src/contexts/community/tasks/create-community.ts" line_range="5" />
<code_context>
-import type { CommunityUiNotes } from '../abilities/community-types.ts';
+import { Interaction } from '@serenity-js/core';
+
+let currentContainer: HTMLElement | null = null;
+
+export function setContainer(container: HTMLElement): void {
</code_context>
<issue_to_address>
**issue (bug_risk):** Global mutable `currentContainer` risks cross-scenario leakage and race conditions

In parallel runs or when scenarios overlap, this shared variable can be overwritten between steps, causing flaky, hard-to-debug failures. Prefer storing the container on the scenario World/actor (e.g., via Serenity `notes` or a custom ability) so each scenario/actor keeps its own reference instead of using a singleton.
</issue_to_address>

### Comment 3
<location path="packages/ocom-verification/acceptance-ui/src/shared/support/ui/react-render.ts" line_range="9-11" />
<code_context>
+
+let rendered: RenderResult | null = null;
+
+export interface MountOptions {
+	mocks?: MockedResponse[];
+	wrapWithRouter?: boolean;
+}
+
</code_context>
<issue_to_address>
**suggestion:** `wrapWithRouter` option is defined but never used when mounting components

The `MountOptions` interface exposes `wrapWithRouter`, but `mountComponent` currently ignores it and always uses the same wrapper tree. To avoid confusing callers and hiding missing routing context in tests, either implement conditional router wrapping based on this flag or remove it from the options API.

Suggested implementation:

```typescript
let rendered: RenderResult | null = null;

```

```typescript
export interface MountOptions {
	mocks?: MockedResponse[];
}

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread build-pipeline/scripts/merge-coverage.js Outdated
Comment thread packages/ocom-verification/acceptance-ui/src/shared/support/ui/react-render.ts Outdated
@jasonmorais
Copy link
Copy Markdown
Contributor Author

image

Example of coverage working for commited changes

nnoce14
nnoce14 previously approved these changes May 18, 2026
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