Skip to content

Conversation

@egordidenko
Copy link
Contributor

@egordidenko egordidenko commented Dec 1, 2025

Description

Checklist

Summary by CodeRabbit

  • New Features

    • Added a Quality Insights configuration option for the uploader.
  • Tests

    • Large expansion of unit and end-to-end test coverage across many components.
    • Test runner now collects coverage by default and test config updated to include coverage.
  • Removal

    • Focus-visible polyfill/utilities removed from the Cloud Image Editor.
  • Accessibility / Testability

    • Added titles and test identifiers to UI elements to improve selectors and tooling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

Adds many new unit and end-to-end tests, enables Vitest coverage, removes two CloudImageEditor focus-visible modules, adds test-targeting data-testid attributes and small UI metadata, and updates multiple tests to pass qualityInsights={false} and improved selectors.

Changes

Cohort / File(s) Summary
Test script & coverage config
package.json, vite.config.js
test:e2e:dev script updated to vitest --coverage --browser.headless=false; vite.config.js test.coverage include/exclude patterns added.
Manager unit tests
src/abstract/managers/__tests__/ModalManager.test.ts, src/abstract/managers/__tests__/SecureUploadsManager.test.ts
Added extensive unit tests for ModalManager and SecureUploadsManager covering lifecycles, events/subscribers, caching/expiration, resolver/error paths, telemetry and debug prints.
Utility & editor unit tests
src/utils/get-top-level-origin.test.ts, src/blocks/CloudImageEditor/src/crop-utils.test.ts
Added unit tests for getTopLevelOrigin and comprehensive crop-utils geometry/SVG logic.
CloudImageEditor removals
src/blocks/CloudImageEditor/src/lib/FocusVisible.ts, src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts
Deleted FocusVisible and applyFocusVisiblePolyfill modules (removed exported APIs and polyfill logic).
CloudImageEditor UI metadata
src/blocks/CloudImageEditor/src/EditorToolbar.ts
Added title-prop attributes to bottom toolbar buttons (cancel, apply) — metadata only.
Test IDs for UI elements
src/blocks/FileItem/FileItem.ts, src/blocks/CameraSource/CameraSource.ts
Added data-testid="edit" to FileItem edit button and multiple data-testid attributes in CameraSource for test hooks.
Camera mode tests
src/blocks/CameraSource/__tests__/calcCameraModes.test.ts
Added unit tests for calcCameraModes covering various cameraModes inputs and expected flags.
loadFileUploaderFrom tests
src/abstract/__tests__/loadFileUploaderFrom.test.ts
Added tests for script loading, UC global handling, defineComponents invocation, success/error paths and non-browser behavior.
E2E tests added
tests/file-uploader-minimal.e2e.test.tsx, tests/file-uploader-inline.e2e.test.tsx, tests/file-uploader-regular.e2e.test.tsx, tests/cloud-image-editor.e2e.test.tsx, tests/adaptive-image.e2e.test.tsx
New end-to-end suites validating uploader flows, camera flows, Cloud Image Editor interactions, and adaptive image placeholder.
E2E tests updates (uc-config & selectors)
tests/api.e2e.test.tsx, tests/config.e2e.test.tsx, tests/file-uploader-regular.e2e.test.tsx, tests/validation.e2e.test.tsx
Tests updated to render uc-config with qualityInsights={false}; tests/validation updated some selectors to role-based queries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus areas requiring extra attention:
    • src/abstract/managers/__tests__/ModalManager.test.ts — many scenarios, subscriber/telemetry assertions.
    • src/abstract/managers/__tests__/SecureUploadsManager.test.ts — fake timers, expiration thresholds, resolver error handling.
    • Confirm removed CloudImageEditor modules (FocusVisible / applyFocusVisiblePolyfill) are not imported or referenced elsewhere.
    • Verify vite.config.js coverage include/exclude patterns align with CI expectations.

Possibly related PRs

Suggested reviewers

  • nd0ut
  • malgojaviro

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description consists entirely of empty template placeholders with no concrete information about the changes, objectives, or rationale for the additions. Provide a meaningful description of the changes, summarize the test additions (managers, components, e2e tests), and explain the coverage goals. Complete at least the description section with actual content.
Title check ❓ Inconclusive The title '[WIP] test: added tests for coverage' is vague and generic. While it mentions tests and coverage, it does not clearly describe the specific changes or main improvements from the developer's perspective. Replace with a more specific title that summarizes the main change, such as 'test: add comprehensive unit and e2e tests for ModalManager, SecureUploadsManager, and UI components' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/coverage-80

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Comment @coderabbitai help to get the list of available commands and usage tips.

import { beforeAll, beforeEach, describe, expect, it, test } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import renderer.

Copilot Autofix

AI 3 days ago

To fix the unused import error, remove the import declaration for renderer from ./utils/test-renderer on line 6. This change should be made only at line 6 of tests/file-uploader-minimal.e2e.test.tsx. No other code or imports need editing. This will ensure that the codebase is cleaner, avoids confusion, and any initialization side effects (if needed) should be handled elsewhere, explicitly, if required.

Suggested changeset 1
tests/file-uploader-minimal.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/file-uploader-minimal.e2e.test.tsx b/tests/file-uploader-minimal.e2e.test.tsx
--- a/tests/file-uploader-minimal.e2e.test.tsx
+++ b/tests/file-uploader-minimal.e2e.test.tsx
@@ -3,7 +3,6 @@
 import '../types/jsx';
 import fi from '@/locales/file-uploader/fi';
 // biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
 
 beforeAll(async () => {
   // biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
EOF
@@ -3,7 +3,6 @@
import '../types/jsx';
import fi from '@/locales/file-uploader/fi';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

beforeAll(async () => {
// biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

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

🧹 Nitpick comments (3)
src/utils/get-top-level-origin.test.ts (1)

4-9: Consider testing edge cases for iframe scenarios.

The test validates the basic case but doesn't verify the "top-level" behavior in iframe contexts, which appears to be the function's primary purpose. Consider adding tests that verify behavior when the code is running in an iframe versus the top-level window.

tests/file-uploader-minimal.e2e.test.tsx (2)

31-35: Use more specific assertion.

toBeDefined() only checks if the element exists but doesn't verify visibility or usability. Consider using toBeInTheDocument() or a similar matcher that better reflects the test intention.

Apply this diff:

     it('should open file dialog on click', async () => {
       await page.getByText('Choose file', { exact: true }).click();
       const startFrom = page.getByTestId('uc-start-from');
-      await expect(startFrom).toBeDefined();
+      await expect.element(startFrom).toBeInTheDocument();
     });

37-46: Consider more realistic drag-and-drop test data.

The test drags the "Powered by Uploadcare" copyright text onto the uploader, which seems like a test workaround rather than realistic user behavior. Consider using a dedicated test element or file-like data structure for more meaningful validation.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 85ba42f and e008ae3.

📒 Files selected for processing (6)
  • package.json (1 hunks)
  • src/abstract/managers/__tests__/ModalManager.test.ts (1 hunks)
  • src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1 hunks)
  • src/utils/get-top-level-origin.test.ts (1 hunks)
  • tests/file-uploader-minimal.e2e.test.tsx (1 hunks)
  • vite.config.js (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
tests/file-uploader-minimal.e2e.test.tsx

[notice] 1-1: Unused variable, import, function or class
Unused import commands.


[notice] 2-2: Unused variable, import, function or class
Unused import test.


[notice] 5-5: Unused variable, import, function or class
Unused import renderer.

⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (4)
package.json (1)

85-85: LGTM!

The addition of --coverage to the e2e dev script aligns with the coverage configuration changes in vite.config.js and enables coverage reporting during development testing.

vite.config.js (1)

20-31: LGTM!

The coverage configuration properly excludes test files and sets reasonable thresholds. The exclude patterns appropriately filter out tests, config files, and locales from coverage calculations, while the thresholds (80-85%) align with the PR's coverage improvement goals.

src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1)

1-369: LGTM!

Comprehensive test suite with excellent coverage of edge cases, error handling, caching behavior, and time-sensitive expiration logic. The use of fake timers, proper mocking, and thorough assertions demonstrates high-quality test engineering.

src/abstract/managers/__tests__/ModalManager.test.ts (1)

1-474: LGTM!

Excellent test suite with comprehensive coverage of modal lifecycle, event system, error handling, and edge cases. The tests are well-structured with proper mocking and clear assertions that validate both happy paths and error scenarios.

@@ -0,0 +1,48 @@
import { commands, page, userEvent } from '@vitest/browser/context';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused import.

The commands import is unused according to static analysis.

Apply this diff:

-import { commands, page, userEvent } from '@vitest/browser/context';
+import { page, userEvent } from '@vitest/browser/context';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { commands, page, userEvent } from '@vitest/browser/context';
import { page, userEvent } from '@vitest/browser/context';
🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 1-1: Unused variable, import, function or class
Unused import commands.

🤖 Prompt for AI Agents
In tests/file-uploader-minimal.e2e.test.tsx around line 1, the import includes
an unused identifier `commands`; remove it from the import list so only the used
symbols (page, userEvent) are imported to satisfy static analysis and avoid lint
errors.

import { beforeAll, beforeEach, describe, expect, it, test } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused import.

The renderer import is unused according to static analysis.

Apply this diff:

-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 5-5: Unused variable, import, function or class
Unused import renderer.

🤖 Prompt for AI Agents
In tests/file-uploader-minimal.e2e.test.tsx around line 5, the import "renderer"
is unused; remove the line "import { renderer } from './utils/test-renderer';"
from the file (or if other tests need it, replace with a named import that is
used), then save the file and run the linter/tests to verify no unused-import
errors remain.

import { commands, page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
import fi from '@/locales/file-uploader/fi';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import fi.

Copilot Autofix

AI 3 days ago

The best way to fix this problem is to remove the unused import statement for fi on line 4 in tests/file-uploader-minimal.e2e.test.tsx. Only imports that are used elsewhere in this file (or intentionally included for side-effects, with a clear comment) should remain. Deleting this line will not affect any existing functionality, as there are no usages or references to this identifier. There are no follow-up changes or new dependencies required.


Suggested changeset 1
tests/file-uploader-minimal.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/file-uploader-minimal.e2e.test.tsx b/tests/file-uploader-minimal.e2e.test.tsx
--- a/tests/file-uploader-minimal.e2e.test.tsx
+++ b/tests/file-uploader-minimal.e2e.test.tsx
@@ -1,9 +1,6 @@
 import { commands, page, userEvent } from '@vitest/browser/context';
 import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
-import fi from '@/locales/file-uploader/fi';
-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
 
 beforeAll(async () => {
   // biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
EOF
@@ -1,9 +1,6 @@
import { commands, page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
import fi from '@/locales/file-uploader/fi';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

beforeAll(async () => {
// biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

@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

♻️ Duplicate comments (1)
tests/file-uploader-minimal.e2e.test.tsx (1)

5-6: Remove unused import.

The renderer import is unused despite the biome-ignore comment claiming it's used in JSX. The comment is misleading since renderer doesn't appear anywhere in the file.

Apply this diff:

-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
🧹 Nitpick comments (2)
src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (1)

1-5: Consider enhancing the deprecation notice with migration guidance.

The @deprecated tag is properly added. For better developer experience, consider specifying:

  • What developers should use instead (e.g., native :focus-visible CSS pseudo-class)
  • The target version for removal
 /**
  * This module is deprecated and will be removed in future versions.
- * @deprecated
- *
- *
+ * @deprecated Use the native `:focus-visible` CSS pseudo-class instead.
+ *
  * Helper function for legacy browsers and iframes which sometimes focus on elements like document, body, and
  * non-interactive SVG.
  */
tests/file-uploader-minimal.e2e.test.tsx (1)

32-36: Use a more robust assertion for visibility testing.

The test name indicates it should verify that a dialog opens (implying visibility), but toBeDefined() only checks existence. Other tests in this file and related test files use toBeVisible() for similar assertions.

Apply this diff:

   it('should open file dialog on click', async () => {
     await page.getByText('Choose file', { exact: true }).click();
     const startFrom = page.getByTestId('uc-start-from');
-    await expect(startFrom).toBeDefined();
+    await expect.element(startFrom).toBeVisible();
   });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 e008ae3 and 05fb135.

📒 Files selected for processing (14)
  • package.json (1 hunks)
  • src/abstract/managers/__tests__/ModalManager.test.ts (1 hunks)
  • src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (1 hunks)
  • src/blocks/Config/initialConfig.ts (1 hunks)
  • src/blocks/FileItem/FileItem.ts (1 hunks)
  • src/utils/get-top-level-origin.test.ts (1 hunks)
  • tests/api.e2e.test.tsx (1 hunks)
  • tests/config.e2e.test.tsx (1 hunks)
  • tests/file-uploader-minimal.e2e.test.tsx (1 hunks)
  • tests/file-uploader-regular.e2e.test.tsx (1 hunks)
  • tests/validation.e2e.test.tsx (1 hunks)
  • vite.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/blocks/FileItem/FileItem.ts
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • vite.config.js
  • src/utils/get-top-level-origin.test.ts
  • src/abstract/managers/tests/ModalManager.test.ts
  • package.json
  • src/abstract/managers/tests/SecureUploadsManager.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
tests/file-uploader-minimal.e2e.test.tsx (1)
tests/utils/commands.ts (1)
  • commands (16-18)
🪛 GitHub Check: CodeQL
tests/file-uploader-minimal.e2e.test.tsx

[notice] 4-4: Unused variable, import, function or class
Unused import fi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

🔇 Additional comments (5)
src/blocks/Config/initialConfig.ts (1)

90-90: LGTM! Environment-aware quality insights configuration.

The change from a hardcoded true to import.meta.env.PROD makes quality insights environment-aware, enabling it only in production builds while keeping it disabled during development and testing. This aligns with the test strategy across the PR where tests explicitly set qualityInsights={false}.

tests/file-uploader-regular.e2e.test.tsx (1)

20-20: LGTM! Consistent test configuration.

Explicitly disabling quality insights in the test environment is appropriate and aligns with the environment-aware configuration change in initialConfig.ts and the consistent pattern across all test files in this PR.

tests/validation.e2e.test.tsx (1)

23-23: LGTM! Consistent test configuration.

The addition of qualityInsights={false} maintains consistency with the test configuration pattern established across all test files in this PR.

tests/api.e2e.test.tsx (1)

21-21: LGTM! Consistent test configuration.

The test configuration aligns with the pattern established across the PR for explicitly disabling quality insights in test environments.

tests/config.e2e.test.tsx (1)

20-20: LGTM! Consistent test configuration.

The test setup maintains the consistent pattern of explicitly disabling quality insights in test environments.

import { commands, page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
import fi from '@/locales/file-uploader/fi';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused import.

The fi locale import is unused in this file.

Apply this diff:

-import fi from '@/locales/file-uploader/fi';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import fi from '@/locales/file-uploader/fi';
🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 4-4: Unused variable, import, function or class
Unused import fi.

🤖 Prompt for AI Agents
In tests/file-uploader-minimal.e2e.test.tsx around line 4, there is an unused
import "import fi from '@/locales/file-uploader/fi';" which should be removed;
delete that import statement to eliminate the unused import and ensure no other
references to `fi` remain in the file.

Comment on lines +38 to +47
it('should drag and drop file', async () => {
const fileUploader = page.getByTestId('uc-file-uploader-minimal');
const copyright = page.getByText('Powered by Uploadcare', { exact: true });

const uploadList = page.getByTestId('uc-upload-list');

await userEvent.dragAndDrop(copyright, fileUploader);

await expect.element(uploadList).toBeVisible();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for drag/drop event handlers in the minimal uploader implementation
rg -nP -A5 -B5 '\b(drag|drop)\b' --type=ts --glob='**/file-uploader-minimal/**' --glob='**/FileItem/**'

Repository: uploadcare/file-uploader

Length of output: 50


🏁 Script executed:

#!/bin/bash
# Find files related to file-uploader-minimal
find . -type f -name '*file-uploader-minimal*' | head -20

Repository: uploadcare/file-uploader

Length of output: 110


🏁 Script executed:

#!/bin/bash
# List the repository structure to understand the layout
ls -la

Repository: uploadcare/file-uploader

Length of output: 2406


🏁 Script executed:

#!/bin/bash
# Search for the test file
find . -type f -name '*file-uploader-minimal.e2e.test.tsx'

Repository: uploadcare/file-uploader

Length of output: 110


🏁 Script executed:

#!/bin/bash
# Read the test file to understand the context
cat -n ./tests/file-uploader-minimal.e2e.test.tsx

Repository: uploadcare/file-uploader

Length of output: 3058


🏁 Script executed:

#!/bin/bash
# Find components in src related to file-uploader-minimal
find ./src -type f \( -name '*minimal*' -o -name '*file-uploader*' \) | head -20

Repository: uploadcare/file-uploader

Length of output: 50


🏁 Script executed:

#!/bin/bash
# Search for drag/drop handlers broadly in the codebase
rg -n 'drag|drop' --type=ts --type=tsx | head -50

Repository: uploadcare/file-uploader

Length of output: 95


🏁 Script executed:

#!/bin/bash
# Search for drag/drop handlers more broadly
rg -n 'drag|drop' --type=ts | head -50

Repository: uploadcare/file-uploader

Length of output: 28595


🏁 Script executed:

#!/bin/bash
# Find the minimal uploader implementation
find ./src -type d -name '*minimal*'
find ./src -path '*file-uploader*' -name '*.ts' -o -path '*file-uploader*' -name '*.tsx'

Repository: uploadcare/file-uploader

Length of output: 426


🏁 Script executed:

#!/bin/bash
# Look at the solutions directory structure
ls -la ./src/solutions/file-uploader/ 2>/dev/null || echo "Directory not found"

Repository: uploadcare/file-uploader

Length of output: 343


🏁 Script executed:

#!/bin/bash
# Read the drop area implementation
cat -n ./src/blocks/DropArea/addDropzone.ts

Repository: uploadcare/file-uploader

Length of output: 5223


🏁 Script executed:

#!/bin/bash
# Read the getDropItems implementation
cat -n ./src/blocks/DropArea/getDropItems.ts

Repository: uploadcare/file-uploader

Length of output: 5238


🏁 Script executed:

#!/bin/bash
# Search for any special handling of drop events or dataTransfer that might accept plain text
rg -n 'text/plain' --type=ts

Repository: uploadcare/file-uploader

Length of output: 995


🏁 Script executed:

#!/bin/bash
# Check if there's any other drag/drop handling besides getDropItems
rg -n 'dataTransfer' --type=ts | head -30

Repository: uploadcare/file-uploader

Length of output: 1198


🏁 Script executed:

#!/bin/bash
# Find where onItems is called and what happens with the items
rg -n 'onItems' --type=ts -A 5 -B 5 | head -80

Repository: uploadcare/file-uploader

Length of output: 2999


Replace test to drag actual file data, not arbitrary text elements.

The test drags a text element ("Powered by Uploadcare") which produces text/plain drag data. However, the uploader's drop handler only processes items where kind === 'file' or kind === 'string' with type matching text/uri-list (see getDropItems.ts lines 101, 135). When neither condition is met, an empty array is returned, causing the onItems handler to exit early without processing any upload (see DropArea.ts line 107-108). The upload list becomes visible for reasons unrelated to drag-and-drop file handling. Drag an actual file or file-like object to properly test file upload via drag-and-drop.

🤖 Prompt for AI Agents
In tests/file-uploader-minimal.e2e.test.tsx around lines 38 to 47, the test
currently drags a text node ("Powered by Uploadcare") which yields text/plain
drag data and is ignored by the uploader; replace that with a real file upload
simulation by creating a File/Blob (e.g., new File([...], 'test.png', { type:
'image/png' })) and use a proper file-oriented API to simulate the drop — either
call the file input's setInputFiles / setFiles helper on the uploader's hidden
input or call userEvent.dragAndDrop with a dataTransfer that includes files:
[file] so the drop produces items with kind === 'file' and the uploader
processes the upload.

Copy link
Contributor

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

♻️ Duplicate comments (2)
tests/file-uploader-minimal.e2e.test.tsx (2)

4-4: Remove unused fi locale import

fi is imported but never used in this test; it just adds noise and triggers static analysis warnings.

You can safely drop it:

-import fi from '@/locales/file-uploader/fi';

38-47: Drag-and-drop test is not actually dropping a file

This test currently drags the “Powered by Uploadcare” text node:

const fileUploader = page.getByTestId('uc-file-uploader-minimal');
const copyright = page.getByText('Powered by Uploadcare', { exact: true });
await userEvent.dragAndDrop(copyright, fileUploader);

That produces text/plain drag data rather than a File / text/uri-list item, so the uploader’s drop logic won’t treat it as a real file drop. The assertion that the upload list becomes visible is therefore not validating the drag‑and‑drop upload path.

Consider rewriting this test to simulate an actual file drop, e.g. by constructing a File and ensuring it’s present in the drop DataTransfer, or by reusing existing helpers that already cover file uploads, so the test truly exercises DnD behavior.

🧹 Nitpick comments (2)
vite.config.js (1)

20-31: Confirm coverage patterns and thresholds match desired scope

The new coverage config is generally solid, but two quick checks might be worthwhile:

  • include: ['src/**/*.ts'] skips any .tsx sources; if you have React/JSX components in src, consider extending this to ['src/**/*.{ts,tsx}'] so they count toward coverage.
  • The thresholds (vars 85, funcs 85, branches 80, lines 85) will make coverage gating stricter; confirm the current suite can consistently meet these numbers to avoid noisy failures.
tests/file-uploader-minimal.e2e.test.tsx (1)

54-56: Verify whether waitFileChooserAndUpload should be awaited

commands.waitFileChooserAndUpload(['./fixtures/test_image.jpeg']); is called without await. If this helper is async (it probably waits for the file chooser and uploads a file), the test may race and click “From device” before the upload wiring is ready.

If waitFileChooserAndUpload returns a Promise, consider:

-      commands.waitFileChooserAndUpload(['./fixtures/test_image.jpeg']);
+      await commands.waitFileChooserAndUpload(['./fixtures/test_image.jpeg']);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 05fb135 and 04aaadf.

📒 Files selected for processing (13)
  • package.json (1 hunks)
  • src/abstract/managers/__tests__/ModalManager.test.ts (1 hunks)
  • src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (1 hunks)
  • src/blocks/FileItem/FileItem.ts (1 hunks)
  • src/utils/get-top-level-origin.test.ts (1 hunks)
  • tests/api.e2e.test.tsx (1 hunks)
  • tests/config.e2e.test.tsx (1 hunks)
  • tests/file-uploader-minimal.e2e.test.tsx (1 hunks)
  • tests/file-uploader-regular.e2e.test.tsx (1 hunks)
  • tests/validation.e2e.test.tsx (1 hunks)
  • vite.config.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • tests/api.e2e.test.tsx
  • package.json
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts
  • src/blocks/FileItem/FileItem.ts
  • tests/file-uploader-regular.e2e.test.tsx
  • src/utils/get-top-level-origin.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
tests/file-uploader-minimal.e2e.test.tsx (1)
tests/utils/commands.ts (1)
  • commands (16-18)
🪛 GitHub Check: CodeQL
tests/file-uploader-minimal.e2e.test.tsx

[notice] 4-4: Unused variable, import, function or class
Unused import fi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (4)
tests/validation.e2e.test.tsx (1)

20-25: qualityInsights flag in test setup looks good

Adding qualityInsights={false} to <uc-config> in the e2e setup is consistent with the rest of the suite and should help keep tests deterministic by disabling quality insights side effects.

tests/config.e2e.test.tsx (1)

18-22: Consistent config for qualityInsights in e2e tests

Adding qualityInsights={false} to <uc-config> here keeps this setup aligned with the other e2e tests and should avoid side effects from quality insights during config tests.

src/abstract/managers/__tests__/ModalManager.test.ts (1)

1-470: Comprehensive ModalManager test coverage

This suite gives very thorough coverage of ModalManager: registration, lifecycle operations, back/closeAll semantics, active state tracking, subscription management (incl. error + telemetry paths), destroy behavior, and ModalEvents constants. The mocks and expectations all look consistent with a robust modal manager contract.

src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1)

1-362: SecureUploadsManager tests thoroughly cover config and resolver flows

The test suite does a good job specifying behavior for static secure config, resolver-based tokens (including caching, expiry thresholds, and precedence), and error/invalid-result handling with appropriate debug/telemetry logging. Timer usage and console spies are correctly set up and cleaned up.

@@ -0,0 +1,76 @@
import { page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import vi.

Copilot Autofix

AI 1 day ago

To fix this issue, simply remove vi from the destructured import statement on line 2 in tests/cloud-image-editor.e2e.test.tsx, so that only the required imports remain. No other changes are required because the rest of the code does not reference vi.


Suggested changeset 1
tests/cloud-image-editor.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/cloud-image-editor.e2e.test.tsx b/tests/cloud-image-editor.e2e.test.tsx
--- a/tests/cloud-image-editor.e2e.test.tsx
+++ b/tests/cloud-image-editor.e2e.test.tsx
@@ -1,5 +1,5 @@
 import { page, userEvent } from '@vitest/browser/context';
-import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
 
 // biome-ignore lint/correctness/noUnusedImports: Used in JSX
EOF
@@ -1,5 +1,5 @@
import { page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';

// biome-ignore lint/correctness/noUnusedImports: Used in JSX
Copilot is powered by AI and may make mistakes. Always verify output.
import '../types/jsx';

// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import renderer.

Copilot Autofix

AI 1 day ago

The fix is to remove the unused import of renderer from './utils/test-renderer' on line 6 in tests/cloud-image-editor.e2e.test.tsx. The comment on line 5 can also be removed as it pertains only to that import. This change will not affect any existing functionality, as renderer is not used elsewhere in the shown code.


Suggested changeset 1
tests/cloud-image-editor.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/cloud-image-editor.e2e.test.tsx b/tests/cloud-image-editor.e2e.test.tsx
--- a/tests/cloud-image-editor.e2e.test.tsx
+++ b/tests/cloud-image-editor.e2e.test.tsx
@@ -2,8 +2,6 @@
 import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
 import '../types/jsx';
 
-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
 
 beforeAll(async () => {
   // biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
EOF
@@ -2,8 +2,6 @@
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import '../types/jsx';

// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

beforeAll(async () => {
// biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

@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

♻️ Duplicate comments (2)
tests/file-uploader-minimal.e2e.test.tsx (2)

4-4: Remove unused fi locale import (or wire it into the config).

fi isn’t used anywhere in this test. Either remove the import, or, if you intend to test Finnish localization, pass it into <uc-config> (e.g., locale={fi}) so it’s actually exercised.

-import fi from '@/locales/file-uploader/fi';

38-47: Drag-and-drop test isn’t dropping a real file.

This test drags the “Powered by Uploadcare” text node, which yields plain text drag data. The drop pipeline for the uploader only processes real files or supported URL types, so this doesn’t actually verify file DnD behavior—it only asserts that the upload list becomes visible for other reasons.

Consider changing the test to simulate a real file drop (e.g., via a File object in the drag data or by using your existing waitFileChooserAndUpload / file chooser helpers) so it exercises the same path actual users hit.

🧹 Nitpick comments (3)
vite.config.js (1)

20-31: Confirm whether coverage should also include TSX/JS sources

test.coverage.include is limited to src/**/*.ts, so any logic in .tsx or .js under src won’t count toward the configured thresholds. If you also want UI/JS modules included, consider broadening the pattern, for example:

-          include: ['src/**/*.ts'],
+          include: ['src/**/*.{ts,tsx}'],

(and adjust exclude similarly if needed).

src/blocks/FileItem/FileItem.ts (1)

476-482: Consider making the edit button test id more specific

data-testid="edit" will be duplicated across multiple FileItem instances; that’s fine functionally but can make selectors ambiguous in e2e tests. If you start relying heavily on this, consider a more specific id (e.g. file-item-edit) or using scoped getByTestId/getAllByTestId in tests.

tests/cloud-image-editor.e2e.test.tsx (1)

35-39: Add an assertion to the “should select tunings tab” test.

This test only clicks the control and never asserts resulting state, so it currently just verifies that the click doesn’t throw. Consider asserting the expected outcome (e.g., active tab, aria-selected, or visible tuning panel) to make the test meaningful.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 04aaadf and dad1f1d.

📒 Files selected for processing (16)
  • package.json (1 hunks)
  • src/abstract/managers/__tests__/ModalManager.test.ts (1 hunks)
  • src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/EditorToolbar.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/crop-utils.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (1 hunks)
  • src/blocks/FileItem/FileItem.ts (1 hunks)
  • src/utils/get-top-level-origin.test.ts (1 hunks)
  • tests/api.e2e.test.tsx (1 hunks)
  • tests/cloud-image-editor.e2e.test.tsx (1 hunks)
  • tests/config.e2e.test.tsx (1 hunks)
  • tests/file-uploader-minimal.e2e.test.tsx (1 hunks)
  • tests/file-uploader-regular.e2e.test.tsx (1 hunks)
  • tests/validation.e2e.test.tsx (1 hunks)
  • vite.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/api.e2e.test.tsx
  • package.json
  • src/utils/get-top-level-origin.test.ts
  • src/abstract/managers/tests/ModalManager.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
tests/file-uploader-minimal.e2e.test.tsx (1)
tests/utils/commands.ts (1)
  • commands (16-18)
🪛 GitHub Check: CodeQL
tests/cloud-image-editor.e2e.test.tsx

[notice] 2-2: Unused variable, import, function or class
Unused import vi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

tests/file-uploader-minimal.e2e.test.tsx

[notice] 4-4: Unused variable, import, function or class
Unused import fi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (6)
src/abstract/managers/__tests__/SecureUploadsManager.test.ts (1)

1-362: SecureUploadsManager test suite looks comprehensive and well-structured

The suite exercises static config, resolver flows (including caching, expiry, threshold behavior), error handling, and debug/telemetry side effects with good use of fake timers and spies; I don’t see gaps or flakiness risks in the current scenarios.

tests/validation.e2e.test.tsx (1)

18-27: Disabling qualityInsights in test config is a sensible default

Passing qualityInsights={false} in the shared uc-config setup should help keep these validation e2e tests deterministic and free from any extra quality/insights side-effects without impacting the scenarios under test.

src/blocks/CloudImageEditor/src/EditorToolbar.ts (1)

504-505: Slider controls now have consistent title metadata

Adding title-prop:cancel / title-prop:apply to the slider buttons brings them in line with the main toolbar buttons’ a11y/tooltip configuration without changing behavior.

tests/file-uploader-regular.e2e.test.tsx (1)

15-23: uc-config setup with qualityInsights={false} is consistent with other e2e tests

Updating this test’s uc-config to include qualityInsights={false} aligns it with the rest of the suite and should avoid any incidental insight-related behavior during runs.

tests/config.e2e.test.tsx (1)

15-24: Explicitly disabling qualityInsights keeps config tests focused

Adding qualityInsights={false} to the shared uc-config here helps ensure these tests exercise only configuration behavior (e.g., cdnCname) without being affected by quality insights logic.

src/blocks/CloudImageEditor/src/crop-utils.test.ts (1)

1-719: crop-utils tests provide strong coverage of geometry and SVG helpers

This suite exercises the key code paths (SVG node helpers, cursor mapping, move/resize with constraints and aspect ratios, centered crop computation, rounding/clamping) with good edge-case coverage; the few exact-value expectations (e.g., specific 1:1 crop frame) are reasonable but will need revisiting if the underlying math is ever adjusted.

Comment on lines 1 to 4
/**
* This module is deprecated and will be removed in future versions.
* @deprecated
*/
Copy link
Contributor

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:

cat -n "src/blocks/CloudImageEditor/src/lib/FocusVisible.ts"

Repository: uploadcare/file-uploader

Length of output: 1431


🏁 Script executed:

rg -n "FocusVisible" --type=ts --type=js -B2 -A2

Repository: uploadcare/file-uploader

Length of output: 7525


🏁 Script executed:

cat -n "src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts" 2>/dev/null || echo "File not found"

Repository: uploadcare/file-uploader

Length of output: 7472


🏁 Script executed:

fd "FocusVisible" --type=f

Repository: uploadcare/file-uploader

Length of output: 184


Deprecation notice needs migration guidance and accurate context.

The deprecation header marks this module for removal but doesn't provide:

  • A reason for deprecation
  • An alternative or migration path
  • A target version for removal

Before enhancing this notice, clarify the actual deprecation rationale. The module's purpose extends beyond providing a :focus-visible selector—it applies custom outline styling based on focus visibility state, which requires more nuanced migration guidance than simply using native CSS :focus-visible. Document what developers should use instead and include a target removal version.

@@ -0,0 +1,76 @@
import { page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused vi import.

vi is not used anywhere in this file, and there is no ignore directive for it. Dropping it will satisfy static analysis and keep imports clean.

-import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 2-2: Unused variable, import, function or class
Unused import vi.

🤖 Prompt for AI Agents
In tests/cloud-image-editor.e2e.test.tsx around line 2, the imported symbol `vi`
is unused; remove `vi` from the import list (i.e., import only beforeAll,
beforeEach, describe, expect, it from 'vitest') to satisfy static analysis and
keep imports clean.

@@ -0,0 +1,68 @@
import { commands, page, userEvent } from '@vitest/browser/context';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import commands.

Copilot Autofix

AI 1 day ago

The best way to fix the problem is to remove the unused import commands from the import statement on line 1 in tests/file-uploader-inline.e2e.test.tsx. This change affects only the import statement itself — the rest of the code uses page and userEvent, so those should remain. No other changes are needed in the file, and no additional imports, methods, or definitions are required.


Suggested changeset 1
tests/file-uploader-inline.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/file-uploader-inline.e2e.test.tsx b/tests/file-uploader-inline.e2e.test.tsx
--- a/tests/file-uploader-inline.e2e.test.tsx
+++ b/tests/file-uploader-inline.e2e.test.tsx
@@ -1,4 +1,4 @@
-import { commands, page, userEvent } from '@vitest/browser/context';
+import { page, userEvent } from '@vitest/browser/context';
 import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
 import { delay } from '@/utils/delay';
EOF
@@ -1,4 +1,4 @@
import { commands, page, userEvent } from '@vitest/browser/context';
import { page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
import { delay } from '@/utils/delay';
Copilot is powered by AI and may make mistakes. Always verify output.
import '../types/jsx';
import { delay } from '@/utils/delay';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import renderer.

Copilot Autofix

AI 1 day ago

To fix this problem, you should remove the unused import statement from line 6 of tests/file-uploader-inline.e2e.test.tsx. Specifically, delete the line import { renderer } from './utils/test-renderer';. No other changes are required in the file, and no imports or code edits elsewhere are necessary, as the identifier is unused.

Suggested changeset 1
tests/file-uploader-inline.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/file-uploader-inline.e2e.test.tsx b/tests/file-uploader-inline.e2e.test.tsx
--- a/tests/file-uploader-inline.e2e.test.tsx
+++ b/tests/file-uploader-inline.e2e.test.tsx
@@ -3,7 +3,6 @@
 import '../types/jsx';
 import { delay } from '@/utils/delay';
 // biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
 
 beforeAll(async () => {
   // biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
EOF
@@ -3,7 +3,6 @@
import '../types/jsx';
import { delay } from '@/utils/delay';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

beforeAll(async () => {
// biome-ignore lint/suspicious/noTsIgnore: Ignoring TypeScript error for CSS import
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

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

♻️ Duplicate comments (2)
tests/cloud-image-editor.e2e.test.tsx (2)

2-2: Remove unused vi import.

The vi import is not used anywhere in this file.

Apply this diff:

-import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { beforeAll, beforeEach, describe, expect, it } from 'vitest';

5-6: Remove unused renderer import despite biome-ignore comment.

The biome-ignore comment claims renderer is used in JSX, but the code only uses native JSX elements (uc-cloud-image-editor and uc-config), not the renderer utility. This import should be removed along with its ignore comment.

Apply this diff:

-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
-
🧹 Nitpick comments (3)
src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (1)

43-45: Align mixed-values test config shape with other cases

In the “mixed valid and invalid values” case you construct a minimal config via a type assertion:

const cfg = { cameraModes: 'video,unknown,photo' } as ConfigType;

This works today, but it’s slightly brittle if calcCameraModes ever starts depending on additional fields from ConfigType. It would also be more consistent with the other tests to base it on initialConfig.

Consider:

-  it('should handle mixed valid and invalid values', () => {
-    const cfg = { cameraModes: 'video,unknown,photo' } as ConfigType;
+  it('should handle mixed valid and invalid values', () => {
+    const cfg = { ...initialConfig, cameraModes: 'video,unknown,photo' } as ConfigType;

This keeps the full config shape while still clearly focusing the test on the cameraModes field.

src/blocks/CloudImageEditor/src/crop-utils.test.ts (1)

68-152: Consider verifying actual path coordinates, not just structure.

The cornerPath and sidePath tests only check that the result contains 'M' and 'L' commands and that the center has length 2. They don't verify that the paths are positioned correctly or that center coordinates are accurate. These tests would pass even if the paths were completely wrong.

Consider adding assertions like:

 it('should generate path for northwest corner', () => {
   const result = cornerPath(rect, 'nw', 1);
 
   expect(result.d).toContain('M');
   expect(result.d).toContain('L');
   expect(result.center).toHaveLength(2);
+  // Verify center is at the northwest corner
+  expect(result.center[0]).toBe(rect.x);
+  expect(result.center[1]).toBe(rect.y);
 });
tests/file-uploader-inline.e2e.test.tsx (1)

34-34: Use a more robust assertion.

toBeDefined() only verifies the selector returned a value, not that the element is actually visible or in the DOM. Consider using toBeVisible() or toBeInTheDocument() for stronger validation.

Apply this diff:

-    await expect(urlSource).toBeDefined();
+    await expect(urlSource).toBeVisible();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 dad1f1d and 632f528.

📒 Files selected for processing (10)
  • src/abstract/__tests__/loadFileUploaderFrom.test.ts (1 hunks)
  • src/blocks/CameraSource/CameraSource.ts (5 hunks)
  • src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/EditorToolbar.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/crop-utils.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts (0 hunks)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (0 hunks)
  • tests/cloud-image-editor.e2e.test.tsx (1 hunks)
  • tests/file-uploader-inline.e2e.test.tsx (1 hunks)
  • tests/validation.e2e.test.tsx (8 hunks)
💤 Files with no reviewable changes (2)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/validation.e2e.test.tsx
  • src/blocks/CloudImageEditor/src/EditorToolbar.ts
🧰 Additional context used
🪛 GitHub Check: CodeQL
tests/file-uploader-inline.e2e.test.tsx

[notice] 1-1: Unused variable, import, function or class
Unused import commands.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

tests/cloud-image-editor.e2e.test.tsx

[notice] 2-2: Unused variable, import, function or class
Unused import vi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (14)
src/blocks/CameraSource/CameraSource.ts (1)

1031-1095: Template data-testid additions look good and non-invasive

The added data-testid attributes on camera tabs, recording timer, retake, microphone toggle, and audio select are purely additive and don’t interfere with existing set bindings or refs. They provide stable hooks for tests and are appropriately scoped to the relevant controls.

src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (1)

6-51: Good coverage of cameraModes behavior space

The suite cleanly exercises default, single-mode, empty, and mixed cameraModes configurations and asserts both isVideoRecordingEnabled and isPhotoEnabled, which should give solid regression coverage around calcCameraModes.

src/blocks/CloudImageEditor/src/crop-utils.test.ts (6)

22-66: LGTM!

The tests for setSvgNodeAttrs and createSvgNode provide adequate coverage for these basic SVG utility functions, verifying attribute setting for both strings and numbers.


154-190: LGTM!

Comprehensive coverage of all cursor types for different resize directions.


192-232: LGTM!

Good coverage of rectangle movement with proper boundary constraint testing in all directions.


234-272: LGTM!

Thorough testing of rectangle constraint logic with all boundary cases covered.


274-441: Excellent test coverage for resize functionality!

The resizeRect test suite is very thorough, covering all resize directions, aspect ratio preservation, boundary constraints, and minimum size enforcement. This comprehensive approach ensures the resize logic is well-tested.


443-718: LGTM!

The remaining test suites (rectContainsPoint, isRectInsideRect, isRectMatchesAspectRatio, rotateSize, calculateMaxCenteredCropFrame, roundRect, and clamp) all have comprehensive coverage with proper edge case and boundary condition testing.

tests/cloud-image-editor.e2e.test.tsx (1)

8-76: LGTM!

The e2e test suite is well-structured with proper setup in beforeAll and beforeEach, and the test cases effectively cover key editor functionality: rendering, tab switching, crop preset selection, and brightness operations. Good use of semantic selectors with getByRole and getByTestId.

src/abstract/__tests__/loadFileUploaderFrom.test.ts (1)

24-25: Top-level await in describe blocks is supported in Vitest 3.2.4.

This pattern works correctly in the current Vitest version (^3.2.4). However, consider using beforeAll or beforeEach instead for a more conventional test structure that better aligns with standard testing patterns.

tests/file-uploader-inline.e2e.test.tsx (4)

8-14: LGTM!

The beforeAll setup correctly imports the required CSS and defines the components for the inline uploader tests.


16-24: LGTM!

The beforeEach setup correctly creates a unique context for each test and properly configures the inline uploader with test mode enabled.


27-29: LGTM!

The rendering verification test correctly asserts the presence and visibility of the expected start area text.


54-55: The delay duration is appropriate for recording simulation.

The 2-second delay is reasonable for testing the microphone recording functionality in an e2e test, even though it adds to test execution time.

Comment on lines +15 to +19
afterEach(() => {
const scripts = document.querySelectorAll('script[src]');
for (const script of scripts) {
script.remove();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Overly broad script cleanup risks test pollution.

The cleanup removes ALL script elements with a src attribute, not just those created by these tests. This could inadvertently remove scripts injected by the test framework, other concurrent tests, or test infrastructure.

Apply this diff to target only the scripts created by these tests:

 afterEach(() => {
-  const scripts = document.querySelectorAll('script[src]');
+  const scripts = document.querySelectorAll(`script[src="${testUrl}"]`);
   for (const script of scripts) {
     script.remove();
   }
 
   delete (window as any)[UC_WINDOW_KEY];
 });

However, this requires testUrl to be accessible in the afterEach scope. Consider moving the import to module level or tracking created scripts explicitly:

let createdScripts: HTMLScriptElement[] = [];

afterEach(() => {
  createdScripts.forEach(script => script.remove());
  createdScripts = [];
  delete (window as any)[UC_WINDOW_KEY];
});

// In each test, after creating a script:
const script = document.querySelector(`script[src="${testUrl}"]`) as HTMLScriptElement;
if (script) createdScripts.push(script);
🤖 Prompt for AI Agents
In src/abstract/__tests__/loadFileUploaderFrom.test.ts around lines 15-19, the
afterEach currently removes all script[src] tags which can delete unrelated
test/framework scripts; instead, track and remove only scripts this test creates
(e.g., push created HTMLScriptElement instances into a module-scoped
createdScripts array and in afterEach iterate over createdScripts to remove them
and reset the array), and ensure UC_WINDOW_KEY cleanup is done there; if testUrl
is needed in afterEach, make it module-scoped (move its import/definition to
top-level) or otherwise capture the created script references at creation time
so afterEach can remove only those specific elements.

Comment on lines +125 to +132
it('should reject on script error', async () => {
const loadPromise = loadFileUploaderFrom(testUrl);

const script = document.querySelector(`script[src="${testUrl}"]`) as HTMLScriptElement;
script.onerror?.(new Event('error'));

await expect(loadPromise).rejects.toBeUndefined();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Error rejection with undefined is poor practice.

The test expects the promise to reject with undefined, which provides no error information for debugging. Errors should typically reject with an Error object or descriptive message.

While this test accurately reflects the current implementation, consider updating the implementation to reject with a meaningful error:

// In loadFileUploaderFrom implementation:
script.onerror = () => {
  reject(new Error(`Failed to load file uploader from ${url}`));
};

Then update the test:

-await expect(loadPromise).rejects.toBeUndefined();
+await expect(loadPromise).rejects.toThrow('Failed to load file uploader');
🤖 Prompt for AI Agents
In src/abstract/__tests__/loadFileUploaderFrom.test.ts around lines 125 to 132,
the test currently expects the load promise to reject with undefined; change the
implementation of loadFileUploaderFrom so script.onerror rejects with a
descriptive Error (e.g. new Error(`Failed to load file uploader from ${url}`)),
and update this test to assert the promise rejects with that Error or at least
with an instance of Error (e.g. use toRejectWith or toThrow matching the message
or Error constructor) instead of toBeUndefined.

Comment on lines +135 to +148
describe('non-browser environment', () => {
it('should resolve with null when document is not an object', async () => {
const originalDocument = global.document;

// @ts-expect-error - intentionally setting to non-object for test
global.document = undefined;

const result = await loadFileUploaderFrom(testUrl);

expect(result).toBeNull();

global.document = originalDocument;
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Non-browser environment test may be fragile.

Manipulating global.document may not work correctly in all test environments. In browser-like environments (jsdom, happy-dom) or real browsers, document may not be accessible via global and could be a non-configurable property.

Consider using a more robust approach with proper environment detection:

it('should resolve with null when document is not an object', async () => {
  // Create a minimal test module that can be imported with document stubbed
  // Or mock the document check at a higher level
  
  // Alternative: Test the actual condition from loadFileUploaderFrom
  const originalTypeOf = global.Object.prototype.toString;
  vi.spyOn(Object.prototype, 'toString').mockReturnValueOnce('[object Undefined]');
  
  // ... test logic
  
  vi.restoreAllMocks();
});

Alternatively, verify the test actually executes correctly by adding an assertion that the mock succeeded:

  // @ts-expect-error - intentionally setting to non-object for test
  global.document = undefined;
+ expect(typeof document).not.toBe('object'); // Verify mock worked
  
  const result = await loadFileUploaderFrom(testUrl);
🤖 Prompt for AI Agents
In src/abstract/__tests__/loadFileUploaderFrom.test.ts around lines 135 to 148,
the test mutates global.document which is fragile across environments
(jsdom/happy-dom/real browsers) because document may not be configurable;
instead, change the test to simulate the "document is not an object" condition
without redefining global.document — for example, spy/mocking the runtime check
used in loadFileUploaderFrom (mock Object.prototype.toString or the specific
helper that checks for document) to return an undefined-like result for the
duration of the test, assert the mock was applied, run loadFileUploaderFrom
expecting null, then restore all mocks; alternatively create a minimal test
module import where document is stubbed and import that module to exercise the
condition.

@@ -0,0 +1,68 @@
import { commands, page, userEvent } from '@vitest/browser/context';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused imports.

The imports commands and renderer are not used in this file.

Apply this diff to remove the unused imports:

-import { commands, page, userEvent } from '@vitest/browser/context';
+import { page, userEvent } from '@vitest/browser/context';
 import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
 import { delay } from '@/utils/delay';
-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';

Also applies to: 6-6

🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 1-1: Unused variable, import, function or class
Unused import commands.

🤖 Prompt for AI Agents
In tests/file-uploader-inline.e2e.test.tsx around lines 1 and 6, remove the
unused imports `commands` and `renderer` from the import statements so only the
used identifiers (e.g., `page`, `userEvent`) remain; update the import lines
accordingly to eliminate the unused bindings and any trailing commas.

const recordingTimer = cameraSource.getByTestId('uc-camera-source--recording-timer');
await expect(recordingTimer).toBeVisible();

const accptButton = cameraSource.getByTestId('uc-camera-source--accept');
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in variable name.

The variable name accptButton should be acceptButton.

Apply this diff:

-    const accptButton = cameraSource.getByTestId('uc-camera-source--accept');
+    const acceptButton = cameraSource.getByTestId('uc-camera-source--accept');

And update the usage:

-    await userEvent.click(accptButton);
+    await userEvent.click(acceptButton);

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In tests/file-uploader-inline.e2e.test.tsx around line 62, the variable name
`accptButton` is misspelled; rename it to `acceptButton` and update all usages
accordingly (e.g., any subsequent references or assertions that use
`accptButton` should be changed to `acceptButton`) so the test compiles and
reads correctly.

@@ -0,0 +1,23 @@
import { commands, page, userEvent } from '@vitest/browser/context';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused imports commands, userEvent.

Copilot Autofix

AI 1 day ago

To fix this issue, simply remove commands and userEvent from the import statement on line 1 in tests/adaptive-image.e2e.test.tsx. Retain the import of page, as it is actively used. No further changes are necessary, as there are no references to the other two symbols elsewhere in the file.

Suggested changeset 1
tests/adaptive-image.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/adaptive-image.e2e.test.tsx b/tests/adaptive-image.e2e.test.tsx
--- a/tests/adaptive-image.e2e.test.tsx
+++ b/tests/adaptive-image.e2e.test.tsx
@@ -1,4 +1,4 @@
-import { commands, page, userEvent } from '@vitest/browser/context';
+import { page } from '@vitest/browser/context';
 import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
 // biome-ignore lint/correctness/noUnusedImports: Used in JSX
EOF
@@ -1,4 +1,4 @@
import { commands, page, userEvent } from '@vitest/browser/context';
import { page } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
Copilot is powered by AI and may make mistakes. Always verify output.
@@ -0,0 +1,23 @@
import { commands, page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import expect.

Copilot Autofix

AI 1 day ago

To fix the problem, the unused named import expect should be removed from the import statement on line 2 in tests/adaptive-image.e2e.test.tsx. Only import the variables/functions actually used in the file (beforeAll, beforeEach, describe, it). The file is fine otherwise, since removing unused imports does not change the functionality of the code.


Suggested changeset 1
tests/adaptive-image.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/adaptive-image.e2e.test.tsx b/tests/adaptive-image.e2e.test.tsx
--- a/tests/adaptive-image.e2e.test.tsx
+++ b/tests/adaptive-image.e2e.test.tsx
@@ -1,5 +1,5 @@
 import { commands, page, userEvent } from '@vitest/browser/context';
-import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
+import { beforeAll, beforeEach, describe, it } from 'vitest';
 import '../types/jsx';
 // biome-ignore lint/correctness/noUnusedImports: Used in JSX
 import { renderer } from './utils/test-renderer';
EOF
@@ -1,5 +1,5 @@
import { commands, page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import { beforeAll, beforeEach, describe, it } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';
Copilot is powered by AI and may make mistakes. Always verify output.
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import renderer.

Copilot Autofix

AI 1 day ago

To fix the problem, remove the unused import of renderer from './utils/test-renderer' in the file tests/adaptive-image.e2e.test.tsx. This will reduce confusion, improve readability, and eliminate any unnecessary module loading, unless further evidence emerges that it is required for side effects. Remove only the import statement on line 5, and leave the rest of the file intact.


Suggested changeset 1
tests/adaptive-image.e2e.test.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/adaptive-image.e2e.test.tsx b/tests/adaptive-image.e2e.test.tsx
--- a/tests/adaptive-image.e2e.test.tsx
+++ b/tests/adaptive-image.e2e.test.tsx
@@ -2,7 +2,6 @@
 import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
 // biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
 
 beforeAll(async () => {
   await import('@/solutions/adaptive-image/index.js');
EOF
@@ -2,7 +2,6 @@
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

beforeAll(async () => {
await import('@/solutions/adaptive-image/index.js');
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

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

♻️ Duplicate comments (3)
tests/cloud-image-editor.e2e.test.tsx (1)

2-2: Remove unused imports.

The imports vi and renderer are not used in this file.

Apply this diff:

-import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';

-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
-
 beforeAll(async () => {

Also applies to: 6-6

tests/file-uploader-inline.e2e.test.tsx (2)

1-1: Remove unused imports.

The imports commands and renderer are not used in this file.

Apply this diff:

-import { commands, page, userEvent } from '@vitest/browser/context';
+import { page, userEvent } from '@vitest/browser/context';
 import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
 import '../types/jsx';
 import { delay } from '@/utils/delay';
-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';

Also applies to: 6-6


62-63: Fix typo in variable name.

The variable name accptButton should be acceptButton.

Apply this diff:

-    const accptButton = cameraSource.getByTestId('uc-camera-source--accept');
-    await userEvent.click(accptButton);
+    const acceptButton = cameraSource.getByTestId('uc-camera-source--accept');
+    await userEvent.click(acceptButton);
🧹 Nitpick comments (2)
src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (2)

7-14: Avoid coupling the first test to implicit initialConfig defaults

The description says “includes video and photo”, but the test relies on whatever initialConfig currently sets for cameraModes. To make the intent future‑proof and self‑contained, consider setting it explicitly, e.g.:

const cfg = { ...initialConfig, cameraModes: 'video,photo' } as ConfigType;

This avoids accidental breakage if initialConfig.cameraModes changes later.


43-45: Align the mixed-values test config with real-world ConfigType shape

Here you construct { cameraModes: 'video,unknown,photo' } as ConfigType, whereas the other tests start from initialConfig. For realism and to reduce the chance of calcCameraModes later depending on another config field, consider:

const cfg = { ...initialConfig, cameraModes: 'video,unknown,photo' } as ConfigType;

This keeps the test closer to how the function is used in production.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 632f528 and 401928a.

📒 Files selected for processing (11)
  • src/abstract/__tests__/loadFileUploaderFrom.test.ts (1 hunks)
  • src/blocks/CameraSource/CameraSource.ts (5 hunks)
  • src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/EditorToolbar.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/crop-utils.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts (0 hunks)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (0 hunks)
  • tests/adaptive-image.e2e.test.tsx (1 hunks)
  • tests/cloud-image-editor.e2e.test.tsx (1 hunks)
  • tests/file-uploader-inline.e2e.test.tsx (1 hunks)
  • tests/validation.e2e.test.tsx (8 hunks)
💤 Files with no reviewable changes (2)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/abstract/tests/loadFileUploaderFrom.test.ts
  • src/blocks/CloudImageEditor/src/crop-utils.test.ts
  • src/blocks/CloudImageEditor/src/EditorToolbar.ts
  • tests/validation.e2e.test.tsx
🧰 Additional context used
🪛 GitHub Check: CodeQL
tests/adaptive-image.e2e.test.tsx

[notice] 1-1: Unused variable, import, function or class
Unused imports commands, userEvent.


[notice] 2-2: Unused variable, import, function or class
Unused import expect.


[notice] 5-5: Unused variable, import, function or class
Unused import renderer.

tests/file-uploader-inline.e2e.test.tsx

[notice] 1-1: Unused variable, import, function or class
Unused import commands.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

tests/cloud-image-editor.e2e.test.tsx

[notice] 2-2: Unused variable, import, function or class
Unused import vi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (3)
src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (1)

1-51: Good coverage and clear expectations for calcCameraModes

The suite cleanly covers the main modes (video/photo/both/none/mixed) and uses explicit expectations for the two booleans. This should be solid for guarding regressions in calcCameraModes.

src/blocks/CameraSource/CameraSource.ts (2)

1026-1044: LGTM! Well-chosen test IDs for tab navigation.

The data-testid attributes for the photo and video tab buttons are descriptive and follow a consistent naming pattern, making them easy to select in automated tests.


1046-1097: LGTM! Comprehensive test coverage for camera controls.

The added data-testid attributes (recording-timer, retake, toggle-microphone, audio-select) provide solid hooks for testing all key camera interactions. The naming is clear and consistent across all elements.

Comment on lines +1 to +6
import { commands, page, userEvent } from '@vitest/browser/context';
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import '../types/jsx';
// biome-ignore lint/correctness/noUnusedImports: Used in JSX
import { renderer } from './utils/test-renderer';

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused imports.

The imports commands, userEvent, expect, and renderer are not used in this file.

Apply this diff to remove the unused imports:

-import { commands, page, userEvent } from '@vitest/browser/context';
-import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
+import { page } from '@vitest/browser/context';
+import { beforeAll, beforeEach, describe, it } from 'vitest';
 import '../types/jsx';
-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';
🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 1-1: Unused variable, import, function or class
Unused imports commands, userEvent.


[notice] 2-2: Unused variable, import, function or class
Unused import expect.


[notice] 5-5: Unused variable, import, function or class
Unused import renderer.

🤖 Prompt for AI Agents
In tests/adaptive-image.e2e.test.tsx around lines 1 to 6, several imports are
unused: remove `commands` and `userEvent` from the first import, remove `expect`
from the vitest import list (keep `beforeAll`, `beforeEach`, `describe`, `it`),
and delete the unused `import { renderer } from './utils/test-renderer';` line;
ensure the file still imports `page` and `../types/jsx` as needed and run
lint/tests to verify no remaining unused imports.

Comment on lines +20 to +22
it('should be rendered', async () => {
// await expect.element(page.getByTestId('uc-img')).toBeVisible();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Complete the test or remove the placeholder.

The test assertion is commented out, making this test non-functional. Either implement the test properly or remove the placeholder if it's not ready.

Apply this diff to enable the assertion:

   it('should be rendered', async () => {
-    // await expect.element(page.getByTestId('uc-img')).toBeVisible();
+    await expect.element(page.getByTestId('uc-img')).toBeVisible();
   });

Note: You'll need to restore the expect import if you uncomment this assertion.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('should be rendered', async () => {
// await expect.element(page.getByTestId('uc-img')).toBeVisible();
});
it('should be rendered', async () => {
await expect.element(page.getByTestId('uc-img')).toBeVisible();
});
🤖 Prompt for AI Agents
In tests/adaptive-image.e2e.test.tsx around lines 20 to 22, the test contains a
commented-out assertion which makes it a no-op; either restore and enable the
expectation or delete the placeholder test. Uncomment the expect assertion
calling page.getByTestId('uc-img') and toBeVisible(), and if necessary re-add
the expect import from the test runner at the top of the file so the assertion
works; alternatively, remove the entire it(...) block if this test isn't ready.

);
});

describe.skip('Cloud Image Editor', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove .skip to enable the test suite.

The entire test suite is currently skipped with describe.skip, which means none of these tests are running. This defeats the purpose of adding test coverage.

Apply this diff to enable the tests:

-describe.skip('Cloud Image Editor', () => {
+describe('Cloud Image Editor', () => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe.skip('Cloud Image Editor', () => {
describe('Cloud Image Editor', () => {
🤖 Prompt for AI Agents
tests/cloud-image-editor.e2e.test.tsx around line 30: the test suite is disabled
by describe.skip; remove the `.skip` so the suite runs (change
describe.skip('Cloud Image Editor', () => { to describe('Cloud Image Editor', ()
=> {), then run the test runner locally/CI to ensure no failures and fix any
resulting flakes or environment-dependent assertions.

Copy link
Contributor

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

♻️ Duplicate comments (10)
tests/file-uploader-inline.e2e.test.tsx (2)

1-1: Remove unused imports.

The imports commands (line 1) and renderer (line 6) are not used anywhere in the test file.

Also applies to: 6-6


62-63: Fix typo in variable name.

The variable name accptButton should be acceptButton.

tests/adaptive-image.e2e.test.tsx (2)

1-6: Remove unused imports.

The imports commands, userEvent, expect, and renderer are not used in this file. These should be removed to satisfy static analysis.

Apply this diff to remove the unused imports:

-import { commands, page, userEvent } from '@vitest/browser/context';
-import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
+import { page } from '@vitest/browser/context';
+import { beforeAll, beforeEach, describe, it } from 'vitest';
 import '../types/jsx';
-// biome-ignore lint/correctness/noUnusedImports: Used in JSX
-import { renderer } from './utils/test-renderer';

19-23: Complete the test or remove the placeholder.

The test assertion is commented out, making this test non-functional. Either implement the test properly or remove the placeholder if it's not ready.

Apply this diff to enable the assertion:

   it('should be rendered', async () => {
-    // await expect.element(page.getByTestId('uc-img')).toBeVisible();
+    await expect.element(page.getByTestId('uc-img')).toBeVisible();
   });

Note: You'll need to restore the expect import when uncommenting this assertion.

tests/cloud-image-editor.e2e.test.tsx (2)

2-2: Remove unused vi import.

The vi import is not used anywhere in this file. Remove it to satisfy static analysis.

Apply this diff:

-import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { beforeAll, beforeEach, describe, expect, it } from 'vitest';

30-30: Remove .skip to enable the test suite.

The entire test suite is currently skipped with describe.skip, which means none of these tests are running. This defeats the purpose of adding test coverage.

Apply this diff to enable the tests:

-describe.skip('Cloud Image Editor', () => {
+describe('Cloud Image Editor', () => {

After enabling, verify all tests pass locally before pushing.

src/abstract/__tests__/loadFileUploaderFrom.test.ts (4)

135-148: Non‑browser test is fragile due to direct global.document reassignment.

Overwriting global.document can be brittle across environments (jsdom, happy-dom, real browser) and, if the test fails before the final line, may leave document in a bad state for subsequent tests. Prefer simulating the “non-object document” condition via the same check used in loadFileUploaderFrom (e.g., mocking that helper or spying on the relevant property) and/or ensure restoration happens in a try/finally:

-    const originalDocument = global.document;
-    // @ts-expect-error - intentionally setting to non-object for test
-    global.document = undefined;
-
-    const result = await loadFileUploaderFrom(testUrl);
-
-    expect(result).toBeNull();
-
-    global.document = originalDocument;
+    const originalDocument = global.document;
+    try {
+      // @ts-expect-error - intentionally setting to non-object for test
+      global.document = undefined;
+
+      const result = await loadFileUploaderFrom(testUrl);
+      expect(result).toBeNull();
+    } finally {
+      global.document = originalDocument;
+    }

This reduces the risk of leaking a broken document into other tests.


15-22: Limit script cleanup to only scripts created by this test suite.

afterEach currently removes all script[src] elements from document, which can unintentionally delete scripts not created by these tests (e.g., shared setup, other helpers using script tags). Track and remove only the specific scripts you create (for example, by storing created HTMLScriptElement instances in a module-scoped array and cleaning those up here), instead of blanket-removing all script[src] nodes.


125-132: Rejecting with undefined is weak; prefer asserting a meaningful Error.

This test encodes a rejection with undefined, which makes failures harder to debug. It would be better for loadFileUploaderFrom to reject with an Error (or at least a descriptive value) and assert accordingly, e.g. rejects.toThrow or rejects.toEqual(expect.any(Error)), once the implementation is updated.


24-26: Remove async from describe callback and move the dynamic import to beforeAll.

The describe callback must be synchronous for Vitest to properly collect tests. Moving the dynamic import to a beforeAll hook resolves this:

-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
@@
-describe('loadFileUploaderFrom', async () => {
-  const { default: testUrl } = await import('~/web/file-uploader.iife.min.js?url');
+describe('loadFileUploaderFrom', () => {
+  let testUrl: string;
+
+  beforeAll(async () => {
+    ({ default: testUrl } = await import('~/web/file-uploader.iife.min.js?url'));
+  });
🧹 Nitpick comments (1)
tests/file-uploader-inline.e2e.test.tsx (1)

34-34: Use toBeVisible() instead of toBeDefined() for consistency.

The assertion toBeDefined() only verifies that the element query returned a value, not that the URL source is actually visible to the user. Other tests in this file use toBeVisible() (lines 28, 48, 60, 66) for UI element verification.

Apply this diff:

-    await expect(urlSource).toBeDefined();
+    await expect(urlSource).toBeVisible();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira 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 401928a and 546d03c.

📒 Files selected for processing (12)
  • src/abstract/__tests__/loadFileUploaderFrom.test.ts (1 hunks)
  • src/blocks/CameraSource/CameraSource.ts (5 hunks)
  • src/blocks/CameraSource/__tests__/calcCameraModes.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/EditorToolbar.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/crop-utils.test.ts (1 hunks)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts (0 hunks)
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts (0 hunks)
  • tests/adaptive-image.e2e.test.tsx (1 hunks)
  • tests/cloud-image-editor.e2e.test.tsx (1 hunks)
  • tests/file-uploader-inline.e2e.test.tsx (1 hunks)
  • tests/validation.e2e.test.tsx (8 hunks)
  • vite.config.js (1 hunks)
💤 Files with no reviewable changes (2)
  • src/blocks/CloudImageEditor/src/lib/FocusVisible.ts
  • src/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/blocks/CloudImageEditor/src/crop-utils.test.ts
  • tests/validation.e2e.test.tsx
  • src/blocks/CameraSource/tests/calcCameraModes.test.ts
🧰 Additional context used
🪛 GitHub Check: CodeQL
tests/cloud-image-editor.e2e.test.tsx

[notice] 2-2: Unused variable, import, function or class
Unused import vi.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

tests/adaptive-image.e2e.test.tsx

[notice] 1-1: Unused variable, import, function or class
Unused imports commands, userEvent.


[notice] 2-2: Unused variable, import, function or class
Unused import expect.


[notice] 5-5: Unused variable, import, function or class
Unused import renderer.

tests/file-uploader-inline.e2e.test.tsx

[notice] 1-1: Unused variable, import, function or class
Unused import commands.


[notice] 6-6: Unused variable, import, function or class
Unused import renderer.

⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (8)
src/blocks/CameraSource/CameraSource.ts (4)

1025-1044: Tab test IDs look good and consistent

data-testid="tab-photo" and data-testid="tab-video" follow the existing test-id style and clearly encode the mode. No issues; just keep these IDs stable since tests will depend on them.


1046-1054: Recording timer test ID is clear

data-testid="recording-timer" is descriptive and tied to the timer control used during recording; no behavioral change introduced.


1056-1071: Retake button test ID completes CTA coverage

Adding data-testid="retake" gives tests a stable hook for the retake path, matching the accept and shot buttons. Looks good.


1082-1097: Audio control test IDs are appropriately named

data-testid="toggle-microphone" and data-testid="audio-select" are self-explanatory and align with existing test-id conventions in this template. No further changes needed.

tests/file-uploader-inline.e2e.test.tsx (1)

37-67: Comprehensive camera source test coverage.

The test effectively validates the camera source workflow including tab switching, microphone toggling, capture actions, and upload list rendering. The timing delays appropriately accommodate the recording flow.

src/blocks/CloudImageEditor/src/EditorToolbar.ts (1)

504-505: LGTM! Good accessibility enhancement.

Adding title-prop attributes to the cancel and apply slider buttons improves accessibility and enables proper localization. The changes are purely metadata and don't affect control flow.

vite.config.js (1)

24-25: LGTM! Appropriate coverage configuration.

The expanded coverage configuration properly includes all TypeScript source files while excluding tests, configuration files, locales, and build artifacts. This aligns well with the PR objective of improving test coverage.

src/abstract/__tests__/loadFileUploaderFrom.test.ts (1)

27-124: Good coverage of UC_WINDOW_KEY and script loading behavior.

The tests around existing window[UC_WINDOW_KEY], script injection, resolve semantics, and defineComponents registration cover the key branches and interactions cleanly and in an implementation-agnostic way. The structure here looks solid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants