Skip to content

fix(test): resolve Feishu hoisted mock export syntax error#32128

Merged
steipete merged 1 commit intoopenclaw:mainfrom
ademczuk:fix/feishu-hoisted-mock-export
Mar 3, 2026
Merged

fix(test): resolve Feishu hoisted mock export syntax error#32128
steipete merged 1 commit intoopenclaw:mainfrom
ademczuk:fix/feishu-hoisted-mock-export

Conversation

@ademczuk
Copy link
Copy Markdown
Contributor

@ademczuk ademczuk commented Mar 2, 2026

Summary

  • Fix 2 Feishu extension test suites that crash with SyntaxError: Cannot export hoisted variable
  • Root cause: vi.hoisted() result cannot be exported from a shared mock module (Vitest limitation)
  • Fix: replace vi.hoisted(() => vi.fn()) with plain vi.fn() in shared mock; inline vi.hoisted() + vi.mock() in startup test

Test plan

  • pnpm vitest run extensions/feishu/ — 29/29 suites pass, 230 tests pass
  • pnpm tsgo — zero errors
  • pnpm format — passes

🤖 Generated with Claude Code

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Fixes SyntaxError: Cannot export hoisted variable in Feishu monitor test mocks by replacing vi.hoisted(() => vi.fn()) with plain vi.fn().

  • Vitest doesn't allow exporting hoisted variables from shared mock modules
  • Hoisting is unnecessary here since the mock is imported from a separate module
  • The fix aligns with the existing pattern in other .test-mocks.ts files (e.g., gateway-connection.test-mocks.ts uses plain vi.fn() for exported mocks)
  • Mock functionality is fully preserved - still works with .mockImplementation(), .mockResolvedValue(), etc.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The fix is minimal, targeted, and resolves a concrete syntax error. It aligns with established codebase patterns for exported mocks, preserves all mock functionality, and enables 225 tests to run successfully
  • No files require special attention

Last reviewed commit: 07f2593

@openclaw-barnacle openclaw-barnacle bot added channel: feishu Channel integration: feishu size: XS labels Mar 2, 2026
@ademczuk ademczuk force-pushed the fix/feishu-hoisted-mock-export branch from 3d83040 to 53c0d10 Compare March 2, 2026 20:49
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

@vincentkoc Would appreciate a review when you get a chance — this fixes 2 Feishu test suites that crash on import (SyntaxError: Cannot export hoisted variable). Single commit, 2 files, all 29 Feishu suites green.

@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

CI failure in src/security/skill-scanner.test.ts is a pre-existing flaky test — the cache invalidation test writes two files with identical byte length, so when both writes land in the same mtime resolution window, the cache isn't invalidated. Tracked in #32159 (opened today). Unrelated to this PR's Feishu changes.

@ademczuk ademczuk force-pushed the fix/feishu-hoisted-mock-export branch 2 times, most recently from 713f607 to 2521af4 Compare March 2, 2026 21:52
@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord app: web-ui App: web-ui gateway Gateway runtime size: M and removed channel: feishu Channel integration: feishu size: XS labels Mar 2, 2026
@ademczuk ademczuk force-pushed the fix/feishu-hoisted-mock-export branch from 2521af4 to 8899ce0 Compare March 2, 2026 21:54
@openclaw-barnacle openclaw-barnacle bot added channel: feishu Channel integration: feishu size: XS and removed channel: discord Channel integration: discord app: web-ui App: web-ui gateway Gateway runtime size: M labels Mar 2, 2026
@ademczuk ademczuk force-pushed the fix/feishu-hoisted-mock-export branch 2 times, most recently from 958241d to 221ef35 Compare March 2, 2026 22:21
@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime channel: zalouser Channel integration: zalouser labels Mar 2, 2026
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

CI failures: upstream fixes included + remaining secrets blocker

This PR now includes fixes for both pre-existing upstream TS errors blocking all open PRs:

  1. ChannelKind import (TS2305)server-reload-handlers.ts still imported from config-reload.js after upstream refactor moved it to config-reload-plan.ts. Fixed in commit 221ef35.

  2. ThreadType enum as type (TS2749)zalouser/src/zalo-js.ts:67 used bare enum in type position, rejected by tsgo. Fixed in commit 36ad611.

Remaining: secrets failure (not actionable from PRs)

pnpm audit reports 11 advisories in extensions__googlechat>openclaw (requires >=2026.3.1). This affects every open PR and can only be resolved by a new openclaw release or an npm audit allowlist.

See also: #32170 (same failures, same root cause)

@ademczuk ademczuk force-pushed the fix/feishu-hoisted-mock-export branch from 36ad611 to bc3c869 Compare March 2, 2026 22:57
@openclaw-barnacle openclaw-barnacle bot removed channel: zalouser Channel integration: zalouser gateway Gateway runtime labels Mar 2, 2026
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 2, 2026

Looks like Peter already fixed it. Commit 0e16749 landed on main — fixes both the pairing-store.ts lint errors, the agents-utils.ts lint error, AND bumps the googlechat/memory-core deps (npm audit fix).

Both issues are already resolved on main.

Please take a look at this @Takhoffman at your leisure.

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@ademczuk ademczuk force-pushed the fix/feishu-hoisted-mock-export branch from bc3c869 to d58210d Compare March 2, 2026 23:39
@steipete steipete merged commit 53fd7f8 into openclaw:main Mar 3, 2026
26 checks passed
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 3, 2026

Landed via temp rebase onto main.

  • Gate: pnpm test -- extensions/feishu/src/monitor.startup.test.ts extensions/feishu/src/monitor.reaction.test.ts
  • Land commit: d58210d
  • Merge commit: 53fd7f8

Thanks @ademczuk!

@ademczuk ademczuk deleted the fix/feishu-hoisted-mock-export branch March 3, 2026 07:58
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-authored-by: Claude Opus 4.6 <[email protected]>
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-authored-by: Claude Opus 4.6 <[email protected]>
AytuncYildizli pushed a commit to AytuncYildizli/openclaw that referenced this pull request Mar 4, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-authored-by: Claude Opus 4.6 <[email protected]>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-authored-by: Claude Opus 4.6 <[email protected]>
ephb pushed a commit to ephb-bot/openclaw that referenced this pull request Mar 19, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-authored-by: Claude Opus 4.6 <[email protected]>
lukeg826 pushed a commit to lukeg826/openclaw that referenced this pull request Mar 26, 2026
…32128)

- Remove vi.hoisted() wrapper from exported mock in shared module
  (Vitest cannot export hoisted variables)
- Inline vi.hoisted + vi.mock in startup test so Vitest's per-file
  hoisting registers mocks before production imports

Co-authored-by: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants