Skip to content

Add more dedicated e2e tests for file paste in chat input#329

Open
providenz wants to merge 1 commit into
mainfrom
providenz/paste-e2e
Open

Add more dedicated e2e tests for file paste in chat input#329
providenz wants to merge 1 commit into
mainfrom
providenz/paste-e2e

Conversation

@providenz
Copy link
Copy Markdown
Collaborator

@providenz providenz commented Mar 12, 2026

Purpose

Add a few tests for file pasting

Summary by CodeRabbit

  • Tests
    • Replaced a single paste-file test with comprehensive end-to-end coverage for pasting files into the chat input: supported text, image, and PDF attachments; unsupported-type error handling; behavior when uploads are disabled; deduplication of repeated pastes; multiple attachments and removal; and plain-text paste handling.
  • Documentation
    • Updated Unreleased changelog to note the new file-paste e2e test coverage.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8600ec93-9928-4f64-bc14-5b26fe04fda4

📥 Commits

Reviewing files that changed from the base of the PR and between 203ea4d and 84ece21.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/frontend/apps/e2e/__tests__/app-conversations/chat.spec.ts
  • src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts
💤 Files with no reviewable changes (1)
  • src/frontend/apps/e2e/tests/app-conversations/chat.spec.ts
✅ Files skipped from review due to trivial changes (2)
  • CHANGELOG.md
  • src/frontend/apps/e2e/tests/app-conversations/file-paste.spec.ts

Walkthrough

Extracted paste-related e2e coverage from the main chat spec into a new dedicated Playwright test file and added a CHANGELOG entry; the single paste test was removed from chat.spec.ts and replaced by a comprehensive file-paste.spec.ts suite. (50 words)

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added an "Added" entry documenting the new end-to-end tests for file pasting in the chat input.
Test removal
src/frontend/apps/e2e/__tests__/app-conversations/chat.spec.ts
Removed the single paste test and the overrideConfig import.
New e2e paste test suite
src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts
Added a comprehensive Playwright test suite that synthesizes paste events with File/DataTransfer, includes helpers pasteFiles/pasteFile, enables document-upload and web-search via overrideConfig in setup, and asserts behavior for supported files, unsupported types (toast), uploads-disabled, deduplication, multiple files, removal, and plain-text paste.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • suitenumerique/conversations#163 — Modifies the same frontend e2e chat tests and may overlap with the removed/relocated paste test.
  • suitenumerique/conversations#232 — Adds/edits paste-related e2e coverage similar to the new file-paste.spec.ts suite.

Suggested labels

frontend

Suggested reviewers

  • qbey
  • elvoisin
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changeset, which adds dedicated e2e tests for file paste functionality in the chat input.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch providenz/paste-e2e

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.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (2)
src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts (2)

128-145: Give the uploads-disabled case its own setup.

This test reloads the app after the suite-level setup already booted it with uploads enabled. Moving it to a dedicated describe/beforeEach would keep the scenario isolated and less dependent on prior startup state.

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

In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts` around
lines 128 - 145, The test "pasting a file when upload is disabled does nothing"
is relying on suite-level startup with uploads enabled; isolate it by creating a
dedicated describe block (e.g., describe('uploads disabled')) and move this test
inside with its own beforeEach that calls overrideConfig(page, { FEATURE_FLAGS:
{ 'document-upload': 'disabled', ... } }) and then page.goto('/'); ensure the
test uses the same selectors (chatInput via getByRole) but does not depend on
prior state; this keeps overrideConfig and page navigation local to that
describe and guarantees uploads are disabled for this test.

232-256: Extract a shared paste dispatcher for the text case.

This block reimplements the clipboard event stub separately from pasteFile. A common helper for dispatching paste events would keep the file and text scenarios aligned as the component’s clipboardData handling evolves.

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

In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts` around
lines 232 - 256, Extract the duplicated clipboard-event construction into a
shared helper and use it in this test instead of reimplementing the stub;
specifically, create a function (e.g., dispatchPasteEvent or pasteText) that
mirrors the structure used by the existing pasteFile helper (building an
Event('paste'), defining clipboardData with files/items/types/getData, and
dispatching it on a given element) and replace the inline block in
file-paste.spec.ts with a call to that helper so text and file paste logic stay
aligned as clipboardData handling evolves.
🤖 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/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts`:
- Around line 19-23: The test currently silently returns when the chat textarea
selector fails (the code using the variable textarea and selector
'textarea[name="inputchat-textarea"]'), which hides selector regressions; change
the early-return to a hard failure by throwing an Error (or using an assertion)
with a clear message like "Chat textarea not found:
'textarea[name=\"inputchat-textarea\"]' - selector mismatch or UI change" so
pasteFile/test fails fast and points to the broken selector.

---

Nitpick comments:
In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts`:
- Around line 128-145: The test "pasting a file when upload is disabled does
nothing" is relying on suite-level startup with uploads enabled; isolate it by
creating a dedicated describe block (e.g., describe('uploads disabled')) and
move this test inside with its own beforeEach that calls overrideConfig(page, {
FEATURE_FLAGS: { 'document-upload': 'disabled', ... } }) and then
page.goto('/'); ensure the test uses the same selectors (chatInput via
getByRole) but does not depend on prior state; this keeps overrideConfig and
page navigation local to that describe and guarantees uploads are disabled for
this test.
- Around line 232-256: Extract the duplicated clipboard-event construction into
a shared helper and use it in this test instead of reimplementing the stub;
specifically, create a function (e.g., dispatchPasteEvent or pasteText) that
mirrors the structure used by the existing pasteFile helper (building an
Event('paste'), defining clipboardData with files/items/types/getData, and
dispatching it on a given element) and replace the inline block in
file-paste.spec.ts with a call to that helper so text and file paste logic stay
aligned as clipboardData handling evolves.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 31a472c6-a663-41fc-8df7-d7a28d15df53

📥 Commits

Reviewing files that changed from the base of the PR and between 0746d23 and b8faa18.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/frontend/apps/e2e/__tests__/app-conversations/chat.spec.ts
  • src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts
💤 Files with no reviewable changes (1)
  • src/frontend/apps/e2e/tests/app-conversations/chat.spec.ts

Comment thread src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts Outdated
@providenz providenz force-pushed the providenz/paste-e2e branch 2 times, most recently from 1fce926 to 8fa22aa Compare March 17, 2026 15:25
Copy link
Copy Markdown

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

🧹 Nitpick comments (3)
src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts (3)

65-67: Consider using a more stable selector for the chat input.

The partial accessible name 'Enter your message or a' is fragile—any change to the placeholder text will break these tests. A data-testid attribute or the same selector used in pasteFile (textarea[name="inputchat-textarea"]) would be more resilient.

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

In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts` around
lines 65 - 67, The test uses a fragile partial accessible name when locating the
chat input (chatInput via page.getByRole('textbox', { name: 'Enter your message
or a' })); replace this with a stable selector such as the existing
textarea[name="inputchat-textarea"] or a dedicated data-testid used elsewhere
(or add one) and update the selector in this spec (and any helpers like
pasteFile) to use that attribute instead of the partial placeholder text.

128-157: Route handler stacking is subtle but works here.

Calling overrideConfig twice (once in beforeEach, again here) stacks route handlers. Playwright invokes matched handlers in LIFO order, so the second call's disabled config takes precedence—which is the intended behavior. The re-navigation via page.goto('/') ensures the app fetches the updated config.

This works correctly, but the implicit reliance on handler ordering can be confusing. Consider adding a brief comment explaining why the second overrideConfig call overrides the first, or using page.unroute() before re-routing for explicitness.

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

In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts` around
lines 128 - 157, The test relies on calling overrideConfig a second time to
change feature flags and then page.goto('/') to re-fetch config, but this
stacking of Playwright route handlers (LIFO) is subtle; update the test to
either add a brief inline comment clarifying that overrideConfig is
intentionally called again because Playwright handlers are invoked LIFO so the
second handler overrides the first, or explicitly clear previous routes before
re-registering (e.g., call page.unroute or an equivalent cleanup) prior to
calling overrideConfig to make the override unambiguous; reference
overrideConfig, beforeEach, and page.goto('/') when making the change.

232-236: Same silent-failure pattern as pasteFile.

This inline page.evaluate block has the same issue at line 236—silently returning when the textarea isn't found. For consistency with the suggested fix in pasteFile, throw an error here as well.

Proposed fix
       const textarea = document.querySelector(
         'textarea[name="inputchat-textarea"]',
       ) as HTMLTextAreaElement;
-      if (!textarea) return;
+      if (!textarea) {
+        throw new Error(
+          'Chat textarea not found: selector "textarea[name=\\"inputchat-textarea\\"]" may have changed',
+        );
+      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts` around
lines 232 - 236, The inline page.evaluate callback in the file-paste.spec.ts
test silently returns when the textarea isn't found; change that behavior to
throw an error instead so the test fails loudly. Locate the page.evaluate block
(the anonymous function that queries 'textarea[name="inputchat-textarea"]') and
replace the early return with throwing a clear Error (e.g., "textarea not
found") so failures mirror the pasteFile fix and surface in the test runner.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts`:
- Around line 65-67: The test uses a fragile partial accessible name when
locating the chat input (chatInput via page.getByRole('textbox', { name: 'Enter
your message or a' })); replace this with a stable selector such as the existing
textarea[name="inputchat-textarea"] or a dedicated data-testid used elsewhere
(or add one) and update the selector in this spec (and any helpers like
pasteFile) to use that attribute instead of the partial placeholder text.
- Around line 128-157: The test relies on calling overrideConfig a second time
to change feature flags and then page.goto('/') to re-fetch config, but this
stacking of Playwright route handlers (LIFO) is subtle; update the test to
either add a brief inline comment clarifying that overrideConfig is
intentionally called again because Playwright handlers are invoked LIFO so the
second handler overrides the first, or explicitly clear previous routes before
re-registering (e.g., call page.unroute or an equivalent cleanup) prior to
calling overrideConfig to make the override unambiguous; reference
overrideConfig, beforeEach, and page.goto('/') when making the change.
- Around line 232-236: The inline page.evaluate callback in the
file-paste.spec.ts test silently returns when the textarea isn't found; change
that behavior to throw an error instead so the test fails loudly. Locate the
page.evaluate block (the anonymous function that queries
'textarea[name="inputchat-textarea"]') and replace the early return with
throwing a clear Error (e.g., "textarea not found") so failures mirror the
pasteFile fix and surface in the test runner.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 391fa347-9397-4e7a-8368-4172b68d6671

📥 Commits

Reviewing files that changed from the base of the PR and between b8faa18 and 1fce926.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/frontend/apps/e2e/__tests__/app-conversations/chat.spec.ts
  • src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts
💤 Files with no reviewable changes (1)
  • src/frontend/apps/e2e/tests/app-conversations/chat.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Copy link
Copy Markdown

@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: 2

🤖 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/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts`:
- Around line 187-209: The test "pasting multiple different files shows all
attachments" currently simulates two separate paste events; change it to
dispatch both files in a single paste event by extending or overloading the
pasteFile helper (pasteFile) to accept an array of file descriptors (or add a
new helper pasteFiles) and synthesize a single clipboard event whose
clipboardData.files/items contains both files; then assert both 'first.txt' and
'second.pdf' are visible and that removeButtons (getByRole name 'Remove
attachment') has count 2. Ensure the new pasteFile/pasteFiles API is used by
this test so the app receives one multi-file paste rather than two single-file
pastes.
- Around line 230-275: The synthetic paste event bypasses browser insertion so
add an assertion (or better, use a real clipboard paste) to verify the textbox
actually receives "just plain text": in the test "pasting text (not a file)
should not create an attachment" after locating
textarea[name="inputchat-textarea"] (and using the chatInput variable), write
"just plain text" to the clipboard (e.g., navigator.clipboard.writeText or
Playwright's clipboard API), focus the textarea and simulate a paste keypress
(Ctrl/Meta+V), then assert the textarea's value or chatInput text equals "just
plain text" in addition to the existing attachment-absence and visibility checks
so the test fails if paste handling is broken.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6547140c-0356-4f29-a9b5-15d23e0c0a13

📥 Commits

Reviewing files that changed from the base of the PR and between 1fce926 and 8fa22aa.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/frontend/apps/e2e/__tests__/app-conversations/chat.spec.ts
  • src/frontend/apps/e2e/__tests__/app-conversations/file-paste.spec.ts
💤 Files with no reviewable changes (1)
  • src/frontend/apps/e2e/tests/app-conversations/chat.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

@providenz providenz requested a review from qbey March 23, 2026 09:56
@providenz providenz force-pushed the providenz/paste-e2e branch from 8fa22aa to 203ea4d Compare March 25, 2026 08:54
Signed-off-by: Laurent Paoletti <lp@providenz.fr>
@providenz providenz force-pushed the providenz/paste-e2e branch from 203ea4d to 84ece21 Compare March 25, 2026 12:24
@sonarqubecloud
Copy link
Copy Markdown

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