Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^2.0.4",
"@vitest/coverage-v8": "^3.0.7",
"@vitest/ui": "^2.0.4",
Comment on lines +166 to 167
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

🌐 Web query:

@vitest/ui 3.0.7 vitest 3.0.7 compatibility requirements

💡 Result:

  • @vitest/ui@3.0.7 expects vitest@3.0.7 as a peer dependency (the @vitest/ui package pins the peer vitest version to the exact same release number; e.g., @vitest/ui@3.0.8 has peerDependencies: { "vitest": "3.0.8" }). [1]
  • Therefore, for @vitest/ui@3.0.7 + vitest@3.0.7, make sure your environment meets Vitest v3 minimums: Node.js ≥ 18.0.0 and Vite ≥ 5.0.0. [2]

Sources: [1] @vitest/ui package.json on UNPKG (example pinned peer dep behavior), [2] Vitest v3 “Getting Started” requirements.


修复 @vitest/ui 的对等依赖版本不匹配

@vitest/ui 的对等依赖(peer dependency)要求与 vitest 版本精确匹配。当前 @vitest/ui^2.0.4vitest 已升级至 ^3.0.7,这会导致对等依赖冲突。需将 @vitest/ui 升级至 ^3.0.7

建议的修改
     "@vitest/coverage-v8": "^3.0.7",
-    "@vitest/ui": "^2.0.4",
+    "@vitest/ui": "^3.0.7",
📝 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
"@vitest/coverage-v8": "^3.0.7",
"@vitest/ui": "^2.0.4",
"@vitest/coverage-v8": "^3.0.7",
"@vitest/ui": "^3.0.7",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 166 - 167, 在 package.json 中修复 `@vitest/ui`
的对等依赖版本不匹配:将依赖项 "@vitest/ui": "^2.0.4" 更新为 "@vitest/ui": "^3.0.7",以与已安装的 vitest
版本 (^3.0.7) 精确匹配;保存 package.json 后重新运行包管理器(npm/yarn/pnpm
install)并执行测试/构建以验证没有新的冲突。

"autoprefixer": "^10.4.17",
"axios": "^1.6.7",
Expand Down
488 changes: 257 additions & 231 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/packages/cell/__test__/__snapshots__/cell.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ exports[`slot extra 1`] = `
class="nut-cell-extra"
>
<div
aria-checked="true"
aria-disabled="false"
class="nut-switch"
role="switch"
tabindex="0"
>
<div
class="nut-switch-button nut-switch-button-open"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`should match snapshot 1`] = `
<DocumentFragment>
<div
class="nut-checkbox nut-checkbox-reverse"
class="nut-checkbox nut-checkbox-reverse nut-checkbox-active"
>
<div
class="nut-checkbox-icon-wrap"
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/packages/tag/tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

&-primary {
background: #fa2c19;
background: $tag-primary-background-color;
}

&-info {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`timeselect props test 1`] = `"<div><div class="nut-overlay" style="z-index: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">取件时间</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="M512 557.23 783.57 828.8c8.32 8.32 21.76 8.32 30.3 0l14.93-14.93c8.32-8.32 8.32-21.76 0-30.3L557.23 512 828.8 240.43c8.32-8.32 8.32-21.76 0-30.3l-14.93-14.93c-8.32-8.32-21.76-8.32-30.3 0L512 466.77 240.43 195.2c-8.32-8.32-21.76-8.32-30.3 0l-14.93 14.93c-8.32 8.32-8.32 21.76 0 30.3L466.77 512 195.2 783.57c-8.32 8.32-8.32 21.76 0 30.3l14.93 14.93c8.32 8.32 21.76 8.32 30.3 0z" fill="currentColor"></path></svg></div></div><div class="nut-timeselect"><div class="nut-timeselect-content"><div class="nut-timeselect-content-left"><div class="nut-timepannel active">520</div><div class="nut-timepannel">521</div></div><div class="nut-timedetail"><span class="nut-timedetail-item">09:00-10:00</span><span class="nut-timedetail-item">10:00-11:00</span><span class="nut-timedetail-item">11:00-12:00</span></div></div></div></div></div>"`;
exports[`timeselect props test 1`] = `"<div><div class="nut-overlay" style="z-index: 1000;"></div><div style="z-index: 1000;" class="nut-popup nut-popup-round nut-popup-bottom"><div class="nut-popup-title"><div class="nut-popup-title-wrapper"><div class="nut-popup-title-title">取件时间</div></div><div class="nut-popup-title-right nut-popup-title-right-top-right" role="button" aria-label="关闭" tabindex="-1"><svg class="nut-icon nut-icon-Close " xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Close" role="presentation"><path d="M512 557.23 783.57 828.8c8.32 8.32 21.76 8.32 30.3 0l14.93-14.93c8.32-8.32 8.32-21.76 0-30.3L557.23 512 828.8 240.43c8.32-8.32 8.32-21.76 0-30.3l-14.93-14.93c-8.32-8.32-21.76-8.32-30.3 0L512 466.77 240.43 195.2c-8.32-8.32-21.76-8.32-30.3 0l-14.93 14.93c-8.32 8.32-8.32 21.76 0 30.3L466.77 512 195.2 783.57c-8.32 8.32-8.32 21.76 0 30.3l14.93 14.93c8.32 8.32 21.76 8.32 30.3 0z" fill="currentColor"></path></svg></div></div><div class="nut-timeselect"><div class="nut-timeselect-content"><div class="nut-timeselect-content-left"><div class="nut-timepannel active">520</div><div class="nut-timepannel">521</div></div><div class="nut-timedetail"><span class="nut-timedetail-item">09:00-10:00</span><span class="nut-timedetail-item">10:00-11:00</span><span class="nut-timedetail-item">11:00-12:00</span></div></div></div></div></div>"`;
70 changes: 49 additions & 21 deletions src/packages/uploader/__tests__/uploader.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { render, fireEvent } from '@testing-library/react'
import { render, fireEvent, waitFor, act } from '@testing-library/react'
import '@testing-library/jest-dom'

import { Uploader } from '../uploader'
Expand Down Expand Up @@ -275,9 +275,12 @@ test('simulates single file upload', async () => {
})
const input: any = container.querySelector('input')

await fireEvent.change(input, { target: { files: [file] } })

expect(handleUpload).toHaveBeenCalledTimes(1)
await act(async () => {
fireEvent.change(input, { target: { files: [file] } })
})
await waitFor(() => {
expect(handleUpload).toHaveBeenCalledTimes(1)
})
expect(handleUpload).toHaveBeenCalledWith(file)
})
test('simulates single file upload fail', async () => {
Expand All @@ -292,9 +295,12 @@ test('simulates single file upload fail', async () => {
})
const input: any = container.querySelector('input')

await fireEvent.change(input, { target: { files: [file] } })

expect(handleUpload).toHaveBeenCalledTimes(1)
await act(async () => {
fireEvent.change(input, { target: { files: [file] } })
})
await waitFor(() => {
expect(handleUpload).toHaveBeenCalledTimes(1)
})
expect(handleUpload).toHaveBeenCalledWith(file)
await expect(handleUpload()).rejects.toThrow('Upload failed')
})
Expand All @@ -321,9 +327,12 @@ test('simulates multiple file upload', async () => {
const files = [file1, file2, file3]
const input: any = container.querySelector('input')

await fireEvent.change(input, { target: { files } })

expect(handleUpload).toHaveBeenCalledTimes(2)
await act(async () => {
fireEvent.change(input, { target: { files } })
})
await waitFor(() => {
expect(handleUpload).toHaveBeenCalledTimes(2)
})
expect(handleOverCount).toHaveBeenCalledTimes(1)
expect(handleOverCount).toHaveBeenCalledWith(3)
})
Expand All @@ -350,9 +359,13 @@ test('simulates file upload when autoupload is false', async () => {
})
const files = [file1, file2, file3]
const input: any = container.querySelector('input')
await fireEvent.change(input, { target: { files } })
await act(async () => {
fireEvent.change(input, { target: { files } })
})
await waitFor(() => {
expect(handleOverCount).toHaveBeenCalledTimes(1)
})
expect(handleUpload).toHaveBeenCalledTimes(0)
expect(handleOverCount).toHaveBeenCalledTimes(1)
expect(handleOverCount).toHaveBeenCalledWith(3)
})
test('should render button', () => {
Expand Down Expand Up @@ -521,18 +534,30 @@ test('should handle beforeUpload function', async () => {
const input: any = container.querySelector('input')

// 测试单个 PNG 文件上传
await fireEvent.change(input, { target: { files: [pngFile] } })
expect(beforeUpload).toHaveBeenCalledTimes(1)
await act(async () => {
fireEvent.change(input, { target: { files: [pngFile] } })
})
await waitFor(() => {
expect(beforeUpload).toHaveBeenCalledTimes(1)
})
expect(handleUpload).toHaveBeenCalledWith(pngFile)

// 测试单个 JPG 文件被过滤
await fireEvent.change(input, { target: { files: [jpgFile] } })
expect(beforeUpload).toHaveBeenCalledTimes(2)
await act(async () => {
fireEvent.change(input, { target: { files: [jpgFile] } })
})
await waitFor(() => {
expect(beforeUpload).toHaveBeenCalledTimes(2)
})
expect(handleUpload).not.toHaveBeenCalledWith(jpgFile)

// 测试多文件上传时的过滤
await fireEvent.change(input, { target: { files: [pngFile, jpgFile] } })
expect(beforeUpload).toHaveBeenCalledTimes(3)
await act(async () => {
fireEvent.change(input, { target: { files: [pngFile, jpgFile] } })
})
await waitFor(() => {
expect(beforeUpload).toHaveBeenCalledTimes(3)
})
expect(handleUpload).toHaveBeenCalledTimes(2) // 只有 PNG 文件被上传
})

Expand All @@ -552,8 +577,11 @@ test('should handle beforeUpload returning empty array', async () => {
})

const input: any = container.querySelector('input')
await fireEvent.change(input, { target: { files: [file] } })

expect(beforeUpload).toHaveBeenCalled()
await act(async () => {
fireEvent.change(input, { target: { files: [file] } })
})
await waitFor(() => {
expect(beforeUpload).toHaveBeenCalled()
})
expect(handleUpload).not.toHaveBeenCalled()
})
Loading