Commit graph

30 commits

Author SHA1 Message Date
wowo
1b7bd06685 feat(web): add skill share button with e2e tests (#181)
* test(web): add Playwright e2e testing framework

Add Playwright for end-to-end testing with initial test suites for search flow and network error handling. Also enhance unit tests for network error scenarios.

- Add @playwright/test dependency and npm scripts
- Configure Playwright with chromium browser and HTML reporter
- Add e2e tests for search flow and network error handling
- Update .gitignore to exclude Playwright generated files
- Add network error test cases to api-error unit tests

* feat(web): add skill share button to detail page

Add share button to skill detail page that copies skill info to clipboard. Share text includes skill name, short description (max 30 chars), and detail page URL.

Closes #168

* test(web): add e2e tests for skill share button

Add Playwright e2e tests to verify share button functionality including clipboard copy, text formatting, and state transitions.

* fix(web): fix share button e2e tests and document Playwright workflow

Fix 3 issues in share-button e2e tests:
- Use authenticated mock (skill detail page requires login)
- Add publishedVersion to skill factory (ShareButton render condition)
- Mock versions/files sub-resource APIs to prevent server errors
- Adjust description assertion for 30-char truncation logic

Add Playwright E2E section to CLAUDE.md documenting commands,
screenshot behavior, and test-results directory conventions.

E2E test results: 10/10 passed (Chromium, Playwright 1.58.2)
- network-error.spec.ts:  3/3 passed
- search-flow.spec.ts:    3/3 passed
- share-button.spec.ts:   4/4 passed

* refactor(web): improve share button layout and text format

- Remove description truncation, display full text
- Change share text format from 2 lines to 3 lines (name, description, URL)
- Replace Button component with custom styled native button
- Move ShareButton from card to below download button
- Update tests to match new 3-line format

* fix(web): handle clipboard copy failure in fallback path

- Check document.execCommand('copy') return value
- Throw error when copy fails in fallback path
- Ensure error is properly caught and displayed to user

Fixes issue where "复制 Token 失败,请重试" was shown but the
underlying failure was not properly detected in the fallback code path.

* refactor(web): modernize clipboard with useCopyToClipboard hook

- Add useCopyToClipboard React hook for cleaner state management
- Migrate all copy buttons to use the new hook
- Remove repetitive useState + setTimeout patterns across 7 files
- Simplify clipboard.ts by removing excessive diagnostic logging
- Keep copyToClipboard utility for special cases (file-preview-dialog)

Benefits:
- More idiomatic React code with custom hook
- Consistent 2-second auto-reset behavior
- Reduced code duplication
- Better separation of concerns

* test(web): fix api-error tests and exclude e2e from vitest

- Set i18n language to 'zh' in api-error.test.ts beforeEach
- Add vitest config to exclude e2e directory from unit tests
- All 506 tests now pass

---------

Co-authored-by: xiose <huyanlin@nuaa.edu.cn>
2026-03-30 14:04:52 +08:00
XiaoSeS
6020006a25 fix: scanner redis sentinel, publish flush, version delete, clipboard fallback (#157)
* fix(scanner): migrate scan stream to redisson

* fix(web): update security audit pending labels

* fix(scanner): support redis sentinel in redisson config

* fix(db): allow deleting skill versions with audit history

* fix(publish): flush replaced versions before recreation

* fix(i18n): localize agent setup command in Chinese locale

Translate the agent quick-start prompt from English to Chinese and add
a test to verify both locale strings.

* fix(clipboard): add fallback for insecure contexts

navigator.clipboard is undefined in HTTP/iframe/WebView contexts,
causing TypeError on copy. Extract copyToClipboard() utility with
execCommand fallback and apply across all 6 call sites.
2026-03-24 20:26:50 +08:00
dongmucat
e5a3aa6006 test(web): add colocated frontend coverage
变更摘要:
- 将前端测试共置到 web/src,保留并迁移 app 样式相关用例
- 为 pages、features、shared UI 与 hooks 补齐大范围 Vitest 覆盖
- 强化 governance、file preview、namespace header 与 API client 的关键分支测试
- 重新验证 pnpm run test 与 pnpm run typecheck,当前均已通过

关键文件:
- web/src/pages/dashboard/governance.test.ts
- web/src/features/governance/governance-inbox.test.ts
- web/src/features/skill/file-preview-dialog.test.ts
- web/src/features/namespace/namespace-header.test.ts
- web/src/api/client.test.ts
2026-03-23 16:13:34 +08:00
dongmucat
c36b74fda6 feat(web): migrate shared select to radix 2026-03-20 14:27:20 +08:00
vsxd
729b1c0498 docs: enrich frontend code documentation 2026-03-19 13:37:21 +08:00
vsxd
f4b9a26f6f fix: preserve local timezone in token expiration UI 2026-03-18 17:16:55 +08:00
yun-zhi-ztl
9e916305f1 test: cover formatting and api error helpers 2026-03-17 11:51:40 +08:00
yun-zhi-ztl
22c3ca69a0 fix: stack dashboard skills and tokens 2026-03-17 11:36:48 +08:00
xiose
40b9c8e39d fix(web): reset token dialog state on reopen, fix pagination and download button
- Reset form fields and mutation state when create-token dialog reopens
- Fix delete pagination: check items.length === 0 (post-delete) instead of 1
- Restrict skill download to PUBLISHED versions only
2026-03-16 20:39:33 +08:00
xiose
c23960ea0b fix(web): prevent text overflow in token dialogs
Add responsive text wrapping and overflow handling to token-related
components to prevent layout breaking with long token names or descriptions.

Changes:
- Add min-w-0 to dialog headers to allow flex shrinking
- Add break-all/break-words to prevent text overflow
- Add overflow-hidden to token display container
- Apply max-w-48 constraint to token name column
2026-03-16 20:39:33 +08:00
yun-zhi-ztl
21ae36645c fix(token): remove list copy action and clarify one-time copy 2026-03-15 14:20:14 +08:00
yun-zhi-ztl
6786b8a95c fix(toast): center feedback and remove native token tooltip 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
4c91b73592 fix(dialog): center popup content across app 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
d6608e4b29 fix(token): center token actions and toast layout 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
fb32512ed9 fix(token): center token feedback toasts 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
9f4ac978b9 feat(token): support copy hints and expiration updates 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
f3c3c2beeb feat(token): support configurable expiration times 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
b1bbbeb7c9 fix(token): center copy toasts with dedicated toaster 2026-03-15 14:20:07 +08:00
yun-zhi-ztl
176bfe9fb5 fix(token): handle successful deletes and refresh immediately 2026-03-14 20:09:41 +08:00
yun-zhi-ztl
196fe52391 fix(dashboard): avoid duplicate token fetch and false error toast 2026-03-14 19:56:57 +08:00
yun-zhi-ztl
bf319332c5 feat(token): paginate token list 2026-03-14 19:44:11 +08:00
yun-zhi-ztl
fc9bdffc7d fix(token): validate name length and uniqueness 2026-03-14 19:38:18 +08:00
yun-zhi-ztl
553a72eeb1 fix(token): center copy feedback toast 2026-03-14 19:24:29 +08:00
yun-zhi-ztl
fd790a9610 feat(web): add header nav to landing page and local dev improvements
- Add sticky header with LanguageSwitcher and UserMenu to landing page
- Update token dialog and i18n translations
- Fix dev process script and compose release config
- Remove stale skillhub submodule reference
2026-03-14 17:32:47 +08:00
vsxd
2170412bda feat(web): complete i18n coverage for all pages and components
Replace hardcoded Chinese strings with t() calls across 36 files.
Expand translation keys from ~160 to 412 covering all pages, features,
and shared components. Fix date formatting to use dynamic i18n locale.
2026-03-13 14:43:26 +08:00
vsxd
9b5154cc51 feat(web): add unified API error handling and complete i18n coverage
- Add ApiError class with status code for structured error handling
- Add global QueryCache/MutationCache error handlers with auto-toast
- Auto-redirect to login on 401, show appropriate messages for 403/404/5xx
- Add i18n to review-detail.tsx, token-list.tsx, confirm-dialog.tsx
- Add review, token, apiError translation keys to zh.json and en.json
2026-03-13 13:55:59 +08:00
vsxd
0200d21f0e feat(web): implement toast notifications and SPA dialogs
- Added sonner toast library for notifications
- Created Toaster component with custom styling
- Created toast utility with success/error/warning/info methods
- Created ConfirmDialog component for confirmations
- Replaced browser alert() with toast notifications in:
  - Publish page: added review notice and toast feedback
  - Token list: replaced confirm() with ConfirmDialog
  - Review detail: replaced alert/confirm with toast and dialogs
- Added review notice in publish page explaining admin approval process
- Improved user experience with in-page notifications instead of browser popups

Database changes:
- Added SKILL_ADMIN role to user usr_da52079c-3329-4a5c-a631-8eadfb865a79
2026-03-13 13:41:10 +08:00
vsxd
68af8047b8 Complete phase 3 and 4 frontend flows 2026-03-13 11:36:39 +08:00
vsxd
0b1607630f fix(phase1): close auth and frontend acceptance gaps 2026-03-12 00:37:51 +08:00
vsxd
e6956e79fc feat(web): implement login page, dashboard, and API token management
- Login page with dynamic OAuth provider buttons from /api/v1/auth/providers
- Dashboard with AuthGuard, user info display, and token management
- TokenList component with create/delete operations via TanStack Query
- CreateTokenDialog with one-time token display and copy functionality
- API client with typed auth and token endpoints
- shadcn/ui components: Button, Card, Dialog, Table, Input, Label
- Tailwind CSS with CSS variables theming
- TanStack Router with Home, Login, Dashboard routes
- ESLint + TypeScript strict mode configuration
2026-03-12 00:13:50 +08:00