Skip to content

test(chat): align ChatInterface selector hooks#2085

Open
ryanmaclean wants to merge 1 commit intomainfrom
fix/chatinterface-selector-compat
Open

test(chat): align ChatInterface selector hooks#2085
ryanmaclean wants to merge 1 commit intomainfrom
fix/chatinterface-selector-compat

Conversation

@ryanmaclean
Copy link
Owner

@ryanmaclean ryanmaclean commented Mar 2, 2026

Problem

Dependabot PRs are repeatedly blocked by ChatInterface selector drift in unit tests (selectors in tests no longer match component DOM hooks).

Scope

  • src/components/ai/ChatInterface.tsx
  • tests/components/ai/ChatInterface.test.tsx

Changes

  • Add model-badge test hook to header model display in ChatInterface.
  • Update ChatInterface unit tests to use current selectors (chat-input, user-message, assistant-message).

Risk/Rollback

Low risk: selector/test-hook alignment only; no runtime logic changes.
Rollback: revert this PR.

Validation

  • Attempted local run: npx jest --runInBand tests/components/ai/ChatInterface.test.tsx
  • Blocked by environment dependency issue: jest-environment-jsdom missing in this workspace, so CI is source of truth for this change.

Summary by CodeRabbit

  • Tests
    • Updated test selectors and identifiers to improve test coverage and maintainability.

Copilot AI review requested due to automatic review settings March 2, 2026 06:10
@claude
Copy link

claude bot commented Mar 2, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

Walkthrough

This PR updates the AI Chat Interface component to add a data-testid attribute to the ModelDisplay component and synchronizes all test selectors to use a new naming convention, replacing message-* prefixes with chat-* and assistant-message-specific identifiers.

Changes

Cohort / File(s) Summary
Component Test Hook
src/components/ai/ChatInterface.tsx
Added data-testid attribute to ModelDisplay component to support test selection and verification.
Test Selector Updates
tests/components/ai/ChatInterface.test.tsx
Updated all test selectors to new naming convention: message-input → chat-input, message-user → user-message, message-assistant → assistant-message. Updated corresponding assertions and queries throughout test suite.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically summarizes the main change: aligning test selectors in ChatInterface tests with current component DOM hooks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/chatinterface-selector-compat

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 and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

PR Analysis 📊

Changed Files Summary:

  • JavaScript/TypeScript files: 2
  • Test files: 1
  • Documentation files: 0
  • Configuration files: 0

CI Status: Running automated checks...

@ryanmaclean ryanmaclean enabled auto-merge (squash) March 2, 2026 06:12
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Dependency Audit Results

# npm audit report

basic-ftp  <5.2.0
Severity: critical
Basic FTP has Path Traversal Vulnerability in its downloadToDir() method - https://github.com/advisories/GHSA-5rq4-664w-9x2c
fix available via `npm audit fix`
node_modules/basic-ftp

fast-xml-parser  <5.3.8
fast-xml-parser has stack overflow in XMLBuilder with preserveOrder - https://github.com/advisories/GHSA-fj3w-jwp8-x2g3
fix available via `npm audit fix --force`
Will install @aws-sdk/client-s3@3.893.0, which is a breaking change
node_modules/fast-xml-parser
  @aws-sdk/xml-builder  >=3.894.0
  Depends on vulnerable versions of fast-xml-parser
  node_modules/@aws-sdk/xml-builder
    @aws-sdk/core  >=3.894.0
    Depends on vulnerable versions of @aws-sdk/xml-builder
    node_modules/@aws-sdk/core
      @aws-sdk/client-s3  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/credential-provider-node
      Depends on vulnerable versions of @aws-sdk/middleware-flexible-checksums
      Depends on vulnerable versions of @aws-sdk/middleware-sdk-s3
      Depends on vulnerable versions of @aws-sdk/middleware-user-agent
      Depends on vulnerable versions of @aws-sdk/signature-v4-multi-region
      Depends on vulnerable versions of @aws-sdk/util-user-agent-node
      node_modules/@aws-sdk/client-s3
      @aws-sdk/credential-provider-env  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      node_modules/@aws-sdk/credential-provider-env
      @aws-sdk/credential-provider-http  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      node_modules/@aws-sdk/credential-provider-http
      @aws-sdk/credential-provider-ini  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/credential-provider-env
      Depends on vulnerable versions of @aws-sdk/credential-provider-http
      Depends on vulnerable versions of @aws-sdk/credential-provider-login
      Depends on vulnerable versions of @aws-sdk/credential-provider-process
      Depends on vulnerable versions of @aws-sdk/credential-provider-sso
      Depends on vulnerable versions of @aws-sdk/credential-provider-web-identity
      Depends on vulnerable versions of @aws-sdk/nested-clients
      node_modules/@aws-sdk/credential-provider-ini
      @aws-sdk/credential-provider-login  *
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/nested-clients
      node_modules/@aws-sdk/credential-provider-login
      @aws-sdk/credential-provider-process  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      node_modules/@aws-sdk/credential-provider-process
      @aws-sdk/credential-provider-sso  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/nested-clients
      Depends on vulnerable versions of @aws-sdk/token-providers
      node_modules/@aws-sdk/credential-provider-sso
      @aws-sdk/credential-provider-web-identity  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/nested-clients
      node_modules/@aws-sdk/credential-provider-web-identity
        @aws-sdk/credential-provider-node  >=3.894.0
        Depends on vulnerable versions of @aws-sdk/credential-provider-env
        Depends on vulnerable versions of @aws-sdk/credential-provider-http
        Depends on vulnerable versions of @aws-sdk/credential-provider-ini
        Depends on vulnerable versions of @aws-sdk/credential-provider-process
        Depends on vulnerable versions of @aws-sdk/credential-provider-sso
        Depends on vulnerable versions of @aws-sdk/credential-provider-web-identity
        node_modules/@aws-sdk/credential-provider-node
      @aws-sdk/middleware-flexible-checksums  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      node_modules/@aws-sdk/middleware-flexible-checksums
      @aws-sdk/middleware-sdk-s3  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      node_modules/@aws-sdk/middleware-sdk-s3
        @aws-sdk/signature-v4-multi-region  >=3.894.0
        Depends on vulnerable versions of @aws-sdk/middleware-sdk-s3
        node_modules/@aws-sdk/signature-v4-multi-region
      @aws-sdk/middleware-user-agent  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      node_modules/@aws-sdk/middleware-user-agent
        @aws-sdk/util-user-agent-node  >=3.894.0
        Depends on vulnerable versions of @aws-sdk/middleware-user-agent
        node_modules/@aws-sdk/util-user-agent-node
      @aws-sdk/nested-clients  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/middleware-user-agent
      Depends on vulnerable versions of @aws-sdk/util-user-agent-node
      node_modules/@aws-sdk/nested-clients
      @aws-sdk/token-providers  >=3.894.0
      Depends on vulnerable versions of @aws-sdk/core
      Depends on vulnerable versions of @aws-sdk/nested-clients
      node_modules/@aws-sdk/token-providers

hono  4.12.0 - 4.12.1
Severity: high
Hono is Vulnerable to Authentication Bypass by IP Spoofing in AWS Lambda ALB conninfo - https://github.com/advisories/GHSA-xh87-mx6m-69f3
fix available via `npm audit fix`
node_modules/hono

serialize-javascript  <=7.0.2
Severity: high
Serialize JavaScript is Vulnerable to RCE via RegExp.flags and Date.prototype.toISOString() - https://github.com/advisories/GHSA-5c6j-r48x-rmvq
No fix available
node_modules/serialize-javascript
  terser-webpack-plugin  *
  Depends on vulnerable versions of serialize-javascript
  node_modules/terser-webpack-plugin

23 vulnerabilities (19 low, 3 high, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b572eb5479

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<div className="flex items-center gap-3">
<h2 className="text-lg font-semibold">AI Chat</h2>
<ModelDisplay
data-testid="model-badge"

Choose a reason for hiding this comment

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

P1 Badge Forward model-badge test hook to rendered markup

Passing data-testid to <ModelDisplay> here does not actually create a model-badge element in the DOM, because ModelDisplay currently only destructures model, className, showDetails, and compact and never forwards extra props to its root node (src/components/ai/ModelDisplay.tsx). In this scenario, selectors like getByTestId('model-badge') in the updated tests (and the existing e2e locator) still fail, so the selector-alignment fix remains broken.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Quick Checks Results

Check Status
ESLint
TypeScript

✅ All quick checks passed!

Copy link
Contributor

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

This PR aims to reduce selector drift failures by aligning ChatInterface unit tests with the component’s current data-testid hooks, and by adding a test hook for the header’s model display.

Changes:

  • Update ChatInterface unit tests to use current selectors (e.g., chat-input, user-message, assistant-message).
  • Add data-testid="model-badge" to the header model display in ChatInterface.

Reviewed changes

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

File Description
tests/components/ai/ChatInterface.test.tsx Updates RTL selectors to match current ChatInterface DOM hooks.
src/components/ai/ChatInterface.tsx Adds a data-testid hook intended to make the header model display selectable in tests.

Comment on lines 362 to 366
<ModelDisplay
data-testid="model-badge"
model={availableModels.find((m) => m.id === selectedModel)}
compact
/>
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

data-testid="model-badge" is being passed to ModelDisplay, but ModelDisplay doesn’t currently forward arbitrary props to a DOM element (it only uses model/className/showDetails/compact). As a result, no element will actually have data-testid="model-badge", and the updated tests using getByTestId('model-badge') will fail. Fix by either (a) wrapping ModelDisplay in a simple DOM element that carries the data-testid, or (b) updating ModelDisplay to accept and spread standard HTML props (including data-testid) onto its top-level element in all render branches.

Suggested change
<ModelDisplay
data-testid="model-badge"
model={availableModels.find((m) => m.id === selectedModel)}
compact
/>
<div data-testid="model-badge">
<ModelDisplay
model={availableModels.find((m) => m.id === selectedModel)}
compact
/>
</div>

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Build Status ✅ Build successful

✅ Build completed successfully!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

🔒 Security Audit Results

Secret Scanning: No secrets detected
⚠️ Environment Config: Missing variables
NPM Audit: Critical/High vulnerabilities
Secret Patterns: None detected


📊 View full results: Security Audit Summary
⏱️ Duration: < 2 minutes

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/ai/ChatInterface.tsx`:
- Line 363: ModelDisplay currently defines ModelDisplayProps without accepting
generic HTML props, so attributes like data-testid passed from ChatInterface are
dropped; update the ModelDisplayProps to extend
React.ComponentPropsWithoutRef<'div'> (or include
HTMLAttributes<HTMLDivElement>) and in the ModelDisplay functional component
destructure the rest (`...rest`) from props and spread them onto the root
element (the div/rendered root in ModelDisplay) so test attributes and other
HTML props (e.g., data-testid="model-badge") are forwarded; ensure to keep
existing props (model, className, showDetails, compact) and merge className
appropriately when spreading rest.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6a2f87 and b572eb5.

📒 Files selected for processing (2)
  • src/components/ai/ChatInterface.tsx
  • tests/components/ai/ChatInterface.test.tsx

<div className="flex items-center gap-3">
<h2 className="text-lg font-semibold">AI Chat</h2>
<ModelDisplay
data-testid="model-badge"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

MODEL_FILE="$(fd 'ModelDisplay.tsx$' src | head -n 1)"
echo "Inspecting: ${MODEL_FILE}"
cat -n "${MODEL_FILE}"

echo
echo "Prop-forwarding signal check:"
rg -n "data-testid|\\.\\.\\.|HTMLAttributes|ComponentProps|props" "${MODEL_FILE}"

Repository: ryanmaclean/vibecode-webgui

Length of output: 10704


Fix ModelDisplay to forward test attributes and HTML props to the root element.

The component's ModelDisplayProps interface accepts only model, className, showDetails, and compact, but does not destructure or forward additional props like data-testid to any DOM element. The data-testid="model-badge" attribute passed in ChatInterface.tsx (line 363) is discarded and tests cannot select this component via that hook. Update the component to accept and spread HTMLAttributes<HTMLDivElement> (or use React.ComponentPropsWithoutRef<'div'>) to enable proper test attribute forwarding.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ai/ChatInterface.tsx` at line 363, ModelDisplay currently
defines ModelDisplayProps without accepting generic HTML props, so attributes
like data-testid passed from ChatInterface are dropped; update the
ModelDisplayProps to extend React.ComponentPropsWithoutRef<'div'> (or include
HTMLAttributes<HTMLDivElement>) and in the ModelDisplay functional component
destructure the rest (`...rest`) from props and spread them onto the root
element (the div/rendered root in ModelDisplay) so test attributes and other
HTML props (e.g., data-testid="model-badge") are forwarded; ensure to keep
existing props (model, className, showDetails, compact) and merge className
appropriately when spreading rest.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Test Results ✅ Passed

Test Suites: 57 failed, 5 skipped, 488 passed, 545 of 550 total
Tests: 355 failed, 104 skipped, 30 todo, 10690 passed, 11179 total

✅ All tests passed! Ready for review.

View test output

Check the Actions tab for detailed test output.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

PR Status Summary

Check Status
Quick Checks ✅ Passed
Tests ✅ Passed
Build ✅ Passed

All checks passed! This PR is ready to merge. 🎉

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