Skip to content

feat(e2e): refine model filtering and test options - #677

Merged
steebchen merged 1 commit into
mainfrom
fix/e2eim
Aug 30, 2025
Merged

steebchen merged 1 commit into
mainfrom
fix/e2eim

Conversation

@steebchen

@steebchen steebchen commented Aug 29, 2025

Copy link
Copy Markdown
Member

Enhanced model filtering logic in e2e tests by integrating TEST_MODELS variable directly into the primary filter chain. Removed redundant filtering steps, improving code clarity and efficiency. Updated getTestOptions to account for models with the test-only flag or TEST_MODELS.

Summary by CodeRabbit

  • Tests
    • E2E model selection now respects TEST_MODELS at the provider/model level, simplifying targeted runs.
    • Removed per-test-case filtering; selection occurs once at the model level for consistency.
    • In CI, failing tests automatically retry up to 3 times.
    • Locally, suites may be skipped when only “test-only” specs are present or when TEST_MODELS is set.
    • Overall, more predictable and transparent test gating behavior.

Enhanced model filtering logic in e2e tests by integrating `TEST_MODELS` variable directly into the primary filter chain. Removed redundant filtering steps, improving code clarity and efficiency. Updated `getTestOptions` to account for models with the test-only flag or `TEST_MODELS`.
@coderabbitai

coderabbitai Bot commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds environment-driven gating for E2E tests. In keys-provider tests, getTestOptions now inspects models/providers, setting retries on CI and skipping locally based on TEST_MODELS or test-only flags. In gateway E2E, shifts TEST_MODELS filtering from per-test-case to a model-level provider/model-pair filter.

Changes

Cohort / File(s) Summary
E2E test gating (keys-provider)
apps/api/src/routes/keys-provider.e2e.ts
Imports models, providers, and ProviderModelMapping; adds typed getTestOptions(): TestOptions. Computes hasTestOnly by scanning models/providers. Returns { retry: 3 } on CI; otherwise { skip: hasTestOnly || !!process.env.TEST_MODELS }. describe uses updated options.
Model selection for E2E (gateway)
apps/gateway/src/api.e2e.ts
Introduces provider/model-pair filter based on TEST_MODELS after existing model filters. Removes per-test-case filtering tied to TEST_MODELS. Uses ${provider.providerId}/${model.id} matching to include models when TEST_MODELS is set.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Env as Env (CI, TEST_MODELS)
  participant Models as Models/Providers
  participant KeysSpec as keys-provider.e2e.ts
  participant Vitest as Vitest Runner

  Env->>KeysSpec: Read CI, TEST_MODELS
  KeysSpec->>Models: Scan for provider with test === "only"
  Models-->>KeysSpec: hasTestOnly flag
  KeysSpec->>Vitest: getTestOptions()\n- CI: { retry: 3 }\n- Local: { skip: hasTestOnly || !!TEST_MODELS }
  Vitest-->>KeysSpec: Apply describe options
Loading
sequenceDiagram
  autonumber
  participant Env as Env (TEST_MODELS)
  participant GWSpec as gateway api.e2e.ts
  participant ModelList as All Models × Providers
  participant Final as Final Test Models

  Env-->>GWSpec: specifiedModels (provider/model ids) or empty
  GWSpec->>ModelList: Apply existing filters\n(auto/custom exclusion, deactivated, free-mode)
  GWSpec->>ModelList: Apply TEST_MODELS filter at model level\nmatch providerId/model.id
  ModelList-->>Final: Filtered models
  Note right of GWSpec: Per-test-case TEST_MODELS filters removed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/e2eim

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/gateway/src/api.e2e.ts (1)

65-74: Prevent “phantom” inclusions when TEST_MODELS targets skipped providers

If TEST_MODELS includes a provider/model that’s marked test: "skip", the model passes this filter but yields zero test cases later. Filter them out here to keep counts and logs consistent.

-  return model.providers.some((provider: ProviderModelMapping) => {
-    const providerModelId = `${provider.providerId}/${model.id}`;
-    return specifiedModels.includes(providerModelId);
-  });
+  return model.providers.some((provider: ProviderModelMapping) => {
+    if (provider.test === "skip") return false;
+    const providerModelId = `${provider.providerId}/${model.id}`;
+    return specifiedModels.includes(providerModelId);
+  });
apps/api/src/routes/keys-provider.e2e.ts (1)

21-30: Confirm intent: skipping all provider-key tests when TEST_MODELS is set

Coupling provider-keys tests to TEST_MODELS may hide regressions when developers narrow model E2E locally. Verify this behavior is desired; alternatively, gate only on hasTestOnly.

-  return process.env.CI
-    ? { retry: 3 }
-    : { skip: hasTestOnly || !!process.env.TEST_MODELS };
+  return process.env.CI ? { retry: 3 } : { skip: hasTestOnly };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 42a6287 and 023efaa.

📒 Files selected for processing (2)
  • apps/api/src/routes/keys-provider.e2e.ts (1 hunks)
  • apps/gateway/src/api.e2e.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use localStorage instead of cookies for client-side data persistence

Files:

  • apps/gateway/src/api.e2e.ts
  • apps/api/src/routes/keys-provider.e2e.ts
**/*.{js,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{js,ts}: Use drizzle with the latest object syntax for database operations
For read queries, always use db().query.<table>.findMany() or db().query.<table>.findFirst()

Files:

  • apps/gateway/src/api.e2e.ts
  • apps/api/src/routes/keys-provider.e2e.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use as any or : any in TypeScript files.

Files:

  • apps/gateway/src/api.e2e.ts
  • apps/api/src/routes/keys-provider.e2e.ts
**/*.e2e.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Name end-to-end test files with the .e2e.ts suffix

Files:

  • apps/gateway/src/api.e2e.ts
  • apps/api/src/routes/keys-provider.e2e.ts
apps/{api,gateway}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/{api,gateway}/**/*.{ts,tsx}: Use Zod schemas for validation in backend services
Use Hono as the web framework for backend routes and middleware

apps/{api,gateway}/**/*.{ts,tsx}: Use Drizzle with the latest object syntax for database operations
For read queries, use db().query.

.findMany() or db().query.
.findFirst()

Files:

  • apps/gateway/src/api.e2e.ts
  • apps/api/src/routes/keys-provider.e2e.ts
apps/gateway/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

In apps/gateway (Hono), always use Hono + Zod + OpenAPI for validation and typesafety

Files:

  • apps/gateway/src/api.e2e.ts
apps/api/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

In apps/api (Hono), always use Hono + Zod + OpenAPI for validation and typesafety

Files:

  • apps/api/src/routes/keys-provider.e2e.ts
🧬 Code graph analysis (2)
apps/gateway/src/api.e2e.ts (1)
packages/models/src/models.ts (2)
  • ModelDefinition (89-130)
  • ProviderModelMapping (22-87)
apps/api/src/routes/keys-provider.e2e.ts (1)
packages/models/src/models.ts (1)
  • ProviderModelMapping (22-87)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e / run
  • GitHub Check: build / run
🔇 Additional comments (2)
apps/api/src/routes/keys-provider.e2e.ts (2)

2-6: LGTM: models/providers imports are appropriate for gating logic

The additional imports are minimal and used correctly.


8-15: LGTM: Importing TestOptions improves typing of getTestOptions

Good move to make the return type explicit.

.filter((model) => !model.deactivatedAt || new Date() <= model.deactivatedAt)
// Filter out free models if not in full mode
.filter((model) => fullMode || !(model as ModelDefinition).free);
.filter((model) => fullMode || !(model as ModelDefinition).free)

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.

🛠️ Refactor suggestion

Parse FULL_MODE as a real boolean to avoid accidental truthiness

process.env.FULL_MODE is a string; "false"/"0" are truthy and will include free models unintentionally. Normalize once at definition.

Outside this hunk, update the declaration:

// before
const fullMode = process.env.FULL_MODE;

// after
const fullMode = /^1|true|yes$/i.test(process.env.FULL_MODE ?? "");
🤖 Prompt for AI Agents
In apps/gateway/src/api.e2e.ts around line 63, process.env.FULL_MODE is being
treated as a truthy string which causes values like "false" or "0" to be
considered true; change the environment parsing at its declaration to convert
FULL_MODE into a real boolean (e.g., test the env value against /^1|true|yes$/i
and default to false), then keep the existing .filter(...) but rely on the new
boolean fullMode so free models are excluded as intended.

@steebchen
steebchen added this pull request to the merge queue Aug 30, 2025
Merged via the queue into main with commit abf8439 Aug 30, 2025
13 checks passed
@steebchen
steebchen deleted the fix/e2eim branch August 30, 2025 18:05
@coderabbitai coderabbitai Bot mentioned this pull request Sep 15, 2025
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.

1 participant