Skip to content

Conversation

@afc163
Copy link
Member

@afc163 afc163 commented Nov 28, 2025

Summary by CodeRabbit

  • New Features

    • 添加 Playwright 组件测试支持与新测试用例,增强响应式与垂直模式验证。
    • 新增测试工具以检测是否存在导航点与箭头,及获取当前幻灯片。
  • Bug Fixes

    • 精简与修正克隆与无滑动判定逻辑,改善无限/无滑动边界行为。
    • 默认配置新增 verticalSwiping:false。
  • Tests

    • 大量旧测试移除或重构,更新若干示例与回归测试预期值。
  • Chores

    • 升级测试/构建相关依赖并扩大对 React 版本的兼容(含 React 19)。
  • Documentation

    • 示例与演示迁移至 React 18+/createRoot 渲染 API。

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

EATSTEAK and others added 30 commits December 7, 2024 01:49
Fix: vertical swiping does not work
Replace enquire.js with window.matchMedia
fixed akiran#2414: No clones when there is one slide or unslick=true
@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

Warning

Rate limit exceeded

@afc163 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9c6537d and 9bc23a8.

📒 Files selected for processing (1)
  • package.json (6 hunks)
📝 Walkthrough

Walkthrough

移除旧的多个 Jest 测试与测试工具,迁移至 React createRoot API,引入 Playwright CT 测试与相关脚手架,调整滑块克隆与媒体查询逻辑,并新增/修改若干测试工具与测试期望值。

Changes

内聚体 / 文件 变更摘要
移除的旧测试工具与挂载测试
__tests__/jQSlickUtils.js, __tests__/reactSlickUtils.js, __tests__/mount/centerMode.test.js, __tests__/mount/lazyLoad.test.js, __tests__/mount/live.test.js, __tests__/mount/simple.test.js
删除所有旧的 jQuery/React 对比测试工具与相关挂载测试文件
回归与示例测试调整
__tests__/regression/fix-1813.test.js, __tests__/regression/fix-2315.test.js, __tests__/regression/fix-2414.test.js, examples/__tests__/*, examples/__tests__/sample.test.js
添加/调整回归测试用例与断言,更新若干示例测试的期望值,移除示例 Counter 测试
测试工具新增
test-utils.js
新增 hasDots(container)hasArrows(container) 测试辅助函数;getCurrentSlide 在相关测试中被引入使用
Playwright 配置与任务
playwright-ct.config.js, gulpfile.js, package.json, .gitignore, jest.config.js
新增 Playwright CT 配置文件,添加 gulp 任务生成 .jsx 文件(gulp-rename),更新 npm 脚本(prepare-playwright、test-ct、test-clear)、devDependencies/peerDependencies、.gitignore 和 jest 的忽略路径
Playwright 测试与故事文件
playwright-tests/sample/sample.spec.tsx, playwright-tests/sample/sample.story.tsx, playwright-tests/features/responsive/*, playwright-tests/regression/fix-1930/*
新增 Playwright CT 测试用例与 Story 文件,覆盖响应式与回归场景
Playwright 脚手架
playwright/index.html, playwright/index.jsx
新增最小 HTML 与 JSX 脚手架文件
React 渲染 API 更新
docs/index.js, docs/single-demo.js
将 ReactDOM.render 改为 React 18+ createRoot API,更新导入与渲染调用,调整示例组件使用
核心滑块逻辑变更
src/slider.js, src/track.js, src/utils/innerSliderUtils.js
media() 不再立即触发匹配回调(仅注册监听器);unslick 条件简化(不再强制检查 settings.infinite);引入 getPostClones 并基于 variableWidth/centerMode 调整后置克隆计算
默认属性扩展
src/default-props.js
新增 verticalSwiping: false 默认属性
TypeScript / 构建配置
tsconfig.json
启用 "jsx": "react-jsx" 配置(注释变更为生效项)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45-60 minutes

需要重点检查的地方:

  • src/track.jssrc/utils/innerSliderUtils.js 的克隆计算(variableWidth、centerMode、infinite 场景)
  • src/slider.js 中 media() 行为变化与 unslick 条件简化对启动/首次渲染的影响
  • Playwright 集成(playwright-ct.config.js、gulp 任务、prepare-playwright 脚手架与 package.json 脚本)的正确性与互操作
  • 测试期望值调整是否与克隆逻辑变化一致

Poem

🐰 测试旧章轻轻合,Playwright 星光在远方,
createRoot 把舞台安放,克隆数悄减细细量,
响应宽度来回跳,滑块节奏又欢畅,
兔耳一摆唱新章,编译与测试共辉煌。

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive 标题'chore: sync upstream'过于宽泛且缺乏具体性,未能清楚传达此PR中大量且复杂的变更内容。 建议将标题改为更具体的描述,例如'chore: upgrade React 19, add Playwright CT tests, and refactor clone generation logic'以准确反映主要变更。
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist
Copy link

Summary of Changes

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

This pull request performs a comprehensive synchronization with upstream changes, focusing on modernizing the project's core dependencies and testing infrastructure. It upgrades React to version 19 and integrates Playwright for robust component testing, replacing older Jest-based utilities. Significant improvements have been made to the slider's cloning logic for better performance and accuracy, alongside a key behavioral adjustment to the 'unslick' condition. These changes collectively enhance the stability, maintainability, and future-readiness of the project.

Highlights

  • React 19 Upgrade & Modernization: The project has been updated to React 19, including react and react-dom dependencies. The documentation's rendering mechanism has been modernized to use React 18's createRoot API for improved performance and concurrent mode compatibility.
  • Playwright Integration for Component Testing: Playwright has been integrated as a new component testing framework. This includes new configuration files (playwright-ct.config.js), dedicated test directories (playwright-tests), and new npm scripts (test-ct, prepare-playwright). Several old Jest-based test utilities and associated mount tests have been removed as part of this transition.
  • Refined Slider Cloning Logic: The internal logic for calculating and rendering cloned slides has been significantly refined. Specifically, the getPostClones utility now uses a more precise calculation based on slidesToShow and centerMode when variableWidth is false, leading to a reduction in the number of rendered cloned slides in various scenarios. This change is reflected in updated expectations across several example tests.
  • Behavioral Change for 'unslick' Condition: The condition under which a slider 'unslicks' (disables slider functionality) has been simplified. Now, if the number of slides is less than or equal to slidesToShow, the slider will always unslick, regardless of the infinite setting. This change aligns with upstream slick carousel functionality and addresses previous inconsistencies, as noted in the updated fix-1813.test.js.
  • New verticalSwiping Prop: A new verticalSwiping prop has been added to the default slider properties, allowing for more granular control over vertical swipe behavior.
Using Gemini Code Assist

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

Invoking Gemini

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

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

Customization

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

Limitations & Feedback

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

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

Footnotes

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

@socket-security
Copy link

socket-security bot commented Nov 28, 2025

Copy link

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

Choose a reason for hiding this comment

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

Code Review

This pull request appears to be a large synchronization with an upstream repository, involving major dependency updates (including React 19 and Playwright for testing), refactoring of the testing suite, and changes to the slider's core logic, particularly around responsive handling and slide cloning. The changes aim to improve performance and align behavior with the original slick carousel.

My review focuses on a few regressions and potential issues introduced with these changes. I've identified a regression in responsive handling that could cause a flash of incorrect styles, pointed out some issues with dependency versions in package.json, and suggested improvements to test descriptions and code cleanup by removing obsolete API calls. Overall, the direction of the changes is positive, but these key issues should be addressed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (4)
docs/single-demo.js (1)

10-43: 考虑移除注释代码。

这段被注释的 SimpleSlider 实现代码(34 行)现在已经有对应的导入可用。如果不再需要此内联实现作为参考,建议移除以保持代码整洁。

src/utils/innerSliderUtils.js (1)

791-800: getPostClonesgetPreClones 逻辑对齐,避免右侧克隆过多

现在在 unslick 或非 infinite 时直接返回 0;其余情况下,variableWidth 仍返回 slideCount,普通模式则与 getPreClones 一样返回 slidesToShow + (centerMode ? 1 : 0)。这样左右两侧克隆节点数保持对称,既减少了不必要的 DOM 体积,也解释了多处测试中 slides / clones 期望值随之下降的原因。可以在未来考虑抽一个内部 helper 复用这段“计算克隆数”的逻辑,以降低两处实现后续改动时可能的偏差风险,但目前实现已足够清晰。

playwright-tests/features/responsive/responsive.spec.tsx (1)

13-37: 避免依赖固定的 waitForTimeout,改用具有自动等待能力的断言

多次使用 page.waitForTimeout(100) 等固定延时,在不同机器或负载下容易造成测试不稳定。这里可以直接对 locator 使用 Playwright 自带的自动轮询断言,既减少代码量,又更可靠,例如:

[建议示例]

-  await expect(await activeSlidesCount(component)).toEqual(4);
+  await expect(
+    component.locator(".slick-slide.slick-active")
+  ).toHaveCount(4);

其他宽度下的断言也可以同样改成对 locator 的 toHaveCount,从而去掉显式的 waitForTimeout 调用。

__tests__/regression/fix-1813.test.js (1)

34-61: 新的回归用例很好地覆盖了 slidesToShow === slidesCount 时的 unslick 行为

MultipleItems 场景下,测试 9 个 slide 全部 active 且同时没有 arrows/dots,和文件顶部“slides <= slidesToShow 时会启用 unslick”的注释是一致的,回归点表达得比较清晰。

如果这些被注释掉的旧用例(导航、dots 交互等)后续不打算再启用,可以考虑在后续重构时直接删除,或者改为 describe.skip/it.skip 来保留行为意图而不是整段注释,便于维护。

Also applies to: 62-163

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6bf3afe and c37d69c.

📒 Files selected for processing (34)
  • .gitignore (1 hunks)
  • __tests__/jQSlickUtils.js (0 hunks)
  • __tests__/mount/centerMode.test.js (0 hunks)
  • __tests__/mount/lazyLoad.test.js (0 hunks)
  • __tests__/mount/live.test.js (0 hunks)
  • __tests__/mount/simple.test.js (0 hunks)
  • __tests__/reactSlickUtils.js (0 hunks)
  • __tests__/regression/fix-1813.test.js (4 hunks)
  • __tests__/regression/fix-2315.test.js (1 hunks)
  • __tests__/regression/fix-2414.test.js (1 hunks)
  • docs/index.js (1 hunks)
  • docs/single-demo.js (1 hunks)
  • examples/__tests__/CentreMode.test.js (1 hunks)
  • examples/__tests__/MultipleItems.test.js (1 hunks)
  • examples/__tests__/SimpleSlider.test.js (1 hunks)
  • examples/__tests__/UnevenSets.test.js (1 hunks)
  • examples/__tests__/sample.test.js (0 hunks)
  • gulpfile.js (2 hunks)
  • jest.config.js (1 hunks)
  • package.json (5 hunks)
  • playwright-ct.config.js (1 hunks)
  • playwright-tests/features/responsive/responsive.spec.tsx (1 hunks)
  • playwright-tests/features/responsive/responsive.story.tsx (1 hunks)
  • playwright-tests/regression/fix-1930/fix-1930.spec.tsx (1 hunks)
  • playwright-tests/regression/fix-1930/fix-1930.story.tsx (1 hunks)
  • playwright-tests/sample/sample.spec.tsx (1 hunks)
  • playwright-tests/sample/sample.story.tsx (1 hunks)
  • playwright/index.html (1 hunks)
  • playwright/index.jsx (1 hunks)
  • src/default-props.js (1 hunks)
  • src/slider.js (1 hunks)
  • src/track.js (2 hunks)
  • src/utils/innerSliderUtils.js (1 hunks)
  • test-utils.js (1 hunks)
💤 Files with no reviewable changes (7)
  • tests/reactSlickUtils.js
  • examples/tests/sample.test.js
  • tests/mount/live.test.js
  • tests/mount/centerMode.test.js
  • tests/jQSlickUtils.js
  • tests/mount/lazyLoad.test.js
  • tests/mount/simple.test.js
🧰 Additional context used
🧬 Code graph analysis (10)
gulpfile.js (1)
playwright-ct.config.js (1)
  • require (2-2)
docs/index.js (1)
docs/docs.js (1)
  • Docs (6-21)
__tests__/regression/fix-2315.test.js (1)
test-utils.js (1)
  • getSlidesCount (3-5)
playwright-tests/sample/sample.spec.tsx (1)
playwright-tests/sample/sample.story.tsx (1)
  • App (3-5)
playwright-tests/regression/fix-1930/fix-1930.spec.tsx (1)
playwright-tests/regression/fix-1930/fix-1930.story.tsx (2)
  • VerticalModeFinite (4-21)
  • VerticalModeInfinite (23-40)
examples/__tests__/MultipleItems.test.js (1)
test-utils.js (2)
  • getSlidesCount (3-5)
  • getClonesCount (11-13)
playwright-tests/regression/fix-1930/fix-1930.story.tsx (1)
src/slider.js (1)
  • Slider (9-219)
__tests__/regression/fix-2414.test.js (2)
__tests__/TestComponents.js (1)
  • GenericSliderComponent (4-9)
test-utils.js (4)
  • getActiveSlidesCount (15-17)
  • getClonesCount (11-13)
  • hasArrows (92-97)
  • hasDots (88-90)
src/track.js (1)
src/utils/innerSliderUtils.js (7)
  • getPostClones (791-800)
  • getPostClones (791-800)
  • spec (166-179)
  • spec (180-180)
  • spec (342-362)
  • spec (441-455)
  • spec (694-708)
docs/single-demo.js (1)
docs/index.js (2)
  • container (7-7)
  • root (8-8)
🪛 ESLint
playwright-tests/features/responsive/responsive.spec.tsx

[error] 11-11: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

playwright-tests/sample/sample.spec.tsx

[error] 12-12: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

playwright-tests/regression/fix-1930/fix-1930.spec.tsx

[error] 11-11: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)


[error] 21-21: 'React' must be in scope when using JSX

(react/react-in-jsx-scope)

__tests__/regression/fix-2414.test.js

[error] 3-3: 'fireEvent' is defined but never used.

(no-unused-vars)


[error] 6-6: 'getCurrentSlideContent' is defined but never used.

(no-unused-vars)


[error] 7-7: 'getSlidesCount' is defined but never used.

(no-unused-vars)

__tests__/regression/fix-1813.test.js

[error] 16-16: 'getCurrentSlide' is defined but never used.

(no-unused-vars)


[error] 17-17: 'getSlidesCount' is defined but never used.

(no-unused-vars)

docs/single-demo.js

[error] 5-5: 'Slider' is defined but never used.

(no-unused-vars)


[error] 6-6: 'MultipleItems' is defined but never used.

(no-unused-vars)


[error] 7-7: 'SimpleSlider' is defined but never used.

(no-unused-vars)


[error] 8-8: 'CenterMode' is defined but never used.

(no-unused-vars)

🔇 Additional comments (23)
playwright/index.jsx (1)

1-2: 验证空文件是否符合预期。

该文件仅包含注释,没有实际的可执行代码或样式导入。请确认这是否是有意为之的初始设置状态,还是需要实现实际的样式导入和主题初始化逻辑。

gulpfile.js (1)

33-39: 实现正确!

这个新的 gulp 任务正确地实现了将 JavaScript 文件复制并重命名为 JSX 扩展名的功能,以支持 Playwright CT 测试工作流。实现遵循了标准的 gulp 模式,逻辑清晰。

jest.config.js (1)

9-9: 配置更新正确。

将忽略模式从 e2e-tests 更新为 playwright-tests 与本次 PR 引入的新 Playwright CT 测试基础设施保持一致。

.gitignore (1)

23-27: 忽略模式添加正确。

新增的忽略模式适合 Playwright CT 测试基础设施:

  • 测试结果和报告目录(test-results、playwright-report、blob-report)
  • Playwright 缓存目录
  • 由 gulp 任务生成的 src-jsx 目录
playwright/index.html (1)

1-12: HTML 脚手架实现正确。

这个 Playwright CT 测试页面的 HTML 结构标准且完整,包含了必要的元信息、根 div 元素和模块脚本导入。

docs/index.js (1)

4-15: React 18+ API 迁移正确。

代码已正确迁移到 React 18+ 的 createRoot API:

  • 正确导入 createRoot from react-dom/client
  • 遵循了创建容器、创建根、调用 root.render() 的标准模式
  • 保留了 React.StrictMode 包装器

这与 React 19 的升级路径一致。

docs/single-demo.js (1)

56-64: React 18+ API 迁移正确。

createRoot API 的迁移实现正确,与 React 19 的最佳实践一致。

examples/__tests__/UnevenSets.test.js (1)

85-86: I'll help you verify the test expectation values. Let me start by examining the test file and understanding the context of these changes.
<function_calls>


#!/bin/bash

First, let's look at the test file around lines 85-86 to understand the context

cat -n examples/tests/UnevenSets.test.js | sed -n '75,95p'


</function_calls>


#!/bin/bash

Search for totalSlides and clonedSlides patterns in test files

echo "=== Searching for totalSlides expectations ==="
rg -n "expect(totalSlides)" examples/tests/ -A 1 -B 1

echo -e "\n=== Searching for clonedSlides expectations ==="
rg -n "expect(clonedSlides)" examples/tests/ -A 1 -B 1


</function_calls>
<function_calls>


#!/bin/bash

Check git history for these specific lines to understand why they changed

cd examples/tests && git log -p --follow -S "expect(totalSlides).toEqual(14)" -- UnevenSets.test.js | head -100 || echo "Git history not available, trying alternative approach"


</function_calls>
<function_calls>


#!/bin/bash

Let's find the implementation being tested

First, understand what UnevenSets test is testing

cat -n examples/tests/UnevenSets.test.js | head -30


</function_calls>
<function_calls>


#!/bin/bash

Look for the actual implementation file that UnevenSets.test.js is testing

rg -n "import.*UnevenSets" examples/tests/UnevenSets.test.js -A 2 -B 2

Also search for UnevenSets implementation

fd -name "nevenSets" -o -name "unevenSets" | grep -v tests


</function_calls>
<function_calls>


#!/bin/bash

Get the full test function containing lines 85-86

cat -n examples/tests/UnevenSets.test.js | sed -n '60,100p'


</function_calls>
<function_calls>


#!/bin/bash

Search for the actual implementation in examples directory

find examples -name ".js" -not -path "tests*" -not -path "node_modules" | head -20


</function_calls>

Let me analyze the structure more carefully:
<function_calls>


#!/bin/bash

List all files in examples directory

ls -la examples/ | head -30


</function_calls>
<function_calls>


#!/bin/bash

Check for the actual implementation - look for imports in the test file more carefully

head -50 examples/tests/UnevenSets.test.js


</function_calls>
<function_calls>


#!/bin/bash

Let's also check if there's recent commit information

git log --oneline -20 -- examples/tests/UnevenSets.test.js 2>/dev/null || echo "No git history"


</function_calls>

Based on the information I need to gather, let me run comprehensive verification:
<function_calls>


#!/bin/bash

Get complete context of the test

wc -l examples/tests/UnevenSets.test.js
echo "---"
cat -n examples/tests/UnevenSets.test.js | sed -n '1,120p'


</function_calls>

package.json (1)

27-30: Playwright CT 测试脚本与依赖新增整体合理,但建议在 CI 中补一轮验证

新增的 test-ct / test-clear / prepare-playwright 脚本与 @playwright/experimental-ct-reactgulp-rename、React 19 等 devDependencies 对齐,看起来配置完整、没有明显问题。需要注意的主要是两点:

  • playwright test -c playwright-ct.config.js 所需的 playwright CLI 是否会通过当前依赖链正确安装;
  • rm -rf ./playwright/.cache 是否确实对应你们 Playwright 配置下的实际缓存目录。

建议在干净环境(CI 或本地重新安装 node_modules)跑一次 npm testnpm run test-ct,确认新脚本在默认场景下可以顺利通过。

Also applies to: 55-90, 109-110

__tests__/regression/fix-2315.test.js (1)

33-33: 更新 slidesCount 期望值以匹配新的克隆逻辑

这里将期望改为 8 与当前实现(例如 6 个实际 slide 加上两侧各 1 个克隆)更一致,有助于防止因为克隆规则调整导致的假阳性,整体测试流程保持不变。

examples/__tests__/CentreMode.test.js (1)

20-21: CenterMode 计数期望已与新的克隆规则对齐

totalSlides = 14clonedSlides = 8 对应 6 个实际 slide、pre/post 各 4 个克隆,符合 centerModegetPreClones/getPostClones 的对称逻辑,修改合理。

src/default-props.js (1)

53-53: 新增 verticalSwiping 默认值提升配置一致性

defaultProps 补上 verticalSwiping: false,让 swipeMove / swipeEnd 等逻辑始终拿到显式布尔值,同时也被 validSettings/filterSettings 正确识别,行为与之前“未传则视为 false”的语义保持向后兼容。

playwright-tests/sample/sample.story.tsx (1)

1-5: 用于 Playwright CT 的最小示例组件实现简单可靠

App 只是渲染静态文本 "Learn React",无状态、无副作用,非常适合作为 Playwright 组件测试的 smoke story,不存在明显问题。

src/slider.js (1)

203-208: 自动 unslick 条件放宽,更贴近“slide 数量不足时直接展示静态内容”的预期

现在当 settings !== "unslick"newChildren.length <= settings.slidesToShow 时,会设置 settings.unslick = true,不再依赖 infinite 标志。这能避免在实际 slide 数不超过可见数量时仍生成多余的克隆节点和导航控件,更符合大多数使用场景的直觉。

这是一个行为层面的改变,建议在包含 responsive + infinite 组合配置的几个示例页上手动走一遍,确认:

  • slide 数量刚好等于或略小于 slidesToShow 时布局/导航行为符合预期;
  • 从小屏断点切回大屏断点时,unslick 状态切换不会引入异常闪烁或状态残留。
examples/__tests__/MultipleItems.test.js (1)

22-27: MultipleItems 测试期望已与新的克隆计数逻辑保持一致

说明文案和断言从“更大的 clones 数量”调整为“9 个实际 slides,(3 pre + 3 post) 共 6 个克隆,总计 15 个 .slick-slide”,与 getPreClones/getPostClonesslidesToShow = 3infinite = true 场景下的对称规则一致。其余关于激活 slides、dots 的行为断言保持不变,整体覆盖面良好。

test-utils.js (1)

88-97: LGTM!新增的工具函数实现正确。

这两个工具函数 hasDotshasArrows 逻辑清晰,可以有效检测滑块控件的存在性,并已被回归测试使用。

examples/__tests__/SimpleSlider.test.js (1)

19-26: 测试预期已更新以反映上游变更。

测试用例正确反映了滑块克隆逻辑的变更:总滑块数从 13 减少到 8,克隆数从 7 减少到 2。这与同步上游的 PR 目标一致。

playwright-tests/features/responsive/responsive.story.tsx (1)

1-71: LGTM!响应式滑块 Story 实现合理。

该组件正确配置了多个响应式断点,并提供了清晰的测试用例。断点设置(1024、600、480)覆盖了常见的设备尺寸。

playwright-tests/regression/fix-1930/fix-1930.spec.tsx (1)

1-26: 验证 JSX 转换配置。

ESLint 在第 11 行和第 21 行提示使用 JSX 时需要 React 在作用域内。如果项目使用旧版 JSX 转换,需要添加 import React from "react"。如果已配置现代 JSX 转换,可以更新 ESLint 规则或忽略此警告。

此问题与 playwright-tests/sample/sample.spec.tsx 中的问题相同,请一并验证项目的 JSX 转换配置。

playwright-tests/regression/fix-1930/fix-1930.story.tsx (1)

1-40: LGTM!边界情况测试设计合理。

这两个组件故意配置 slidesToShow: 3 但仅提供 2 个滑块,用于测试修复 akiran#1930(当滑块数量少于 slidesToShow 时垂直模式的高度问题)。测试预期轨道高度为 200(2 个滑块 × 100 高度),符合修复后的行为。

playwright-ct.config.js (1)

1-47: LGTM!Playwright 组件测试配置合理。

配置文件正确设置了组件测试所需的各项参数,包括测试目录、超时时间、并行执行和 CI 优化。ctPort 设置为 3100 避免了端口冲突。

src/track.js (1)

8-9: 基于 getPostClones 的 post-clone 生成逻辑与 pre-clone 对称,整体实现合理

新引入的 getPostClones(spec) 与已有的 getPreClones(spec) 一样,对需要生成的克隆数量做了明确上限控制,且仍然叠加了 key < endIndex 的 lazy-load 边界判断和外层 spec.infinite && !spec.unslick 等条件。这样既减少不必要的 post clones,又保持了与 pre clones 对称的行为,看起来没有逻辑漏洞。

Also applies to: 170-191

playwright-tests/features/responsive/responsive.spec.tsx (1)

1-2: Based on my verification, I can now provide the final analysis:

Key Findings:

  1. Playwright tests are not linted: The npm run lint command runs eslint src only, which excludes the playwright-tests directory entirely.

  2. Playwright CT React handles JSX automatically: Playwright's experimental-ct-react framework provides built-in JSX transformation support without requiring explicit React imports in test files.

  3. Consistent pattern across the codebase: Multiple spec files (responsive.spec.tsx, fix-1930.spec.tsx, sample.spec.tsx) all omit the React import in spec files, while story files (regular React components) do import React.

  4. Babel configuration: The .babelrc.js uses @babel/preset-react (old JSX transform), but this is handled by Playwright's built-in compilation for CT tests.


Output

React import not required in Playwright Component Testing spec files

Playwright's experimental-ct-react automatically handles JSX transformation in test files without requiring an explicit React import. The responsive.spec.tsx file follows the correct pattern already established across the codebase—spec files omit React imports while story files (regular React components) include them. Additionally, playwright-tests are excluded from linting (the npm lint command targets only src), so no ESLint violations would occur. No changes are needed.

Comment on lines +16 to +19
getCurrentSlide,
getSlidesCount,
hasArrows,
hasDots
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, find and read the test file to examine the imports and usage
fd "fix-1813.test.js" -type f

Repository: ant-design/react-slick

Length of output: 236


🏁 Script executed:

#!/bin/bash
# Correct fd command to find the test file
fd "fix-1813.test.js"

Repository: ant-design/react-slick

Length of output: 103


🏁 Script executed:

#!/bin/bash
# Read the test file with line numbers
cat -n __tests__/regression/fix-1813.test.js | head -60

Repository: ant-design/react-slick

Length of output: 2225


🏁 Script executed:

#!/bin/bash
# Get full file line count
wc -l __tests__/regression/fix-1813.test.js

Repository: ant-design/react-slick

Length of output: 107


🏁 Script executed:

#!/bin/bash
# Search for getCurrentSlide usage in the test file
echo "=== Searching for getCurrentSlide ===" 
rg "getCurrentSlide" __tests__/regression/fix-1813.test.js -n

echo ""
echo "=== Searching for getSlidesCount ===" 
rg "getSlidesCount" __tests__/regression/fix-1813.test.js -n

Repository: ant-design/react-slick

Length of output: 184


🏁 Script executed:

#!/bin/bash
# Read the full test file to see complete context
cat -n __tests__/regression/fix-1813.test.js

Repository: ant-design/react-slick

Length of output: 5651


Remove unused getCurrentSlide and getSlidesCount imports to fix ESLint no-unused-vars warnings

These imports are not used anywhere in the test file. Neither appears in the active test cases (lines 35–61) nor in the commented-out test code (lines 62–163). Removing them will resolve ESLint no-unused-vars errors without affecting test coverage.

   getButtons,
   getButtonsLength,
   getClonesCount,
-  getCurrentSlide,
-  getSlidesCount,
   hasArrows,
   hasDots
 } from "../../test-utils";
📝 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
getCurrentSlide,
getSlidesCount,
hasArrows,
hasDots
getButtons,
getButtonsLength,
getClonesCount,
hasArrows,
hasDots
} from "../../test-utils";
🧰 Tools
🪛 ESLint

[error] 16-16: 'getCurrentSlide' is defined but never used.

(no-unused-vars)


[error] 17-17: 'getSlidesCount' is defined but never used.

(no-unused-vars)

🤖 Prompt for AI Agents
In __tests__/regression/fix-1813.test.js around lines 16 to 19, the imports
getCurrentSlide and getSlidesCount are unused and trigger ESLint no-unused-vars
warnings; remove these two named imports from the import list so only used
imports (hasArrows, hasDots, etc.) remain, then run the linter to confirm
warnings are gone.

Comment on lines +3 to +12
import { render, fireEvent } from "@testing-library/react";

import {
getCurrentSlideContent,
getSlidesCount,
getActiveSlidesCount,
getClonesCount,
hasArrows,
hasDots
} from "../../test-utils";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

移除未使用的导入。

代码导入了 fireEventgetCurrentSlideContentgetSlidesCount,但在测试中从未使用这些函数。建议移除这些未使用的导入以保持代码整洁。

应用此 diff 移除未使用的导入:

-import { render, fireEvent } from "@testing-library/react";
+import { render } from "@testing-library/react";

 import {
-  getCurrentSlideContent,
-  getSlidesCount,
   getActiveSlidesCount,
   getClonesCount,
   hasArrows,
   hasDots
 } from "../../test-utils";
📝 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 { render, fireEvent } from "@testing-library/react";
import {
getCurrentSlideContent,
getSlidesCount,
getActiveSlidesCount,
getClonesCount,
hasArrows,
hasDots
} from "../../test-utils";
import { render } from "@testing-library/react";
import {
getActiveSlidesCount,
getClonesCount,
hasArrows,
hasDots
} from "../../test-utils";
🧰 Tools
🪛 ESLint

[error] 3-3: 'fireEvent' is defined but never used.

(no-unused-vars)


[error] 6-6: 'getCurrentSlideContent' is defined but never used.

(no-unused-vars)


[error] 7-7: 'getSlidesCount' is defined but never used.

(no-unused-vars)

🤖 Prompt for AI Agents
In __tests__/regression/fix-2414.test.js around lines 3 to 12, remove the unused
imports to clean up the test file: delete fireEvent from the first import and
remove getCurrentSlideContent and getSlidesCount from the second import list,
leaving only the functions that are actually used (getActiveSlidesCount,
getClonesCount, hasArrows, hasDots); update the import lines accordingly so
there are no dangling or unused imports.

const { container } = render(<SliderWithOneSlide />);
expect(getClonesCount(container)).toEqual(0);
});
it("should no have dots and arrows", function() {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

修正测试描述中的语法错误。

测试描述中存在拼写错误:"should no have" 应为 "should not have"。

应用此 diff 修正语法错误:

-  it("should no have dots and arrows", function() {
+  it("should not have dots and arrows", function() {
-  it("should no have dots and arrows", function() {
+  it("should not have dots and arrows", function() {

Also applies to: 57-57

🤖 Prompt for AI Agents
In __tests__/regression/fix-2414.test.js around lines 41 and 57, the test
description contains a typo: "should no have" should be corrected to "should not
have"; update both occurrences to use "should not have" so the test descriptions
read correctly and grammatically.

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.07%. Comparing base (17c4018) to head (9bc23a8).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/track.js 60.00% 4 Missing ⚠️
src/utils/innerSliderUtils.js 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
- Coverage   45.86%   45.07%   -0.80%     
==========================================
  Files           8        8              
  Lines         992      994       +2     
  Branches      317      320       +3     
==========================================
- Hits          455      448       -7     
- Misses        439      446       +7     
- Partials       98      100       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@afc163 afc163 merged commit 1cc7f3c into master Dec 4, 2025
6 of 8 checks passed
@afc163 afc163 deleted the feat/update-upstream branch December 4, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants