@web-auto/webauto 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/desktop-console/default-settings.json +1 -0
- package/apps/desktop-console/dist/main/index.mjs +1618 -0
- package/apps/desktop-console/{src → dist}/main/preload.mjs +10 -0
- package/apps/desktop-console/dist/renderer/index.js +3063 -0
- package/apps/desktop-console/entry/ui-console.mjs +299 -0
- package/apps/webauto/entry/account.mjs +356 -0
- package/apps/webauto/entry/lib/account-detect.mjs +160 -0
- package/apps/webauto/entry/lib/account-store.mjs +587 -0
- package/apps/webauto/entry/lib/profilepool.mjs +1 -1
- package/apps/webauto/entry/xhs-install.mjs +27 -3
- package/apps/webauto/entry/xhs-status.mjs +152 -0
- package/apps/webauto/entry/xhs-unified.mjs +595 -17
- package/bin/webauto.mjs +247 -12
- package/dist/apps/webauto/server.js +66 -0
- package/dist/modules/camo-backend/src/index.js +575 -0
- package/dist/modules/camo-backend/src/internal/BrowserSession.js +817 -0
- package/dist/modules/camo-backend/src/internal/ElementRegistry.js +61 -0
- package/dist/modules/camo-backend/src/internal/ProfileLock.js +85 -0
- package/dist/modules/camo-backend/src/internal/SessionManager.js +172 -0
- package/dist/modules/camo-backend/src/internal/container-matcher.js +852 -0
- package/dist/modules/camo-backend/src/internal/engine-manager.js +258 -0
- package/dist/modules/camo-backend/src/internal/fingerprint.js +203 -0
- package/dist/modules/camo-backend/src/internal/pageRuntime.js +29 -0
- package/dist/modules/camo-backend/src/internal/runtimeInjector.js +30 -0
- package/dist/modules/camo-backend/src/internal/state-bus.js +46 -0
- package/dist/modules/camo-backend/src/internal/storage-paths.js +36 -0
- package/dist/modules/camo-backend/src/internal/ws-server.js +1202 -0
- package/dist/modules/camo-runtime/src/utils/browser-service.mjs +423 -0
- package/dist/modules/camo-runtime/src/utils/config.mjs +77 -0
- package/dist/modules/container-registry/src/index.js +184 -0
- package/dist/modules/logging/src/index.js +92 -0
- package/dist/modules/operations/src/builtin.js +27 -0
- package/dist/modules/operations/src/container-binding.js +75 -0
- package/dist/modules/operations/src/executor.js +146 -0
- package/dist/modules/operations/src/operations/click.js +167 -0
- package/dist/modules/operations/src/operations/extract.js +204 -0
- package/dist/modules/operations/src/operations/find-child.js +17 -0
- package/dist/modules/operations/src/operations/highlight.js +138 -0
- package/dist/modules/operations/src/operations/key.js +61 -0
- package/dist/modules/operations/src/operations/navigate.js +148 -0
- package/dist/modules/operations/src/operations/scroll.js +126 -0
- package/dist/modules/operations/src/operations/type.js +190 -0
- package/dist/modules/operations/src/queue.js +100 -0
- package/dist/modules/operations/src/registry.js +11 -0
- package/dist/modules/operations/src/system/mouse.js +33 -0
- package/dist/modules/state/src/atomic-json.js +33 -0
- package/dist/modules/workflow/blocks/AnchorVerificationBlock.js +71 -0
- package/dist/modules/workflow/blocks/BehaviorRandomizer.js +26 -0
- package/dist/modules/workflow/blocks/CallWorkflowBlock.js +38 -0
- package/dist/modules/workflow/blocks/CloseDetailBlock.js +209 -0
- package/dist/modules/workflow/blocks/CollectBatch.js +137 -0
- package/dist/modules/workflow/blocks/CollectCommentsBlock.js +415 -0
- package/dist/modules/workflow/blocks/CollectSearchListBlock.js +599 -0
- package/dist/modules/workflow/blocks/CollectWeiboPosts.js +229 -0
- package/dist/modules/workflow/blocks/DetectPageStateBlock.js +259 -0
- package/dist/modules/workflow/blocks/EnsureLoginBlock.js +162 -0
- package/dist/modules/workflow/blocks/EnsureSession.js +426 -0
- package/dist/modules/workflow/blocks/ErrorClassifier.js +164 -0
- package/dist/modules/workflow/blocks/ErrorRecoveryBlock.js +319 -0
- package/dist/modules/workflow/blocks/ExpandCommentsBlock.js +1032 -0
- package/dist/modules/workflow/blocks/ExtractDetailBlock.js +310 -0
- package/dist/modules/workflow/blocks/ExtractPostFields.js +88 -0
- package/dist/modules/workflow/blocks/GenerateSmartReplyBlock.js +68 -0
- package/dist/modules/workflow/blocks/GoToSearchBlock.js +497 -0
- package/dist/modules/workflow/blocks/GracefulFallbackBlock.js +104 -0
- package/dist/modules/workflow/blocks/HighlightBlock.js +66 -0
- package/dist/modules/workflow/blocks/InitAutoScroll.js +65 -0
- package/dist/modules/workflow/blocks/LoadContainerDefinition.js +50 -0
- package/dist/modules/workflow/blocks/LoadContainerIndex.js +43 -0
- package/dist/modules/workflow/blocks/LocateAndGuardBlock.js +176 -0
- package/dist/modules/workflow/blocks/LoginRecoveryBlock.js +242 -0
- package/dist/modules/workflow/blocks/MatchContainers.js +64 -0
- package/dist/modules/workflow/blocks/MonitoringBlock.js +190 -0
- package/dist/modules/workflow/blocks/OpenDetailBlock.js +1240 -0
- package/dist/modules/workflow/blocks/OrganizeXhsNotesBlock.js +117 -0
- package/dist/modules/workflow/blocks/PersistXhsNoteBlock.js +270 -0
- package/dist/modules/workflow/blocks/PickSinglePost.js +69 -0
- package/dist/modules/workflow/blocks/ProgressTracker.js +125 -0
- package/dist/modules/workflow/blocks/RecordFixtureBlock.js +44 -0
- package/dist/modules/workflow/blocks/RenderMarkdown.js +48 -0
- package/dist/modules/workflow/blocks/SaveFile.js +54 -0
- package/dist/modules/workflow/blocks/ScrollNextBatch.js +72 -0
- package/dist/modules/workflow/blocks/SessionHealthBlock.js +73 -0
- package/dist/modules/workflow/blocks/StartBrowserService.js +45 -0
- package/dist/modules/workflow/blocks/ValidateContainerDefinition.js +67 -0
- package/dist/modules/workflow/blocks/ValidateExtract.js +35 -0
- package/dist/modules/workflow/blocks/WaitSearchPermitBlock.js +162 -0
- package/dist/modules/workflow/blocks/WaitStable.js +74 -0
- package/dist/modules/workflow/blocks/WarmupCommentsBlock.js +120 -0
- package/dist/modules/workflow/blocks/WorkflowExecutor.js +156 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectFromLinksBlock.js +1004 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectLinksBlock.js +1049 -0
- package/dist/modules/workflow/blocks/XiaohongshuFullCollectBlock.js +782 -0
- package/dist/modules/workflow/blocks/helpers/anchorVerify.js +198 -0
- package/dist/modules/workflow/blocks/helpers/asyncWorkQueue.js +53 -0
- package/dist/modules/workflow/blocks/helpers/commentScroller.js +334 -0
- package/dist/modules/workflow/blocks/helpers/commentSectionLocator.js +126 -0
- package/dist/modules/workflow/blocks/helpers/containerAnchors.js +301 -0
- package/dist/modules/workflow/blocks/helpers/debugArtifacts.js +6 -0
- package/dist/modules/workflow/blocks/helpers/downloadPaths.js +29 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsController.js +53 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsExtractor.js +129 -0
- package/dist/modules/workflow/blocks/helpers/macosVisionOcrPlugin.js +116 -0
- package/dist/modules/workflow/blocks/helpers/mergeXhsMarkdown.js +109 -0
- package/dist/modules/workflow/blocks/helpers/openDetailController.js +56 -0
- package/dist/modules/workflow/blocks/helpers/openDetailTypes.js +7 -0
- package/dist/modules/workflow/blocks/helpers/openDetailViewport.js +474 -0
- package/dist/modules/workflow/blocks/helpers/openDetailWaiter.js +104 -0
- package/dist/modules/workflow/blocks/helpers/operationLogger.js +195 -0
- package/dist/modules/workflow/blocks/helpers/persistedNotes.js +107 -0
- package/dist/modules/workflow/blocks/helpers/replyExpander.js +260 -0
- package/dist/modules/workflow/blocks/helpers/scrollIntoView.js +138 -0
- package/dist/modules/workflow/blocks/helpers/searchExecutor.js +328 -0
- package/dist/modules/workflow/blocks/helpers/searchGate.js +46 -0
- package/dist/modules/workflow/blocks/helpers/searchPageState.js +164 -0
- package/dist/modules/workflow/blocks/helpers/searchResultWaiter.js +64 -0
- package/dist/modules/workflow/blocks/helpers/simpleAnchor.js +134 -0
- package/dist/modules/workflow/blocks/helpers/smartReply.js +40 -0
- package/dist/modules/workflow/blocks/helpers/systemInput.js +635 -0
- package/dist/modules/workflow/blocks/helpers/targetCountMode.js +9 -0
- package/dist/modules/workflow/blocks/helpers/xhsCliArgs.js +80 -0
- package/dist/modules/workflow/blocks/helpers/xhsCommentDom.js +805 -0
- package/dist/modules/workflow/blocks/helpers/xhsNoteOrganizer.js +140 -0
- package/dist/modules/workflow/blocks/restore/RestorePhaseBlock.js +204 -0
- package/dist/modules/workflow/config/workflowRegistry.js +32 -0
- package/dist/modules/workflow/definitions/batch-collect-workflow.js +63 -0
- package/dist/modules/workflow/definitions/scroll-extract-workflow.js +74 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow-v2.js +81 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow.js +57 -0
- package/dist/modules/workflow/definitions/xiaohongshu-full-collect-workflow-v3.js +68 -0
- package/dist/modules/workflow/definitions/xiaohongshu-note-collect.js +49 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase1-workflow-v3.js +30 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase2-links-workflow-v3.js +40 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase3-collect-workflow-v1.js +54 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase34-from-links-workflow-v3.js +25 -0
- package/dist/modules/workflow/src/WeiboEventDrivenWorkflowRunner.js +308 -0
- package/dist/modules/workflow/src/context.js +70 -0
- package/dist/modules/workflow/src/index.js +5 -0
- package/dist/modules/workflow/src/orchestrator.js +230 -0
- package/dist/modules/workflow/src/runner.js +55 -0
- package/dist/modules/workflow/src/runtime.js +70 -0
- package/dist/modules/workflow/workflows/WeiboFeedExtractionWorkflow.js +359 -0
- package/dist/modules/workflow/workflows/XiaohongshuLoginWorkflow.js +110 -0
- package/dist/modules/xiaohongshu/app/src/blocks/MatchCommentsBlock.js +139 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1EnsureServicesBlock.js +36 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1MonitorCookieBlock.js +213 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1StartProfileBlock.js +121 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2CollectLinksBlock.js +1249 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2SearchBlock.js +703 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseDetailBlock.js +41 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseTabsBlock.js +44 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CollectCommentsBlock.js +150 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ExtractDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenDetailBlock.js +102 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenTabsBlock.js +109 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34PersistDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ProcessSingleNoteBlock.js +114 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ValidateLinksBlock.js +90 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase3InteractBlock.js +1009 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase4MultiTabHarvestBlock.js +233 -0
- package/dist/modules/xiaohongshu/app/src/blocks/ReplyInteractBlock.js +291 -0
- package/dist/modules/xiaohongshu/app/src/blocks/XhsDiscoverFallbackBlock.js +240 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatchDsl.js +126 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatcher.js +99 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/evidence.js +27 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/sharding.js +42 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/xhsComments.js +270 -0
- package/dist/modules/xiaohongshu/app/src/index.js +9 -0
- package/dist/modules/xiaohongshu/app/src/utils/checkpoints.js +222 -0
- package/dist/modules/xiaohongshu/app/src/utils/controllerAction.js +43 -0
- package/dist/services/controller/src/controller.js +1476 -0
- package/dist/services/controller/src/index.js +2 -0
- package/dist/services/controller/src/payload-normalizer.js +129 -0
- package/dist/services/shared/heartbeat.js +120 -0
- package/dist/services/shared/lib/errorHandler.js +2 -0
- package/dist/services/shared/serviceProcessLogger.js +139 -0
- package/dist/services/unified-api/RemoteBrowserSession.js +176 -0
- package/dist/services/unified-api/RemoteSessionManager.js +148 -0
- package/dist/services/unified-api/container-operations-handler.js +115 -0
- package/dist/services/unified-api/server.js +652 -0
- package/dist/services/unified-api/state-registry.js +274 -0
- package/dist/services/unified-api/task-persistence.js +66 -0
- package/dist/services/unified-api/task-state.js +130 -0
- package/modules/camo-runtime/src/autoscript/action-providers/xhs/search.mjs +12 -5
- package/modules/xiaohongshu/app/pnpm-lock.yaml +24 -0
- package/package.json +37 -9
- package/.beads/README.md +0 -81
- package/.beads/config.yaml +0 -67
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +0 -180
- package/.beads/metadata.json +0 -4
- package/.claude/settings.local.json +0 -10
- package/.github/workflows/ci.yml +0 -55
- package/AGENTS.md +0 -253
- package/apps/desktop-console/README.md +0 -27
- package/apps/desktop-console/package-lock.json +0 -897
- package/apps/desktop-console/package.json +0 -20
- package/apps/desktop-console/scripts/build-and-install.mjs +0 -19
- package/apps/desktop-console/scripts/build.mjs +0 -45
- package/apps/desktop-console/scripts/test-preload.mjs +0 -13
- package/apps/desktop-console/src/main/config.mts +0 -26
- package/apps/desktop-console/src/main/core-daemon-manager.mts +0 -131
- package/apps/desktop-console/src/main/desktop-settings.mts +0 -267
- package/apps/desktop-console/src/main/heartbeat-watchdog.mts +0 -50
- package/apps/desktop-console/src/main/heartbeat-watchdog.test.mts +0 -68
- package/apps/desktop-console/src/main/index-streaming.test.mts +0 -20
- package/apps/desktop-console/src/main/index.mts +0 -980
- package/apps/desktop-console/src/main/profile-store.mts +0 -239
- package/apps/desktop-console/src/main/profile-store.test.mts +0 -54
- package/apps/desktop-console/src/main/state-bridge.mts +0 -114
- package/apps/desktop-console/src/main/task-state-types.ts +0 -32
- package/apps/desktop-console/src/renderer/hooks/use-task-state.mts +0 -120
- package/apps/desktop-console/src/renderer/index.mts +0 -133
- package/apps/desktop-console/src/renderer/index.test.mts +0 -34
- package/apps/desktop-console/src/renderer/path-helpers.mts +0 -46
- package/apps/desktop-console/src/renderer/path-helpers.test.mts +0 -14
- package/apps/desktop-console/src/renderer/tabs/debug.mts +0 -48
- package/apps/desktop-console/src/renderer/tabs/debug.test.mts +0 -22
- package/apps/desktop-console/src/renderer/tabs/logs.mts +0 -421
- package/apps/desktop-console/src/renderer/tabs/logs.test.mts +0 -27
- package/apps/desktop-console/src/renderer/tabs/preflight.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/preflight.test.mts +0 -33
- package/apps/desktop-console/src/renderer/tabs/profile-pool.mts +0 -213
- package/apps/desktop-console/src/renderer/tabs/results.mts +0 -171
- package/apps/desktop-console/src/renderer/tabs/run.test.mts +0 -63
- package/apps/desktop-console/src/renderer/tabs/runtime.mts +0 -151
- package/apps/desktop-console/src/renderer/tabs/settings.mts +0 -146
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/account-flow.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/guide-browser-check.mts +0 -56
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/helpers.mts +0 -262
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/layout-block.mts +0 -430
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/live-stats.mts +0 -847
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/run-flow.mts +0 -443
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu-state.mts +0 -425
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.mts +0 -497
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.test.mts +0 -291
- package/apps/desktop-console/src/renderer/ui-components.mts +0 -31
- package/docs/README_camoufox_chinese.md +0 -141
- package/docs/USAGE_V3.md +0 -163
- package/docs/arch/OCR_MACOS_PLUGIN.md +0 -39
- package/docs/arch/PORTS.md +0 -40
- package/docs/arch/REGRESSION_CHECKLIST.md +0 -121
- package/docs/arch/SEARCH_GATE.md +0 -224
- package/docs/arch/VIEWPORT_SAFETY.md +0 -182
- package/docs/arch/XIAOHONGSHU_OFFLINE_MOCK_DESIGN.md +0 -267
- package/docs/xiaohongshu-container-driven-summary.md +0 -221
- package/docs/xiaohongshu-full-collect-runbook.md +0 -134
- package/docs/xiaohongshu-next-steps.md +0 -228
- package/docs/xiaohongshu-quickstart.md +0 -73
- package/docs/xiaohongshu-workflow-summary.md +0 -227
- package/modules/container-registry/tests/container-registry.test.ts +0 -16
- package/modules/logging/tests/logging.test.ts +0 -38
- package/modules/operations/tests/operations.test.ts +0 -22
- package/modules/operations/tests/viewport-filter.test.ts +0 -161
- package/modules/operations/tests/visible-only.test.ts +0 -250
- package/modules/session-manager/tests/session-manager.test.ts +0 -23
- package/modules/state/src/atomic-json.test.ts +0 -30
- package/modules/state/src/paths.test.ts +0 -59
- package/modules/state/src/xiaohongshu-collect-state.test.ts +0 -259
- package/modules/workflow/blocks/AnchorVerificationBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/AnchorVerificationBlock.js.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.js.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.js.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.js.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.js.map +0 -1
- package/modules/workflow/blocks/helpers/downloadPaths.test.ts +0 -62
- package/modules/workflow/blocks/helpers/mergeXhsMarkdown.test.ts +0 -121
- package/modules/workflow/blocks/helpers/operationLogger.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/operationLogger.js.map +0 -1
- package/modules/workflow/blocks/helpers/persistedNotes.test.ts +0 -268
- package/modules/workflow/blocks/helpers/searchPageState.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/searchPageState.js.map +0 -1
- package/modules/workflow/blocks/helpers/targetCountMode.test.ts +0 -29
- package/modules/workflow/blocks/helpers/xhsCliArgs.test.ts +0 -75
- package/modules/workflow/tests/smartReply.test.ts +0 -32
- package/modules/xiaohongshu/app/src/blocks/Phase3Interact.matcher.test.ts +0 -33
- package/modules/xiaohongshu/app/src/utils/__tests__/checkpoints.test.ts +0 -141
- package/modules/xiaohongshu/app/tests/commentMatchDsl.test.ts +0 -50
- package/modules/xiaohongshu/app/tests/commentMatcher.test.ts +0 -46
- package/modules/xiaohongshu/app/tests/sharding.test.ts +0 -31
- package/package-scripts.json +0 -8
- package/runtime/infra/utils/README.md +0 -13
- package/runtime/infra/utils/scripts/README.md +0 -0
- package/runtime/infra/utils/scripts/development/eval-in-session.mjs +0 -40
- package/runtime/infra/utils/scripts/development/highlight-search-containers.mjs +0 -35
- package/runtime/infra/utils/scripts/service/kill-port.mjs +0 -24
- package/runtime/infra/utils/scripts/service/start-api.mjs +0 -39
- package/runtime/infra/utils/scripts/service/start-browser-service.mjs +0 -106
- package/runtime/infra/utils/scripts/service/stop-api.mjs +0 -18
- package/runtime/infra/utils/scripts/service/stop-browser-service.mjs +0 -104
- package/runtime/infra/utils/scripts/test-services.mjs +0 -94
- package/services/shared/heartbeat.test.ts +0 -102
- package/services/unified-api/__tests__/task-state.test.ts +0 -95
- package/sitecustomize.py +0 -19
- package/tests/README.md +0 -194
- package/tests/e2e/workflows/weibo-feed-extraction.test.ts +0 -171
- package/tests/fixtures/data/container-definitions.json +0 -67
- package/tests/fixtures/pages/simple-page.html +0 -69
- package/tests/integration/01-test-container-match.mjs +0 -188
- package/tests/integration/02-test-dom-branch.mjs +0 -161
- package/tests/integration/03-test-container-operation-system.mjs +0 -91
- package/tests/integration/05-test-container-lifecycle-events.mjs +0 -224
- package/tests/integration/05-test-container-lifecycle-with-events.mjs +0 -250
- package/tests/integration/06-test-container-dom-tree-drawing.mjs +0 -256
- package/tests/integration/07-test-weibo-container-lifecycle.mjs +0 -355
- package/tests/integration/08-test-weibo-feed-workflow.test.mjs +0 -164
- package/tests/integration/10-test-visual-analyzer.mjs +0 -312
- package/tests/integration/11-test-visual-loop.mjs +0 -284
- package/tests/integration/12-test-simple-visual-loop.mjs +0 -242
- package/tests/integration/13-test-visual-robust.mjs +0 -185
- package/tests/integration/14-test-visual-highlight-loop.mjs +0 -271
- package/tests/integration/inspect-page.mjs +0 -50
- package/tests/integration/run-all-tests.mjs +0 -95
- package/tests/patch_verification/CODEX_PATCH_TEST.md +0 -103
- package/tests/patch_verification/PHASE2_ANALYSIS.md +0 -179
- package/tests/patch_verification/PHASE2_OPTIMIZATION_REPORT.md +0 -55
- package/tests/patch_verification/PHASE2_TO_PHASE4_SUMMARY.md +0 -126
- package/tests/patch_verification/QUICK_TEST_SEQUENCE.md +0 -262
- package/tests/patch_verification/README.md +0 -143
- package/tests/patch_verification/RUN_TESTS.md +0 -60
- package/tests/patch_verification/TEST_EXECUTION.md +0 -99
- package/tests/patch_verification/TEST_PLAN.md +0 -328
- package/tests/patch_verification/TEST_RESULTS.md +0 -34
- package/tests/patch_verification/TOOL_TEST_PLAN.md +0 -48
- package/tests/patch_verification/run-tool-test.mjs +0 -121
- package/tests/patch_verification/temp_test_files/test01.txt +0 -1
- package/tests/patch_verification/temp_test_files/test02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test02_gnu.txt +0 -3
- package/tests/patch_verification/temp_test_files/test03.txt +0 -1
- package/tests/patch_verification/temp_test_files/test03_multiline.txt +0 -5
- package/tests/patch_verification/temp_test_files/test04_function.ts +0 -5
- package/tests/patch_verification/temp_test_files/test05_import.ts +0 -4
- package/tests/patch_verification/temp_test_files/test06_special_chars.txt +0 -4
- package/tests/patch_verification/temp_test_files/test07_indentation.ts +0 -5
- package/tests/patch_verification/temp_test_files/test08_mismatch.txt +0 -1
- package/tests/patch_verification/temp_test_files/test_add_02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test_simple.txt +0 -1
- package/tests/runner/TestReporter.mjs +0 -57
- package/tests/runner/TestRunner.mjs +0 -244
- package/tests/unit/commands/profile.test.mjs +0 -10
- package/tests/unit/container/change-notifier.test.mjs +0 -181
- package/tests/unit/lifecycle/session-registry.test.mjs +0 -135
- package/tests/unit/operations/registry.test.ts +0 -73
- package/tests/unit/utils/browser-service.test.mjs +0 -153
- package/tests/unit/utils/config.test.mjs +0 -166
- package/tests/unit/utils/fingerprint.test.mjs +0 -166
- package/tsconfig.json +0 -31
- package/tsconfig.services.json +0 -26
- /package/apps/desktop-console/{src → dist}/renderer/index.html +0 -0
- /package/apps/desktop-console/{src/renderer/tabs → dist/renderer}/run.mts +0 -0
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { parseHTML } from 'linkedom';
|
|
4
|
-
|
|
5
|
-
import { createViewportFilter } from '../src/utils/visibility.js';
|
|
6
|
-
|
|
7
|
-
function installDom(html: string, viewport: { width: number; height: number } = { width: 800, height: 600 }) {
|
|
8
|
-
const { window, document } = parseHTML(html);
|
|
9
|
-
|
|
10
|
-
(globalThis as any).window = window;
|
|
11
|
-
(globalThis as any).document = document;
|
|
12
|
-
(globalThis as any).Element = window.Element;
|
|
13
|
-
(globalThis as any).HTMLElement = window.HTMLElement;
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(window, 'innerWidth', { value: viewport.width, configurable: true });
|
|
16
|
-
Object.defineProperty(window, 'innerHeight', { value: viewport.height, configurable: true });
|
|
17
|
-
|
|
18
|
-
if (typeof (document as any).elementFromPoint !== 'function') {
|
|
19
|
-
(document as any).elementFromPoint = (): Element | null => null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return { window, document };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function setRect(el: Element, rect: { left: number; top: number; right: number; bottom: number }) {
|
|
26
|
-
const width = rect.right - rect.left;
|
|
27
|
-
const height = rect.bottom - rect.top;
|
|
28
|
-
(el as any).getBoundingClientRect = () => ({
|
|
29
|
-
...rect,
|
|
30
|
-
x: rect.left,
|
|
31
|
-
y: rect.top,
|
|
32
|
-
width,
|
|
33
|
-
height,
|
|
34
|
-
toJSON() {
|
|
35
|
-
return this;
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
test('fully visible element passes fullyVisible check', async () => {
|
|
41
|
-
const { document } = installDom(`<div id="a">A</div>`);
|
|
42
|
-
|
|
43
|
-
// Fully inside viewport
|
|
44
|
-
setRect(document.getElementById('a')!, { left: 10, top: 10, right: 100, bottom: 100 });
|
|
45
|
-
|
|
46
|
-
const filter = createViewportFilter();
|
|
47
|
-
const result = filter({
|
|
48
|
-
selector: '#a',
|
|
49
|
-
index: 0,
|
|
50
|
-
visibleOnly: false,
|
|
51
|
-
fullyVisible: true,
|
|
52
|
-
anchor: null,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
assert.equal(result.fullyVisible, true);
|
|
56
|
-
assert.equal(result.partiallyVisible, true);
|
|
57
|
-
assert.notEqual(result.clickPoint, null);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('partially visible element fails fullyVisible but passes partiallyVisible', async () => {
|
|
61
|
-
const { document } = installDom(`<div id="b">B</div>`);
|
|
62
|
-
|
|
63
|
-
// Partially outside bottom
|
|
64
|
-
setRect(document.getElementById('b')!, { left: 10, top: 500, right: 100, bottom: 700 });
|
|
65
|
-
|
|
66
|
-
const filter = createViewportFilter();
|
|
67
|
-
const result = filter({
|
|
68
|
-
selector: '#b',
|
|
69
|
-
index: 0,
|
|
70
|
-
visibleOnly: false,
|
|
71
|
-
fullyVisible: true,
|
|
72
|
-
anchor: null,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
assert.equal(result.fullyVisible, false);
|
|
76
|
-
assert.equal(result.partiallyVisible, true);
|
|
77
|
-
assert.equal(result.clickPoint, null);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('off-screen element fails both checks', async () => {
|
|
81
|
-
const { document } = installDom(`<div id="c">C</div>`);
|
|
82
|
-
|
|
83
|
-
// Completely outside viewport
|
|
84
|
-
setRect(document.getElementById('c')!, { left: 1000, top: 2000, right: 1100, bottom: 2100 });
|
|
85
|
-
|
|
86
|
-
const filter = createViewportFilter();
|
|
87
|
-
const result = filter({
|
|
88
|
-
selector: '#c',
|
|
89
|
-
index: 0,
|
|
90
|
-
visibleOnly: false,
|
|
91
|
-
fullyVisible: true,
|
|
92
|
-
anchor: null,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
assert.equal(result.fullyVisible, false);
|
|
96
|
-
assert.equal(result.partiallyVisible, false);
|
|
97
|
-
assert.equal(result.element, null);
|
|
98
|
-
assert.equal(result.clickPoint, null);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('anchor verification passes when hit matches element', async () => {
|
|
102
|
-
const { document } = installDom(`<div id="d">D</div>`);
|
|
103
|
-
|
|
104
|
-
setRect(document.getElementById('d')!, { left: 10, top: 10, right: 100, bottom: 100 });
|
|
105
|
-
|
|
106
|
-
(document as any).elementFromPoint = () => document.getElementById('d');
|
|
107
|
-
|
|
108
|
-
const filter = createViewportFilter();
|
|
109
|
-
const result = filter({
|
|
110
|
-
selector: '#d',
|
|
111
|
-
index: 0,
|
|
112
|
-
visibleOnly: false,
|
|
113
|
-
fullyVisible: true,
|
|
114
|
-
anchor: { x: 50, y: 50 },
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
assert.equal(result.anchorMatch, true);
|
|
118
|
-
assert.notEqual(result.clickPoint, null);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
test('anchor verification fails when hit does not match element', async () => {
|
|
122
|
-
const { document } = installDom(`<div id="e">E</div><div id="f">F</div>`);
|
|
123
|
-
|
|
124
|
-
setRect(document.getElementById('e')!, { left: 10, top: 10, right: 100, bottom: 100 });
|
|
125
|
-
setRect(document.getElementById('f')!, { left: 200, top: 200, right: 300, bottom: 300 });
|
|
126
|
-
|
|
127
|
-
// elementFromPoint returns f instead of e
|
|
128
|
-
(document as any).elementFromPoint = () => document.getElementById('f');
|
|
129
|
-
|
|
130
|
-
const filter = createViewportFilter();
|
|
131
|
-
const result = filter({
|
|
132
|
-
selector: '#e',
|
|
133
|
-
index: 0,
|
|
134
|
-
visibleOnly: false,
|
|
135
|
-
fullyVisible: true,
|
|
136
|
-
anchor: { x: 50, y: 50 },
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
assert.equal(result.anchorMatch, false);
|
|
140
|
-
assert.equal(result.clickPoint?.x, 55);
|
|
141
|
-
assert.equal(result.clickPoint?.y, 55);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test('zero size element fails visibility check', async () => {
|
|
145
|
-
const { document } = installDom(`<div id="g">G</div>`);
|
|
146
|
-
|
|
147
|
-
// Zero size
|
|
148
|
-
setRect(document.getElementById('g')!, { left: 10, top: 10, right: 10, bottom: 10 });
|
|
149
|
-
|
|
150
|
-
const filter = createViewportFilter();
|
|
151
|
-
const result = filter({
|
|
152
|
-
selector: '#g',
|
|
153
|
-
index: 0,
|
|
154
|
-
visibleOnly: false,
|
|
155
|
-
fullyVisible: true,
|
|
156
|
-
anchor: null,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
assert.equal(result.fullyVisible, false);
|
|
160
|
-
assert.equal(result.partiallyVisible, false);
|
|
161
|
-
});
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { parseHTML } from 'linkedom';
|
|
4
|
-
|
|
5
|
-
import { highlightOperation } from '../src/operations/highlight.js';
|
|
6
|
-
import { extractOperation } from '../src/operations/extract.js';
|
|
7
|
-
import { clickOperation } from '../src/operations/click.js';
|
|
8
|
-
import { scrollOperation } from '../src/operations/scroll.js';
|
|
9
|
-
|
|
10
|
-
function installDom(html: string) {
|
|
11
|
-
const { window, document } = parseHTML(html);
|
|
12
|
-
|
|
13
|
-
(globalThis as any).window = window;
|
|
14
|
-
(globalThis as any).document = document;
|
|
15
|
-
(globalThis as any).Element = window.Element;
|
|
16
|
-
(globalThis as any).HTMLElement = window.HTMLElement;
|
|
17
|
-
(globalThis as any).HTMLAnchorElement = window.HTMLAnchorElement;
|
|
18
|
-
(globalThis as any).HTMLImageElement = window.HTMLImageElement;
|
|
19
|
-
|
|
20
|
-
Object.defineProperty(window, 'innerWidth', { value: 800, configurable: true });
|
|
21
|
-
Object.defineProperty(window, 'innerHeight', { value: 600, configurable: true });
|
|
22
|
-
|
|
23
|
-
if (typeof (document as any).elementFromPoint !== 'function') {
|
|
24
|
-
(document as any).elementFromPoint = (): Element | null => null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return { window, document };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function setRect(el: Element, rect: { left: number; top: number; right: number; bottom: number }) {
|
|
31
|
-
const width = rect.right - rect.left;
|
|
32
|
-
const height = rect.bottom - rect.top;
|
|
33
|
-
(el as any).getBoundingClientRect = () => ({
|
|
34
|
-
...rect,
|
|
35
|
-
x: rect.left,
|
|
36
|
-
y: rect.top,
|
|
37
|
-
width,
|
|
38
|
-
height,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
test('highlight supports visibleOnly filtering (overlay mode)', async () => {
|
|
43
|
-
const { window, document } = installDom(`
|
|
44
|
-
<div class="x" id="a">A</div>
|
|
45
|
-
<div class="x" id="b">B</div>
|
|
46
|
-
`);
|
|
47
|
-
|
|
48
|
-
setRect(document.getElementById('a')!, { left: 10, top: 10, right: 110, bottom: 60 });
|
|
49
|
-
setRect(document.getElementById('b')!, { left: 10, top: 2000, right: 110, bottom: 2050 });
|
|
50
|
-
|
|
51
|
-
let highlightCount = 0;
|
|
52
|
-
(window as any).__webautoRuntime = {
|
|
53
|
-
highlight: {
|
|
54
|
-
highlightElements: (els: any[]) => {
|
|
55
|
-
highlightCount = Array.isArray(els) ? els.length : 0;
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const res = await highlightOperation.run(
|
|
61
|
-
{
|
|
62
|
-
page: {
|
|
63
|
-
evaluate: async (fn: any, arg: any) => fn(arg),
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{ selector: '.x', visibleOnly: true, channel: 'test', duration: 1000 },
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
assert.equal(res.success, true);
|
|
70
|
-
assert.equal(res.mode, 'overlay');
|
|
71
|
-
assert.equal(res.count, 1);
|
|
72
|
-
assert.equal(highlightCount, 1);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('extract supports visibleOnly filtering', async () => {
|
|
76
|
-
const { document } = installDom(`
|
|
77
|
-
<div class="item" id="a">A</div>
|
|
78
|
-
<div class="item" id="b">B</div>
|
|
79
|
-
`);
|
|
80
|
-
|
|
81
|
-
setRect(document.getElementById('a')!, { left: 10, top: 10, right: 110, bottom: 60 });
|
|
82
|
-
setRect(document.getElementById('b')!, { left: 10, top: 2000, right: 110, bottom: 2050 });
|
|
83
|
-
|
|
84
|
-
const res = await extractOperation.run(
|
|
85
|
-
{
|
|
86
|
-
page: {
|
|
87
|
-
evaluate: async (fn: any, arg: any) => fn(arg),
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{ selector: '.item', include_text: true, max_items: 10, visibleOnly: true },
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
assert.equal(res.success, true);
|
|
94
|
-
assert.equal(res.count, 1);
|
|
95
|
-
assert.equal(res.extracted?.[0]?.text, 'A');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('click supports visibleOnly filtering and uses system mouse', async () => {
|
|
99
|
-
const { document } = installDom(`
|
|
100
|
-
<div class="btn" id="a"><span class="inner">A</span></div>
|
|
101
|
-
<div class="btn" id="b"><span class="inner">B</span></div>
|
|
102
|
-
`);
|
|
103
|
-
|
|
104
|
-
const a = document.getElementById('a')!;
|
|
105
|
-
const b = document.getElementById('b')!;
|
|
106
|
-
const aInner = a.querySelector('.inner') as Element;
|
|
107
|
-
const bInner = b.querySelector('.inner') as Element;
|
|
108
|
-
setRect(a, { left: 100, top: 100, right: 300, bottom: 200 });
|
|
109
|
-
setRect(aInner, { left: 100, top: 100, right: 300, bottom: 200 });
|
|
110
|
-
setRect(b, { left: 100, top: 2000, right: 300, bottom: 2100 });
|
|
111
|
-
setRect(bInner, { left: 100, top: 2000, right: 300, bottom: 2100 });
|
|
112
|
-
|
|
113
|
-
// Make elementFromPoint always hit within the visible element.
|
|
114
|
-
(document as any).elementFromPoint = () => aInner;
|
|
115
|
-
|
|
116
|
-
let clicked: { x: number; y: number } | null = null;
|
|
117
|
-
const res = await clickOperation.run(
|
|
118
|
-
{
|
|
119
|
-
page: {
|
|
120
|
-
evaluate: async (fn: any, arg: any) => fn(arg),
|
|
121
|
-
},
|
|
122
|
-
systemInput: {
|
|
123
|
-
mouseClick: async (x: number, y: number) => {
|
|
124
|
-
clicked = { x, y };
|
|
125
|
-
return { success: true };
|
|
126
|
-
},
|
|
127
|
-
mouseMove: async () => ({ success: true }),
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
{ selector: '.btn', index: 0, target: '.inner', useSystemMouse: true, visibleOnly: true },
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
assert.equal(res.success, true);
|
|
134
|
-
assert.deepEqual(clicked, { x: 200, y: 150 });
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
test('click supports protocol mode without system mouse', async () => {
|
|
140
|
-
const { document } = installDom(`
|
|
141
|
-
<div class="btn" id="a"><span class="inner">A</span></div>
|
|
142
|
-
`);
|
|
143
|
-
|
|
144
|
-
const a = document.getElementById('a')!;
|
|
145
|
-
const aInner = a.querySelector('.inner') as Element;
|
|
146
|
-
setRect(a, { left: 100, top: 100, right: 300, bottom: 200 });
|
|
147
|
-
setRect(aInner, { left: 100, top: 100, right: 300, bottom: 200 });
|
|
148
|
-
(document as any).elementFromPoint = () => aInner;
|
|
149
|
-
|
|
150
|
-
let clicked: { x: number; y: number } | null = null;
|
|
151
|
-
const res = await clickOperation.run(
|
|
152
|
-
{
|
|
153
|
-
page: {
|
|
154
|
-
evaluate: async (fn: any, arg: any) => fn(arg),
|
|
155
|
-
mouse: {
|
|
156
|
-
click: async (x: number, y: number) => {
|
|
157
|
-
clicked = { x, y };
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
} as any,
|
|
161
|
-
},
|
|
162
|
-
{ selector: '.btn', index: 0, target: '.inner', useSystemMouse: false, visibleOnly: true },
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
assert.equal(res.success, true);
|
|
166
|
-
assert.equal(res.inputMode, 'protocol');
|
|
167
|
-
assert.deepEqual(clicked, { x: 200, y: 150 });
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test('scroll moves mouse into selector before wheel', async () => {
|
|
171
|
-
const { document } = installDom(`
|
|
172
|
-
<div class="scroller" id="s"><div id="child"></div></div>
|
|
173
|
-
`);
|
|
174
|
-
|
|
175
|
-
const s = document.getElementById('s')!;
|
|
176
|
-
const child = document.getElementById('child')!;
|
|
177
|
-
setRect(s, { left: 100, top: 100, right: 500, bottom: 500 });
|
|
178
|
-
setRect(child, { left: 120, top: 120, right: 140, bottom: 140 });
|
|
179
|
-
|
|
180
|
-
(document as any).elementFromPoint = () => child;
|
|
181
|
-
|
|
182
|
-
let moved: { x: number; y: number } | null = null;
|
|
183
|
-
let wheel: { dx: number; dy: number } | null = null;
|
|
184
|
-
|
|
185
|
-
const res = await scrollOperation.run(
|
|
186
|
-
{
|
|
187
|
-
page: {
|
|
188
|
-
evaluate: async (fn: any, arg: any) => fn(arg),
|
|
189
|
-
keyboard: undefined,
|
|
190
|
-
},
|
|
191
|
-
systemInput: {
|
|
192
|
-
mouseMove: async (x: number, y: number) => {
|
|
193
|
-
moved = { x, y };
|
|
194
|
-
return { success: true };
|
|
195
|
-
},
|
|
196
|
-
mouseWheel: async (dx: number, dy: number) => {
|
|
197
|
-
wheel = { dx, dy };
|
|
198
|
-
return { success: true };
|
|
199
|
-
},
|
|
200
|
-
mouseClick: async () => ({ success: true }),
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
{ selector: '.scroller', direction: 'down', distance: 600 },
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
assert.equal(res.success, true);
|
|
207
|
-
// We should move near the top-middle (top + pad=24), not the center.
|
|
208
|
-
assert.deepEqual(moved, { x: 300, y: 124 });
|
|
209
|
-
assert.deepEqual(wheel, { dx: 0, dy: 600 });
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
test('scroll supports protocol mode without system wheel', async () => {
|
|
214
|
-
const { document } = installDom(`
|
|
215
|
-
<div class="scroller" id="s"><div id="child"></div></div>
|
|
216
|
-
`);
|
|
217
|
-
|
|
218
|
-
const s = document.getElementById('s')!;
|
|
219
|
-
const child = document.getElementById('child')!;
|
|
220
|
-
setRect(s, { left: 100, top: 100, right: 500, bottom: 500 });
|
|
221
|
-
setRect(child, { left: 120, top: 120, right: 140, bottom: 140 });
|
|
222
|
-
|
|
223
|
-
(document as any).elementFromPoint = () => child;
|
|
224
|
-
|
|
225
|
-
let moved: { x: number; y: number } | null = null;
|
|
226
|
-
let wheel: { dx: number; dy: number } | null = null;
|
|
227
|
-
|
|
228
|
-
const res = await scrollOperation.run(
|
|
229
|
-
{
|
|
230
|
-
page: {
|
|
231
|
-
evaluate: async (fn: any, arg: any) => fn(arg),
|
|
232
|
-
keyboard: undefined,
|
|
233
|
-
mouse: {
|
|
234
|
-
move: async (x: number, y: number) => {
|
|
235
|
-
moved = { x, y };
|
|
236
|
-
},
|
|
237
|
-
wheel: async (dx: number, dy: number) => {
|
|
238
|
-
wheel = { dx, dy };
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
} as any,
|
|
242
|
-
},
|
|
243
|
-
{ selector: '.scroller', direction: 'down', distance: 600, useSystemMouse: false },
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
assert.equal(res.success, true);
|
|
247
|
-
assert.equal(res.inputMode, 'protocol');
|
|
248
|
-
assert.deepEqual(moved, { x: 300, y: 124 });
|
|
249
|
-
assert.deepEqual(wheel, { dx: 0, dy: 600 });
|
|
250
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { run as runCli } from '../src/cli.js';
|
|
4
|
-
|
|
5
|
-
test('session-manager cli create/list/delete works in test mode', async () => {
|
|
6
|
-
process.env.SESSION_MANAGER_TEST_MODE = '1';
|
|
7
|
-
|
|
8
|
-
const create = await runCli(['create', '--profile', 'demo', '--url', 'https://example.com']);
|
|
9
|
-
assert.equal(create.success, true);
|
|
10
|
-
assert.equal(create.data.sessionId, 'demo');
|
|
11
|
-
|
|
12
|
-
const list = await runCli(['list']);
|
|
13
|
-
assert.equal(list.success, true);
|
|
14
|
-
assert.equal(list.data.sessions.length, 1);
|
|
15
|
-
|
|
16
|
-
const del = await runCli(['delete', '--profile', 'demo']);
|
|
17
|
-
assert.equal(del.success, true);
|
|
18
|
-
|
|
19
|
-
const listAfter = await runCli(['list']);
|
|
20
|
-
assert.equal(listAfter.data.sessions.length, 0);
|
|
21
|
-
|
|
22
|
-
delete process.env.SESSION_MANAGER_TEST_MODE;
|
|
23
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { promises as fs } from 'node:fs';
|
|
6
|
-
|
|
7
|
-
import { atomicWriteJson, readJsonMaybe } from './atomic-json.js';
|
|
8
|
-
|
|
9
|
-
test('readJsonMaybe returns null when file missing', async () => {
|
|
10
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-atomic-'));
|
|
11
|
-
const p = path.join(root, 'missing.json');
|
|
12
|
-
const v = await readJsonMaybe(p);
|
|
13
|
-
assert.equal(v, null);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('atomicWriteJson writes json and readJsonMaybe reads it back', async () => {
|
|
17
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-atomic-'));
|
|
18
|
-
const p = path.join(root, 'state.json');
|
|
19
|
-
await atomicWriteJson(p, { ok: true, n: 1 });
|
|
20
|
-
const v = await readJsonMaybe<any>(p);
|
|
21
|
-
assert.deepEqual(v, { ok: true, n: 1 });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('readJsonMaybe throws on invalid json', async () => {
|
|
25
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauto-atomic-'));
|
|
26
|
-
const p = path.join(root, 'bad.json');
|
|
27
|
-
await fs.writeFile(p, '{bad json', 'utf8');
|
|
28
|
-
await assert.rejects(async () => readJsonMaybe(p));
|
|
29
|
-
});
|
|
30
|
-
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
import { resolveDownloadRoot, resolveHomeDir, resolvePlatformEnvKeywordDir } from './paths.js';
|
|
6
|
-
|
|
7
|
-
test('resolveHomeDir prefers platform env var when provided', () => {
|
|
8
|
-
const prevHome = process.env.HOME;
|
|
9
|
-
const prevUser = process.env.USERPROFILE;
|
|
10
|
-
try {
|
|
11
|
-
process.env.HOME = '/tmp/homeA';
|
|
12
|
-
process.env.USERPROFILE = 'C:\\Users\\HomeB';
|
|
13
|
-
const home = resolveHomeDir();
|
|
14
|
-
if (process.platform === 'win32') {
|
|
15
|
-
assert.equal(home, 'C:\\Users\\HomeB');
|
|
16
|
-
} else {
|
|
17
|
-
assert.equal(home, '/tmp/homeA');
|
|
18
|
-
}
|
|
19
|
-
} finally {
|
|
20
|
-
if (prevHome == null) delete process.env.HOME;
|
|
21
|
-
else process.env.HOME = prevHome;
|
|
22
|
-
if (prevUser == null) delete process.env.USERPROFILE;
|
|
23
|
-
else process.env.USERPROFILE = prevUser;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('resolveDownloadRoot honors WEBAUTO_DOWNLOAD_ROOT override', () => {
|
|
28
|
-
const prev = process.env.WEBAUTO_DOWNLOAD_ROOT;
|
|
29
|
-
try {
|
|
30
|
-
process.env.WEBAUTO_DOWNLOAD_ROOT = '/tmp/webauto-download';
|
|
31
|
-
assert.equal(resolveDownloadRoot(), '/tmp/webauto-download');
|
|
32
|
-
} finally {
|
|
33
|
-
if (prev == null) delete process.env.WEBAUTO_DOWNLOAD_ROOT;
|
|
34
|
-
else process.env.WEBAUTO_DOWNLOAD_ROOT = prev;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('resolvePlatformEnvKeywordDir joins platform/env/keyword under downloadRoot', () => {
|
|
39
|
-
const p = resolvePlatformEnvKeywordDir({
|
|
40
|
-
downloadRoot: '/tmp/dl',
|
|
41
|
-
platform: 'xiaohongshu',
|
|
42
|
-
env: 'debug',
|
|
43
|
-
keyword: '工作服',
|
|
44
|
-
});
|
|
45
|
-
assert.equal(p, path.join('/tmp/dl', 'xiaohongshu', 'debug', '工作服'));
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('resolvePlatformEnvKeywordDir validates required fields', () => {
|
|
49
|
-
assert.throws(() =>
|
|
50
|
-
resolvePlatformEnvKeywordDir({ downloadRoot: '/tmp/dl', platform: '', env: 'debug', keyword: 'k' }),
|
|
51
|
-
);
|
|
52
|
-
assert.throws(() =>
|
|
53
|
-
resolvePlatformEnvKeywordDir({ downloadRoot: '/tmp/dl', platform: 'x', env: '', keyword: 'k' }),
|
|
54
|
-
);
|
|
55
|
-
assert.throws(() =>
|
|
56
|
-
resolvePlatformEnvKeywordDir({ downloadRoot: '/tmp/dl', platform: 'x', env: 'e', keyword: '' }),
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
|