Skip to content

Ofrep contract tests#10

Merged
jonathannorris merged 6 commits intomainfrom
cursor/ofrep-contract-tests-af15
Mar 20, 2026
Merged

Ofrep contract tests#10
jonathannorris merged 6 commits intomainfrom
cursor/ofrep-contract-tests-af15

Conversation

@jonathannorris
Copy link
Copy Markdown
Member

Add OFREP contract tests for the js-ofrep-worker package to validate its protocol compatibility.

The tests use the official OFREP client/provider in-process, routing requests through a custom fetch adapter to the OfrepHandler to ensure protocol-level assertions rather than just internal unit coverage.

Open in Web Open in Cursor 

@cursor
Copy link
Copy Markdown

cursor Bot commented Mar 11, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the robustness of the js-ofrep-worker by introducing dedicated contract tests. These tests are designed to validate the worker's adherence to the OpenFeature OFREP protocol, ensuring that it correctly processes flag evaluations, handles context, preserves metadata, and manages various error conditions. By simulating real-world interactions with the OFREP client and provider, this change provides a higher level of confidence in the worker's protocol compatibility and overall reliability.

Highlights

  • New OFREP Contract Tests: Introduced a new suite of contract tests for the js-ofrep-worker package to ensure its compatibility with the OpenFeature OFREP protocol.
  • In-process Testing Approach: The tests leverage the official OFREP client and provider in-process, routing requests through a custom fetch adapter directly to the OfrepHandler.
  • Comprehensive Protocol Validation: The new tests validate various aspects of the OFREP protocol, including single-flag evaluation, context propagation, metadata preservation, and error handling for missing flags and type mismatches.
  • Bulk Evaluation Testing: Added specific tests to verify the correct behavior of bulk flag evaluation through the OFREP API client.
  • Dependency Updates: Updated package.json and package-lock.json to include necessary OpenFeature OFREP core, provider, and server SDK dependencies for the new tests.
Changelog
  • package-lock.json
    • Added new dev dependencies: @openfeature/ofrep-core, @openfeature/ofrep-provider, @openfeature/server-sdk.
    • Updated @openfeature/core to version 1.9.2.
  • package.json
    • Added new dev dependencies: @openfeature/ofrep-core, @openfeature/ofrep-provider, @openfeature/server-sdk.
  • packages/js-ofrep-worker/test/ofrep-contract.spec.ts
    • Created a new test file for OFREP contract tests.
    • Implemented tests for single-flag evaluation, including boolean, string, and number types.
    • Added tests for context passing and metadata preservation during flag evaluation.
    • Included tests for error conditions such as FLAG_NOT_FOUND and TYPE_MISMATCH.
    • Developed a test for bulk flag evaluation using the OFREP API client.
Activity
  • No specific activity has been recorded for this pull request yet, as it is newly opened.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds OFREP contract tests for the js-ofrep-worker package, which is a great step towards ensuring protocol compatibility. The tests are well-structured and cover several important evaluation scenarios, including single-flag, context-based, and bulk evaluations.

I've added a couple of suggestions to improve the tests further:

  1. A refactoring suggestion to reduce code duplication in the test file.
  2. A recommendation to add test cases for handling malformed requests and evaluating disabled flags, which may uncover a potential bug in the current implementation.

Comment thread packages/js-ofrep-worker/test/ofrep-contract.spec.ts
Comment thread packages/js-ofrep-worker/test/ofrep-contract.spec.ts
cursoragent and others added 2 commits March 20, 2026 19:01
Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: jonathan <jonathan@taplytics.com>
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
@cursor cursor Bot force-pushed the cursor/ofrep-contract-tests-af15 branch from 749799b to 57a9e34 Compare March 20, 2026 19:20
@jonathannorris jonathannorris marked this pull request as ready for review March 20, 2026 19:22
@jonathannorris jonathannorris requested a review from Copilot March 20, 2026 19:22
@jonathannorris
Copy link
Copy Markdown
Member Author

/gemini review

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces OFREP contract tests for the js-ofrep-worker, which is a great step towards ensuring protocol compatibility. The changes correctly update the flag evaluation logic, particularly for disabled flags, to align with the OFREP specification by deferring to code defaults instead of treating them as errors. The implementation of resolveAll has also been improved to include all configured flags in bulk evaluations. The new tests are comprehensive and validate the worker's behavior against the OFREP provider and API client. I have one suggestion regarding type safety in a related file.

Comment thread packages/js-ofrep-worker/src/types.ts
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Copy link
Copy Markdown

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

Adds protocol-level OFREP contract tests for the js-ofrep-worker handler, and adjusts disabled-flag behavior to defer to code defaults (including in bulk evaluation) while keeping metadata available.

Changes:

  • Add OFREP contract tests using the official OFREP client/provider routed in-process to OfrepHandler.
  • Change disabled flags to return DISABLED reason and omit value to defer to code defaults (single + bulk), including updating FlagStore.resolveAll.
  • Update public types to allow OFREP success responses to omit value, and add required test dependencies.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/js-ofrep-worker/test/ofrep-handler.spec.ts Adds assertions that disabled flags defer to code defaults in single and bulk endpoints.
packages/js-ofrep-worker/test/ofrep-contract.spec.ts New upstream contract test suite validating handler compatibility via official OFREP client/provider.
packages/js-ofrep-worker/test/flag-store.spec.ts Updates expectations to treat disabled flags as code-default deferrals and include them in resolveAll.
packages/js-ofrep-worker/src/types.ts Makes OfrepEvaluationSuccess.value optional to represent code-default deferrals.
packages/js-ofrep-worker/src/flag-store.ts Implements DISABLED deferral semantics and updates resolveAll to include disabled flags.
package.json Adds devDependencies needed for contract tests.
package-lock.json Locks new OFREP packages and related dependency updates.

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

Comment thread packages/js-ofrep-worker/src/flag-store.ts Outdated
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
@jonathannorris jonathannorris merged commit 5efb03f into main Mar 20, 2026
4 checks passed
@jonathannorris jonathannorris deleted the cursor/ofrep-contract-tests-af15 branch March 20, 2026 19:36
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.

3 participants