@lowdefy/server-dev 7.1.0 → 7.2.0
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/client/Inspector.jsx +24 -75
- package/client/Page.jsx +8 -0
- package/client/Routing.jsx +0 -2
- package/client/clientBuildImports.test.mjs +5 -3
- package/client/devStreamConnections.test.mjs +1 -0
- package/client/journeyObserver/startJourneyObserver.test.mjs +11 -11
- package/client/openInEditor/OpenInEditorListener.jsx +36 -29
- package/client/openInEditor/OpenInEditorListener.test.mjs +116 -0
- package/client/{feedback → openInEditor}/elementInspect.js +9 -44
- package/client/openInEditor/findBlockLocation.js +2 -2
- package/client/openInEditor/openInEditorStyles.js +56 -0
- package/client/recorder/createPairingBuffer.test.mjs +27 -9
- package/client/recorder/createRecorder.js +11 -7
- package/client/recorder/createRecorder.test.mjs +9 -9
- package/client/recorder/isPasswordElement.js +41 -0
- package/client/recorder/keyChord.test.mjs +1 -0
- package/{client/recorder/toJsonSafe.js → lib/build/mobileConfig.js} +9 -12
- package/lib/client/auth/AuthConfigured.jsx +75 -48
- package/lib/client/auth/authNotConfiguredParity.test.mjs +1 -0
- package/lib/client/auth/authTemplateSync.test.mjs +1 -0
- package/lib/client/auth/betterAuthSessionContract.test.mjs +2 -1
- package/lib/client/auth/sessionCaller.js +56 -0
- package/lib/client/auth/sessionCaller.test.mjs +78 -0
- package/lib/client/getPagePath.test.mjs +1 -0
- package/lib/client/utils/formatErrorsForCopy.test.mjs +1 -0
- package/lib/client/utils/getErrorBarColor.test.mjs +1 -0
- package/lib/client/utils/usePageConfig.test.mjs +15 -15
- package/lib/configTree/buildConfigTree.test.mjs +6 -8
- package/lib/configTree/collectConfigText.test.mjs +1 -0
- package/lib/configTree/runConfigTreeBuild.mjs +2 -1
- package/lib/configTree/runConfigTreeBuild.skipPluginChecks.test.mjs +11 -11
- package/lib/configTree/runConfigTreeBuild.test.mjs +2 -2
- package/lib/docs/addNestedEndpoints.test.mjs +1 -0
- package/lib/docs/checkAgentFiles.test.mjs +1 -0
- package/lib/docs/checkStepReferences.test.mjs +3 -3
- package/lib/docs/clientErrorStore.test.mjs +4 -4
- package/lib/docs/createBrowserLifecycle.test.mjs +40 -24
- package/lib/docs/createDocsMcpServer.js +195 -138
- package/lib/docs/createDocsMcpServer.test.mjs +331 -25
- package/lib/docs/createDocsMcpServerRunJourney.test.mjs +5 -5
- package/lib/docs/createJourneyActors.chromium.test.mjs +3 -3
- package/lib/docs/createJourneyActors.test.mjs +4 -4
- package/lib/docs/dataSets/dataSetJourneys.chromium.mongodb.test.mjs +6 -6
- package/lib/docs/dataSets/drainSessionWork.test.mjs +21 -5
- package/lib/docs/dataSets/getDataStore.js +11 -3
- package/lib/docs/dataSets/getDataStore.mongodb.test.mjs +3 -3
- package/lib/docs/dataSets/getDataStore.test.mjs +32 -20
- package/lib/docs/dataSets/mergeCollectionIndexes.test.mjs +1 -0
- package/lib/docs/dataSets/openDataSession.js +4 -2
- package/lib/docs/dataSets/openDataSession.mongodb.test.mjs +25 -7
- package/lib/docs/dataSets/pickDataStorePort.test.mjs +2 -2
- package/lib/docs/dataSets/readDataSession.test.mjs +1 -0
- package/lib/docs/dataSets/readDataSet.test.mjs +1 -0
- package/lib/docs/dataSets/resolveJourneyDataSet.test.mjs +1 -0
- package/lib/docs/dataSets/test/buildTestApp.mjs +1 -1
- package/lib/docs/devEventBus.js +7 -2
- package/lib/docs/devEventBus.test.mjs +12 -10
- package/lib/docs/devToolDefinitions.js +87 -135
- package/lib/docs/device/buildDeviceCommand.js +103 -0
- package/lib/docs/device/buildDeviceCommand.test.mjs +142 -0
- package/lib/docs/device/captureDevice.js +85 -0
- package/lib/docs/device/checkShownPage.js +56 -0
- package/lib/docs/device/createFakePhoneTab.mjs +77 -0
- package/lib/docs/device/deviceAction.js +74 -0
- package/lib/docs/device/deviceTools.test.mjs +604 -0
- package/lib/docs/device/findDeviceTab.js +50 -0
- package/lib/docs/device/findDeviceTarget.js +73 -0
- package/lib/docs/device/injectDevice.js +160 -0
- package/lib/docs/device/listDevices.js +100 -0
- package/lib/docs/device/listDevices.test.mjs +105 -0
- package/lib/docs/device/runDeviceJourney.js +68 -0
- package/lib/docs/device/runDeviceSteps.js +164 -0
- package/lib/docs/device/screenshotDevice.js +68 -0
- package/lib/docs/device/sendDeviceStep.js +52 -0
- package/lib/docs/device/startDevice.js +150 -0
- package/lib/docs/docs.test.mjs +44 -28
- package/lib/docs/docsIndex.test.mjs +1 -0
- package/lib/docs/findConfig.js +3 -4
- package/lib/docs/findPageBlock.js +35 -0
- package/lib/docs/findPageBlock.test.mjs +45 -0
- package/lib/docs/fitResponse.js +18 -17
- package/lib/docs/fitResponse.test.mjs +18 -0
- package/lib/docs/getBrowser.js +3 -3
- package/lib/docs/getBrowser.test.mjs +32 -16
- package/lib/docs/getBuildId.test.mjs +1 -0
- package/lib/docs/getBuildStatus.test.mjs +11 -11
- package/lib/docs/getBuildStatusAfterEdits.test.mjs +8 -8
- package/{src/routes/docs/appMap.js → lib/docs/getConfigDirectory.js} +3 -5
- package/lib/docs/getHazards.js +4 -1
- package/lib/docs/getHazards.test.mjs +9 -7
- package/lib/docs/getOverview.js +20 -42
- package/lib/docs/getOverviewBasePath.test.mjs +1 -0
- package/lib/docs/getStaleStatus.test.mjs +1 -0
- package/lib/docs/inspectState.js +78 -3
- package/lib/docs/inspectState.test.mjs +61 -9
- package/lib/docs/inspectStateFromTab.js +38 -6
- package/lib/docs/inspectStateFromTab.test.mjs +79 -0
- package/lib/docs/inspectStateHeadless.js +98 -34
- package/lib/docs/inspectStateHeadless.test.mjs +17 -5
- package/lib/docs/installHeadlessShell.failure.test.mjs +9 -5
- package/lib/docs/installHeadlessShell.js +5 -2
- package/lib/docs/installHeadlessShell.test.mjs +8 -5
- package/lib/docs/installHeadlessShell.timeout.test.mjs +32 -12
- package/lib/docs/isDeepEqual.js +37 -0
- package/lib/docs/isHeadlessShellIncomplete.test.mjs +1 -0
- package/lib/docs/isPageReady.test.mjs +1 -0
- package/lib/docs/journeyMutantCookie.chromium.test.mjs +3 -3
- package/lib/docs/journeyRunRecording.test.mjs +1 -0
- package/lib/docs/keepEventStreamAlive.test.mjs +1 -0
- package/lib/docs/launchBrowser.test.mjs +8 -8
- package/lib/docs/listTypes.js +58 -8
- package/lib/docs/loadFrameworkHazards.test.mjs +1 -0
- package/lib/docs/matchJourneyRoute.test.mjs +1 -0
- package/lib/docs/observe/createJourneyAppErrors.test.mjs +3 -3
- package/lib/docs/observe/evaluateInvariants.test.mjs +1 -0
- package/lib/docs/observe/hasNoEffect.test.mjs +1 -0
- package/lib/docs/observe/withAppErrors.test.mjs +1 -0
- package/lib/docs/openJourneyEmail.test.mjs +6 -6
- package/lib/docs/pageBuildStatus.test.mjs +6 -6
- package/lib/docs/pollTab.js +100 -0
- package/lib/docs/pollTab.test.mjs +64 -0
- package/lib/docs/rails/authEngineActions.test.mjs +1 -0
- package/lib/docs/rails/authEngineMethods.test.mjs +2 -1
- package/lib/docs/rails/checkAuthActionsRan.test.mjs +5 -5
- package/lib/docs/rails/createDataSetRails.test.mjs +1 -0
- package/lib/docs/rails/findExternalBlocks.test.mjs +1 -0
- package/lib/docs/readJourneyEmailMatch.test.mjs +2 -2
- package/lib/docs/readJourneySession.js +1 -1
- package/lib/docs/reportDevToolFault.js +29 -0
- package/lib/docs/reportDevToolFault.test.mjs +34 -0
- package/lib/docs/requestRestart.test.mjs +1 -0
- package/lib/docs/resolvePageInstance.test.mjs +1 -0
- package/lib/docs/resolveSource.js +2 -2
- package/lib/docs/resolveSource.test.mjs +6 -6
- package/lib/docs/reviewPageBuilds.test.mjs +2 -2
- package/lib/docs/runCheck.test.mjs +3 -3
- package/lib/docs/runCheckChild.js +2 -1
- package/lib/docs/runEndpoint.js +23 -10
- package/lib/docs/runEndpoint.test.mjs +42 -37
- package/lib/docs/runErrorBuffers.test.mjs +1 -0
- package/lib/docs/runJourney.js +21 -1
- package/lib/docs/runJourney.test.mjs +119 -99
- package/lib/docs/runJourneyDataSet.test.mjs +25 -25
- package/lib/docs/runJourneySteps.js +8 -29
- package/lib/docs/runRequest.js +6 -6
- package/lib/docs/runRequest.test.mjs +22 -22
- package/lib/docs/screenshotPage.js +6 -7
- package/lib/docs/screenshotPage.test.mjs +46 -46
- package/lib/docs/screenshotPageClip.test.mjs +10 -10
- package/lib/docs/searchDocs.test.mjs +1 -0
- package/lib/docs/searchIcons.test.mjs +5 -5
- package/lib/docs/selectFinalState.test.mjs +1 -0
- package/lib/docs/serverErrorStore.test.mjs +4 -4
- package/lib/docs/setupTestFixtures.mjs +25 -0
- package/lib/docs/splitSearchTerms.test.mjs +1 -0
- package/lib/docs/tabAvailable.js +1 -1
- package/lib/docs/tabChannel.js +90 -14
- package/lib/docs/tabChannel.test.mjs +40 -15
- package/lib/docs/validateJourneyTimeout.test.mjs +1 -0
- package/lib/docs/validateStateSelection.test.mjs +1 -0
- package/lib/docs/validateViewport.test.mjs +1 -0
- package/lib/docs/waitForBuild.test.mjs +1 -0
- package/lib/docs/withBrowserSlot.test.mjs +5 -5
- package/lib/server/applyDataSetRedirect.test.mjs +2 -2
- package/lib/server/applyDataSetRedirectTenantReach.test.mjs +1 -0
- package/lib/server/applyDataSetRedirectWalled.test.mjs +1 -0
- package/lib/server/auth/getHeadlessUser.js +6 -0
- package/lib/server/auth/getHeadlessUser.test.mjs +13 -2
- package/lib/server/auth/resolveHeadlessUser.test.mjs +1 -0
- package/lib/server/contextMapBudget.test.mjs +3 -3
- package/lib/server/continueJitKeys.test.mjs +1 -0
- package/lib/server/createLowdefyContext.js +5 -1
- package/lib/server/createLowdefyContext.test.mjs +32 -32
- package/lib/server/getClientAddress.test.mjs +2 -2
- package/lib/server/getPageJitEnrichment.test.mjs +1 -0
- package/lib/server/importAppCode.test.mjs +2 -2
- package/lib/server/jitPageBuilder.js +27 -3
- package/lib/server/jitPageBuilder.mobileTypes.test.mjs +65 -0
- package/lib/server/jitPageBuilder.skipPluginChecks.test.mjs +5 -6
- package/lib/server/jitPageBuilder.test.mjs +4 -4
- package/lib/server/journeyCookies.test.mjs +1 -0
- package/lib/server/loadDynamicJsMap.js +10 -1
- package/lib/server/log/createHandleError.js +10 -5
- package/lib/server/log/createHandleError.test.mjs +19 -8
- package/lib/server/log/createLogger.test.mjs +2 -2
- package/lib/server/mutantDataSetWrappers.test.mjs +1 -0
- package/lib/server/mutants/listMutants.test.mjs +1 -0
- package/lib/server/mutants/mutantRuns.test.mjs +1 -0
- package/lib/server/mutants/operators.test.mjs +1 -0
- package/lib/server/pageBuildRecords.test.mjs +1 -0
- package/lib/server/pageCache.test.mjs +1 -0
- package/lib/server/pageRebuilds.test.mjs +3 -3
- package/{src/routes/docs/examples.js → lib/server/pairingHeaders.js} +8 -15
- package/lib/server/pruneJitMaps.test.mjs +1 -0
- package/lib/server/readBuildApiArtifacts.test.mjs +1 -0
- package/lib/server/readInstanceRecord.test.mjs +24 -8
- package/lib/server/readMergedMaps.test.mjs +1 -0
- package/lib/server/recording/errorRecordingStamp.test.mjs +1 -0
- package/lib/server/recording/readRecordingCookie.test.mjs +2 -0
- package/lib/server/recording/servedBuilds.test.mjs +1 -0
- package/lib/server/sinkExternalConnections.test.mjs +6 -6
- package/lib/server/skipStaleMapWrites.test.mjs +12 -12
- package/lib/server/startIdleGc.test.mjs +25 -9
- package/lib/server/testFixtures/importAppCodeTwice.mjs +2 -2
- package/lib/vite/createDevServerExclude.test.mjs +1 -0
- package/manager/getContext.mjs +9 -0
- package/manager/processes/checkPendingPlugins.mjs +49 -0
- package/manager/processes/checkPendingPlugins.test.mjs +107 -0
- package/manager/processes/createIdleChild.mjs +141 -0
- package/manager/processes/createIdleChild.test.mjs +209 -0
- package/manager/processes/initialBuild.mjs +2 -15
- package/manager/processes/initialBuild.test.mjs +8 -40
- package/manager/processes/lowdefyBuild.mjs +7 -4
- package/manager/processes/lowdefyBuild.skipPluginChecks.test.mjs +13 -13
- package/manager/processes/lowdefyBuild.test.mjs +17 -15
- package/manager/processes/restartServer.test.mjs +63 -15
- package/manager/processes/shutdownServer.test.mjs +3 -3
- package/manager/processes/startFirstServer.test.mjs +23 -22
- package/manager/processes/startMailSink.mjs +11 -3
- package/manager/processes/startMailSink.test.mjs +28 -2
- package/manager/processes/startProxy.mjs +158 -27
- package/manager/processes/startProxy.pairing.test.mjs +204 -0
- package/manager/processes/startProxy.test.mjs +127 -2
- package/manager/processes/startServer.mjs +5 -7
- package/manager/processes/startServer.test.mjs +10 -9
- package/manager/processes/syncServer.mjs +31 -4
- package/manager/processes/syncServer.test.mjs +71 -6
- package/manager/processes/waitForDevServer.test.mjs +21 -6
- package/manager/run.mjs +32 -8
- package/manager/utils/BatchChanges.mjs +1 -1
- package/manager/utils/BatchChanges.test.mjs +4 -4
- package/manager/utils/acquireDevInstance.test.mjs +1 -0
- package/manager/utils/checkPairing.mjs +45 -0
- package/manager/utils/checkPairing.test.mjs +53 -0
- package/manager/utils/createBuildActivity.mjs +5 -1
- package/manager/utils/createBuildActivity.test.mjs +2 -2
- package/manager/utils/createChangeSignal.test.mjs +5 -5
- package/manager/utils/createCustomPluginMessagesMap.mjs +8 -3
- package/manager/utils/createCustomPluginTypesMap.mjs +48 -12
- package/manager/utils/createCustomPluginTypesMap.test.mjs +181 -19
- package/manager/utils/createDotPathIgnore.test.mjs +1 -0
- package/manager/utils/createGlobIgnore.mjs +45 -0
- package/manager/utils/createGlobIgnore.test.mjs +58 -0
- package/manager/utils/createGlobWatchPaths.mjs +75 -0
- package/manager/utils/createGlobWatchPaths.test.mjs +67 -0
- package/manager/utils/createIdleGc.test.mjs +31 -15
- package/{src/routes/docs/content.js → manager/utils/createLanPairing.mjs} +14 -13
- package/manager/utils/createLanPairing.test.mjs +46 -0
- package/manager/utils/createRequestActivity.mjs +30 -3
- package/manager/utils/createRequestActivity.test.mjs +76 -22
- package/manager/utils/createServerArtifactTracker.mjs +1 -0
- package/manager/utils/createServerArtifactTracker.test.mjs +1 -0
- package/manager/utils/findBuildFilesOutsideWatch.test.mjs +1 -0
- package/{client/recorder/collectEventActions.js → manager/utils/findSignInCode.mjs} +13 -10
- package/manager/utils/findSignInCode.test.mjs +33 -0
- package/manager/utils/formatLanPairing.mjs +32 -0
- package/manager/utils/formatLanPairing.test.mjs +40 -0
- package/manager/utils/getLanAddress.mjs +83 -0
- package/manager/utils/getLanAddress.test.mjs +70 -0
- package/manager/utils/importFresh.test.mjs +1 -0
- package/{src/routes/docs/icons.js → manager/utils/isLoopbackAddress.mjs} +11 -10
- package/manager/utils/pluginTypeCache.mjs +100 -0
- package/manager/utils/pluginTypeCache.test.mjs +141 -0
- package/manager/utils/pruneRecordings.test.mjs +1 -0
- package/manager/utils/publishBuildDirectory.order.test.mjs +2 -2
- package/manager/utils/publishBuildDirectory.test.mjs +6 -7
- package/manager/utils/readBasePath.test.mjs +1 -0
- package/manager/utils/readManagerVersion.test.mjs +1 -0
- package/manager/utils/readPluginDefinitions.mjs +6 -6
- package/manager/utils/renderTerminalQr.mjs +54 -0
- package/manager/utils/resolveDevAuthUrl.test.mjs +1 -0
- package/manager/utils/setupWatcher.mjs +19 -4
- package/manager/utils/startRecordingPruner.test.mjs +24 -8
- package/manager/utils/waitForChildExit.test.mjs +2 -2
- package/manager/utils/writeBuildStatus.test.mjs +1 -0
- package/manager/watchers/envWatcher.mjs +3 -0
- package/manager/watchers/envWatcher.test.mjs +19 -7
- package/manager/watchers/listServerPluginFiles.mjs +188 -0
- package/manager/watchers/listServerPluginFiles.test.mjs +257 -0
- package/manager/watchers/lowdefyBuildWatcher.mjs +5 -0
- package/manager/watchers/lowdefyBuildWatcher.test.mjs +63 -10
- package/manager/watchers/pluginSourceWatcher.mjs +45 -17
- package/manager/watchers/pluginSourceWatcher.test.mjs +97 -21
- package/manager/watchers/resolveFile.mjs +46 -0
- package/manager/watchers/resolveFile.test.mjs +67 -0
- package/manager/watchers/resolvePackageSpecifier.mjs +127 -0
- package/manager/watchers/resolvePackageSpecifier.test.mjs +151 -0
- package/manager/watchers/restartRequestWatcher.mjs +7 -4
- package/manager/watchers/restartRequestWatcher.test.mjs +43 -6
- package/manager/watchers/selectLocalPluginPackages.test.mjs +1 -0
- package/package.json +50 -49
- package/package.original.json +50 -49
- package/src/app.js +83 -85
- package/src/html/renderDevPage.test.mjs +1 -0
- package/src/lib/getPathSegments.js +16 -1
- package/src/{routes/docs/checkpointsList.js → lib/getRequestSurface.js} +6 -4
- package/src/lib/isTabAnswer.js +32 -0
- package/src/lib/isTabChannelCaller.js +35 -0
- package/src/middleware/apiContext.js +4 -2
- package/src/middleware/createSameOriginGuard.test.mjs +1 -0
- package/src/middleware/errorHandler.js +33 -45
- package/src/middleware/errorHandler.test.mjs +10 -10
- package/src/middleware/isRebindingSafeHost.test.mjs +1 -0
- package/src/middleware/localDevToolsOnly.js +13 -1
- package/src/middleware/localDevToolsOnly.test.mjs +36 -2
- package/src/middleware/noStore.test.mjs +1 -0
- package/src/middleware/staleFlag.test.mjs +1 -0
- package/src/middleware/stampCaller.test.mjs +1 -0
- package/src/routes/agentBearer.test.mjs +183 -0
- package/src/routes/auth.test.mjs +10 -10
- package/src/routes/clientError.js +21 -4
- package/src/routes/clientError.test.mjs +127 -0
- package/src/routes/devInspect.js +6 -51
- package/src/routes/devInspect.test.mjs +128 -3
- package/src/routes/devRecording.js +6 -17
- package/src/routes/devRecording.test.mjs +54 -3
- package/src/routes/docs/buildStatus.test.mjs +6 -6
- package/src/routes/docs/events.test.mjs +4 -4
- package/src/routes/docs/find.js +3 -3
- package/src/routes/docs/journey.test.mjs +8 -8
- package/src/routes/docs/journeyRefusals.test.mjs +9 -9
- package/src/routes/docs/loadDocsRoutes.js +70 -0
- package/src/routes/docs/loadDocsRoutes.test.mjs +110 -0
- package/src/routes/docs/mcp.test.mjs +5 -5
- package/src/routes/docs/mutants.js +7 -0
- package/src/routes/docs/mutants.test.mjs +20 -6
- package/src/routes/docs/parsePathParamsParam.test.mjs +1 -0
- package/src/routes/docs/parseUserParam.test.mjs +1 -0
- package/src/routes/docs/restart.test.mjs +1 -0
- package/src/routes/endpoints.js +24 -0
- package/src/routes/endpointsLink.test.mjs +111 -0
- package/src/routes/endpointsTextAnswer.test.mjs +8 -8
- package/src/routes/jitPage.js +13 -1
- package/src/routes/jitPage.test.mjs +36 -11
- package/src/routes/mcp.js +6 -0
- package/src/routes/mcp.test.mjs +23 -8
- package/src/routes/mcpMemberToken.test.mjs +8 -8
- package/src/routes/mcpProtectedResourceMetadata.test.mjs +2 -2
- package/src/routes/{docs/checkpointsRevert.js → mobileRoot.js} +10 -13
- package/src/routes/mobileRoutes.test.mjs +223 -0
- package/src/routes/mobileSignIn.js +58 -0
- package/src/routes/mobileSignIn.test.mjs +59 -0
- package/src/routes/mobileSignInCallback.js +34 -0
- package/src/routes/mobileSignInCallback.test.mjs +51 -0
- package/src/routes/mountDevPageRoutes.js +10 -2
- package/src/routes/mountDevPageRoutes.test.mjs +25 -1
- package/src/routes/mountMobileWellKnown.js +35 -0
- package/src/routes/mountMobileWellKnown.test.mjs +79 -0
- package/src/routes/mountOauthDiscovery.test.mjs +5 -5
- package/src/routes/normalizeMcpProtocolVersionHeader.test.mjs +1 -0
- package/src/routes/reload.js +101 -20
- package/src/routes/reload.test.mjs +153 -0
- package/src/routes/request.js +1 -22
- package/src/routes/request.test.mjs +7 -24
- package/src/routes/requestBody.test.mjs +14 -27
- package/src/routes/websocket.test.mjs +2 -2
- package/src/routes/wellKnownFallback.test.mjs +2 -2
- package/src/websocket/devWebSocket.test.mjs +12 -12
- package/vite.config.js +13 -1
- package/client/feedback/FeedbackMount.jsx +0 -83
- package/client/feedback/FeedbackOverlay.jsx +0 -904
- package/client/feedback/captureTabScreenshot.js +0 -84
- package/client/feedback/copyToClipboard.js +0 -45
- package/client/feedback/drawAnnotationsSvg.js +0 -119
- package/client/feedback/feedbackStyles.js +0 -304
- package/client/feedback/pinResponsiveImages.js +0 -59
- package/client/feedback/sendFeedback.js +0 -39
- package/client/feedback/useFeedbackToggle.js +0 -70
- package/client/recorder/buildEngineRecord.js +0 -37
- package/client/recorder/buildInteractionRecord.js +0 -64
- package/client/recorder/buildTraceEvent.js +0 -57
- package/client/recorder/buildTraceEvent.test.mjs +0 -81
- package/client/recorder/chunkRecords.js +0 -69
- package/client/recorder/chunkRecords.test.mjs +0 -59
- package/client/recorder/collectEventEndpoints.js +0 -40
- package/client/recorder/collectEventRequests.js +0 -39
- package/client/recorder/createPairingBuffer.js +0 -187
- package/client/recorder/createPasswordRedactor.js +0 -84
- package/client/recorder/createRecordBatcher.js +0 -54
- package/client/recorder/createRecordBatcher.test.mjs +0 -76
- package/client/recorder/createRecordingSession.js +0 -61
- package/client/recorder/createRecordingSession.test.mjs +0 -72
- package/client/recorder/diffStateWrites.js +0 -77
- package/client/recorder/diffStateWrites.test.mjs +0 -66
- package/client/recorder/isEventCall.js +0 -30
- package/client/recorder/jsonType.js +0 -39
- package/client/recorder/sendRecords.js +0 -40
- package/lib/docs/captureAnnotatedScreenshot.js +0 -99
- package/lib/docs/checkpointPaths.js +0 -91
- package/lib/docs/checkpointStore.js +0 -243
- package/lib/docs/checkpointToMocks.js +0 -65
- package/lib/docs/configCheckpoints.test.mjs +0 -156
- package/lib/docs/createConfigCheckpoint.js +0 -92
- package/lib/docs/devMockRegistry.js +0 -68
- package/lib/docs/enrichFeedback.js +0 -71
- package/lib/docs/evalOperator.js +0 -49
- package/lib/docs/evalOperator.test.mjs +0 -157
- package/lib/docs/evalOperatorHeadless.js +0 -159
- package/lib/docs/evalOperatorHeadless.test.mjs +0 -78
- package/lib/docs/evalOperatorInTab.js +0 -49
- package/lib/docs/formatFeedback.js +0 -142
- package/lib/docs/formatFeedback.test.mjs +0 -252
- package/lib/docs/getPluginDoc.js +0 -53
- package/lib/docs/listConfigCheckpoints.js +0 -55
- package/lib/docs/loadState.js +0 -220
- package/lib/docs/revertConfigCheckpoint.js +0 -73
- package/lib/docs/saveAnnotatedScreenshot.js +0 -43
- package/lib/docs/scaffoldPage.js +0 -77
- package/lib/docs/scaffoldPage.test.mjs +0 -97
- package/lib/docs/snapshotState.js +0 -67
- package/lib/docs/stateCheckpoints.test.mjs +0 -443
- package/manager/watchers/listServerSidePackages.mjs +0 -47
- package/manager/watchers/listServerSidePackages.test.mjs +0 -38
- package/src/routes/docs/checkpointsCreate.js +0 -28
- package/src/routes/docs/evalOperator.js +0 -70
- package/src/routes/docs/inspectState.js +0 -59
- package/src/routes/docs/loadState.js +0 -51
- package/src/routes/docs/pluginDoc.js +0 -33
- package/src/routes/docs/plugins.js +0 -23
- package/src/routes/docs/runEndpoint.js +0 -54
- package/src/routes/docs/runEndpoint.test.mjs +0 -165
- package/src/routes/docs/runRequest.js +0 -53
- package/src/routes/docs/runRequest.test.mjs +0 -92
- package/src/routes/docs/schema.js +0 -37
- package/src/routes/docs/screenshot.js +0 -120
- package/src/routes/docs/screenshot.test.mjs +0 -117
- package/src/routes/docs/search.js +0 -40
- package/src/routes/docs/snapshotState.js +0 -50
- package/src/routes/docs/stateCheckpointsList.js +0 -26
- package/src/routes/docs/types.js +0 -33
- package/src/routes/feedback.js +0 -107
- package/src/routes/feedback.test.mjs +0 -204
|
@@ -22,7 +22,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
|
22
22
|
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
23
23
|
import { LoggingMessageNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { vi, expect, test } from 'vitest';
|
|
26
26
|
|
|
27
27
|
import setupTestFixtures from './setupTestFixtures.mjs';
|
|
28
28
|
|
|
@@ -33,50 +33,46 @@ process.chdir(fixtureDir);
|
|
|
33
33
|
|
|
34
34
|
// runJourney needs a browser; mocked so the tool's result shaping (JSON text
|
|
35
35
|
// followed by image blocks) can be asserted without one.
|
|
36
|
-
const mockRunJourney =
|
|
37
|
-
|
|
36
|
+
const mockRunJourney = vi.fn();
|
|
37
|
+
vi.doMock('./runJourney.js', () => ({
|
|
38
38
|
default: mockRunJourney,
|
|
39
|
-
runSteps:
|
|
39
|
+
runSteps: vi.fn(),
|
|
40
40
|
MAIN_ACTOR: 'main',
|
|
41
41
|
}));
|
|
42
|
-
const mockScreenshotPage =
|
|
43
|
-
|
|
42
|
+
const mockScreenshotPage = vi.fn();
|
|
43
|
+
vi.doMock('./screenshotPage.js', () => ({ default: mockScreenshotPage }));
|
|
44
|
+
const mockInspectState = vi.fn();
|
|
45
|
+
vi.doMock('./inspectState.js', () => ({ default: mockInspectState }));
|
|
46
|
+
const mockGetPageConfig = vi.fn();
|
|
47
|
+
vi.doMock('./getPageConfig.js', () => ({ default: mockGetPageConfig }));
|
|
44
48
|
|
|
45
49
|
const { default: createDocsMcpServer, subscribeMcpServerToDevEvents } = await import(
|
|
46
50
|
'./createDocsMcpServer.js'
|
|
47
51
|
);
|
|
48
52
|
const { publish } = await import('./devEventBus.js');
|
|
53
|
+
const { default: createFakePhoneTab, VIEW_PNG } = await import('./device/createFakePhoneTab.mjs');
|
|
54
|
+
const { INSTRUCTIONS } = await import('./devToolDefinitions.js');
|
|
49
55
|
|
|
50
56
|
const EXPECTED_TOOLS = [
|
|
51
|
-
'lowdefy_overview',
|
|
52
57
|
'lowdefy_list_types',
|
|
53
|
-
'lowdefy_list_plugins',
|
|
54
58
|
'lowdefy_get_schema',
|
|
55
59
|
'lowdefy_get_examples',
|
|
56
60
|
'lowdefy_get_doc',
|
|
57
61
|
'lowdefy_search_docs',
|
|
58
62
|
'lowdefy_search_icons',
|
|
59
|
-
'lowdefy_get_plugin_doc',
|
|
60
63
|
'lowdefy_build_status',
|
|
61
64
|
'lowdefy_check',
|
|
62
65
|
'lowdefy_get_page_config',
|
|
63
66
|
'lowdefy_find_config',
|
|
64
67
|
'lowdefy_screenshot_page',
|
|
65
68
|
'lowdefy_run_journey',
|
|
66
|
-
'lowdefy_scaffold_page',
|
|
67
69
|
'lowdefy_inspect_state',
|
|
68
|
-
'lowdefy_eval_operator',
|
|
69
70
|
'lowdefy_run_request',
|
|
70
71
|
'lowdefy_run_endpoint',
|
|
71
72
|
'lowdefy_restart',
|
|
72
73
|
'lowdefy_app_map',
|
|
73
|
-
'lowdefy_checkpoint',
|
|
74
|
-
'lowdefy_revert_checkpoint',
|
|
75
|
-
'lowdefy_snapshot_state',
|
|
76
|
-
'lowdefy_load_state',
|
|
77
|
-
'lowdefy_list_state_checkpoints',
|
|
78
|
-
'lowdefy_checkpoint_to_mocks',
|
|
79
74
|
'lowdefy_journey_session',
|
|
75
|
+
'lowdefy_device',
|
|
80
76
|
];
|
|
81
77
|
|
|
82
78
|
async function connectClient() {
|
|
@@ -156,7 +152,9 @@ test('MCP server exposes instructions teaching the feedback loop', async () => {
|
|
|
156
152
|
const client = await connectClient();
|
|
157
153
|
const instructions = client.getInstructions();
|
|
158
154
|
expect(instructions).toContain('lowdefy_build_status');
|
|
159
|
-
expect(instructions).toContain('
|
|
155
|
+
expect(instructions).toContain('Never guess a type name');
|
|
156
|
+
expect(instructions).toContain('wait: true');
|
|
157
|
+
expect(instructions).toContain('STALE:');
|
|
160
158
|
await client.close();
|
|
161
159
|
});
|
|
162
160
|
|
|
@@ -184,8 +182,6 @@ test('MCP tools that render a page headless advertise an optional user parameter
|
|
|
184
182
|
'lowdefy_screenshot_page',
|
|
185
183
|
'lowdefy_run_journey',
|
|
186
184
|
'lowdefy_inspect_state',
|
|
187
|
-
'lowdefy_eval_operator',
|
|
188
|
-
'lowdefy_load_state',
|
|
189
185
|
'lowdefy_run_request',
|
|
190
186
|
'lowdefy_run_endpoint',
|
|
191
187
|
].forEach((name) => {
|
|
@@ -201,14 +197,12 @@ test('MCP tools that act as someone take one user option and share one sentence
|
|
|
201
197
|
const client = await connectClient();
|
|
202
198
|
const { tools } = await client.listTools();
|
|
203
199
|
const sentence =
|
|
204
|
-
'Pass user to act as someone
|
|
200
|
+
'Pass user (and data) to act as someone, in the forms the server instructions give.';
|
|
205
201
|
|
|
206
202
|
[
|
|
207
203
|
'lowdefy_screenshot_page',
|
|
208
204
|
'lowdefy_run_journey',
|
|
209
205
|
'lowdefy_inspect_state',
|
|
210
|
-
'lowdefy_eval_operator',
|
|
211
|
-
'lowdefy_load_state',
|
|
212
206
|
'lowdefy_run_request',
|
|
213
207
|
'lowdefy_run_endpoint',
|
|
214
208
|
].forEach((name) => {
|
|
@@ -273,6 +267,137 @@ test('MCP lowdefy_screenshot_page advertises steps and urlQuery, and passes them
|
|
|
273
267
|
await client.close();
|
|
274
268
|
});
|
|
275
269
|
|
|
270
|
+
// Every agent session pays for the tool list and the instructions before it
|
|
271
|
+
// does any work, so growing either past these is a deliberate change. The
|
|
272
|
+
// phone tools (lowdefy_device and the device parameters) take about 1,900 of it.
|
|
273
|
+
test('MCP tools/list stays at most 25,500 characters and the instructions at most 2,500', async () => {
|
|
274
|
+
const client = await connectClient();
|
|
275
|
+
const { tools } = await client.listTools();
|
|
276
|
+
expect(JSON.stringify(tools).length).toBeLessThanOrEqual(25500);
|
|
277
|
+
expect(INSTRUCTIONS.length).toBeLessThanOrEqual(2500);
|
|
278
|
+
expect(client.getInstructions()).toEqual(INSTRUCTIONS);
|
|
279
|
+
await client.close();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('MCP lowdefy_get_page_config returns a small page inline as compact JSON', async () => {
|
|
283
|
+
mockGetPageConfig.mockResolvedValue({ id: 'home', type: 'Box' });
|
|
284
|
+
const client = await connectClient();
|
|
285
|
+
|
|
286
|
+
const result = await client.callTool({
|
|
287
|
+
name: 'lowdefy_get_page_config',
|
|
288
|
+
arguments: { pageId: 'home' },
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
expect(result.content[0].text).toEqual('{"page":{"id":"home","type":"Box"}}');
|
|
292
|
+
await client.close();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test('MCP lowdefy_get_page_config writes a page over the cap to a file and says so', async () => {
|
|
296
|
+
const page = { id: 'big', type: 'Box', properties: { html: 'x'.repeat(41000) } };
|
|
297
|
+
mockGetPageConfig.mockResolvedValue(page);
|
|
298
|
+
const client = await connectClient();
|
|
299
|
+
|
|
300
|
+
const result = await client.callTool({
|
|
301
|
+
name: 'lowdefy_get_page_config',
|
|
302
|
+
arguments: { pageId: 'big' },
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
const body = JSON.parse(result.content[0].text);
|
|
306
|
+
expect(body.page).toBeUndefined();
|
|
307
|
+
expect(body.pageChars).toBe(JSON.stringify(page).length);
|
|
308
|
+
expect(body.note).toContain('written in full to pageFile');
|
|
309
|
+
expect(JSON.parse(fs.readFileSync(body.pageFile, 'utf8'))).toEqual(page);
|
|
310
|
+
await client.close();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test('MCP lowdefy_get_page_config returns one block subtree for blockId', async () => {
|
|
314
|
+
const card = {
|
|
315
|
+
blockId: 'card',
|
|
316
|
+
type: 'Card',
|
|
317
|
+
slots: { content: { blocks: [{ blockId: 'title', type: 'Title' }] } },
|
|
318
|
+
};
|
|
319
|
+
mockGetPageConfig.mockResolvedValue({
|
|
320
|
+
id: 'home',
|
|
321
|
+
type: 'Box',
|
|
322
|
+
slots: { content: { blocks: [{ blockId: 'other', type: 'Box' }, card] } },
|
|
323
|
+
});
|
|
324
|
+
const client = await connectClient();
|
|
325
|
+
|
|
326
|
+
const result = await client.callTool({
|
|
327
|
+
name: 'lowdefy_get_page_config',
|
|
328
|
+
arguments: { pageId: 'home', blockId: 'card' },
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
expect(JSON.parse(result.content[0].text)).toEqual({ block: card });
|
|
332
|
+
await client.close();
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
test('MCP lowdefy_get_page_config refuses a blockId the page does not have', async () => {
|
|
336
|
+
mockGetPageConfig.mockResolvedValue({ id: 'home', type: 'Box', slots: {} });
|
|
337
|
+
const client = await connectClient();
|
|
338
|
+
|
|
339
|
+
const result = await client.callTool({
|
|
340
|
+
name: 'lowdefy_get_page_config',
|
|
341
|
+
arguments: { pageId: 'home', blockId: 'missing' },
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
expect(result.isError).toBe(true);
|
|
345
|
+
expect(result.content[0].text).toContain('Block "missing" not found on page "home"');
|
|
346
|
+
await client.close();
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test('MCP lowdefy_get_page_config returns build errors as they are', async () => {
|
|
350
|
+
mockGetPageConfig.mockResolvedValue({ buildError: true, errors: [{ message: 'Bad.' }] });
|
|
351
|
+
const client = await connectClient();
|
|
352
|
+
|
|
353
|
+
const result = await client.callTool({
|
|
354
|
+
name: 'lowdefy_get_page_config',
|
|
355
|
+
arguments: { pageId: 'home', blockId: 'card' },
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
expect(JSON.parse(result.content[0].text)).toEqual({
|
|
359
|
+
buildError: true,
|
|
360
|
+
errors: [{ message: 'Bad.' }],
|
|
361
|
+
});
|
|
362
|
+
await client.close();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test('MCP lowdefy_inspect_state passes a null expression through as an expression', async () => {
|
|
366
|
+
mockInspectState.mockResolvedValue({ value: null, errors: [], reads: [], source: 'headless' });
|
|
367
|
+
const client = await connectClient();
|
|
368
|
+
|
|
369
|
+
const result = await client.callTool({
|
|
370
|
+
name: 'lowdefy_inspect_state',
|
|
371
|
+
arguments: { pageId: 'home', expression: null },
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
const params = mockInspectState.mock.calls.at(-1)[0];
|
|
375
|
+
expect(Object.hasOwn(params, 'expression')).toBe(true);
|
|
376
|
+
expect(params).toMatchObject({
|
|
377
|
+
pageId: 'home',
|
|
378
|
+
expression: null,
|
|
379
|
+
origin: 'http://localhost:3000',
|
|
380
|
+
});
|
|
381
|
+
expect(JSON.parse(result.content[0].text)).toEqual({
|
|
382
|
+
value: null,
|
|
383
|
+
errors: [],
|
|
384
|
+
reads: [],
|
|
385
|
+
source: 'headless',
|
|
386
|
+
});
|
|
387
|
+
await client.close();
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test('MCP lowdefy_inspect_state without expression passes no expression key', async () => {
|
|
391
|
+
mockInspectState.mockResolvedValue({ state: { a: 1 }, source: 'headless' });
|
|
392
|
+
const client = await connectClient();
|
|
393
|
+
|
|
394
|
+
await client.callTool({ name: 'lowdefy_inspect_state', arguments: { pageId: 'home' } });
|
|
395
|
+
|
|
396
|
+
const params = mockInspectState.mock.calls.at(-1)[0];
|
|
397
|
+
expect(Object.hasOwn(params, 'expression')).toBe(false);
|
|
398
|
+
await client.close();
|
|
399
|
+
});
|
|
400
|
+
|
|
276
401
|
test('MCP lowdefy_screenshot_page returns a failed step beside the image', async () => {
|
|
277
402
|
mockScreenshotPage.mockResolvedValue({
|
|
278
403
|
data: 'AAAA',
|
|
@@ -564,7 +689,7 @@ test('MCP lowdefy_run_journey advertises data and the name form of user', async
|
|
|
564
689
|
const { tools } = await client.listTools();
|
|
565
690
|
const { properties } = tools.find((tool) => tool.name === 'lowdefy_run_journey').inputSchema;
|
|
566
691
|
expect(properties.data.type).toEqual('string');
|
|
567
|
-
expect(properties.user.description).toMatch('
|
|
692
|
+
expect(properties.user.description).toMatch('a list of data set user names');
|
|
568
693
|
await client.close();
|
|
569
694
|
});
|
|
570
695
|
|
|
@@ -670,7 +795,7 @@ test('MCP instructions teach lowdefy_run_journey as the way to verify behaviour'
|
|
|
670
795
|
const client = await connectClient();
|
|
671
796
|
const instructions = client.getInstructions();
|
|
672
797
|
expect(instructions).toContain('lowdefy_run_journey');
|
|
673
|
-
expect(instructions).toContain('verify behaviour');
|
|
798
|
+
expect(instructions).toContain('verify its behaviour');
|
|
674
799
|
await client.close();
|
|
675
800
|
});
|
|
676
801
|
|
|
@@ -779,3 +904,184 @@ test('MCP tools/call lowdefy_journey_session lists dev sessions and prints one a
|
|
|
779
904
|
fs.rmSync(configDirectory, { recursive: true, force: true });
|
|
780
905
|
}
|
|
781
906
|
});
|
|
907
|
+
|
|
908
|
+
test('MCP the device tool adds one tool to the 18 the dev server has', async () => {
|
|
909
|
+
const client = await connectClient();
|
|
910
|
+
const { tools } = await client.listTools();
|
|
911
|
+
expect(tools).toHaveLength(19);
|
|
912
|
+
const device = tools.find((tool) => tool.name === 'lowdefy_device');
|
|
913
|
+
expect(device.inputSchema.properties.action.enum).toEqual(['list', 'start', 'inject']);
|
|
914
|
+
expect(device.inputSchema.properties.inject.properties.kind.enum).toEqual([
|
|
915
|
+
'scan',
|
|
916
|
+
'photo',
|
|
917
|
+
'nfc',
|
|
918
|
+
'transcript',
|
|
919
|
+
'location',
|
|
920
|
+
'permission',
|
|
921
|
+
'network',
|
|
922
|
+
'push',
|
|
923
|
+
'share',
|
|
924
|
+
'clear',
|
|
925
|
+
]);
|
|
926
|
+
expect(device.inputSchema.required).toEqual(['action']);
|
|
927
|
+
await client.close();
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
test('MCP tools that can act on a phone advertise an optional device parameter', async () => {
|
|
931
|
+
const client = await connectClient();
|
|
932
|
+
const { tools } = await client.listTools();
|
|
933
|
+
['lowdefy_screenshot_page', 'lowdefy_run_journey', 'lowdefy_inspect_state'].forEach((name) => {
|
|
934
|
+
const tool = tools.find((candidate) => candidate.name === name);
|
|
935
|
+
expect(tool.inputSchema.properties.device.type).toEqual('string');
|
|
936
|
+
expect(tool.inputSchema.required ?? []).not.toContain('device');
|
|
937
|
+
});
|
|
938
|
+
const listTypesTool = tools.find((tool) => tool.name === 'lowdefy_list_types');
|
|
939
|
+
expect(listTypesTool.inputSchema.properties.target.enum).toEqual(['web', 'mobile']);
|
|
940
|
+
await client.close();
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
test('MCP lowdefy_screenshot_page with device captures the phone, not the headless browser', async () => {
|
|
944
|
+
const phone = createFakePhoneTab({
|
|
945
|
+
id: 'mcp-phone',
|
|
946
|
+
device: { shell: '7.1.0', platform: 'ios', app: 'com.lowdefy.dev', paired: true },
|
|
947
|
+
page: { pageId: 'ticket', pathParams: {}, instanceKey: 'page:ticket' },
|
|
948
|
+
});
|
|
949
|
+
const client = await connectClient();
|
|
950
|
+
const result = await client.callTool({
|
|
951
|
+
name: 'lowdefy_screenshot_page',
|
|
952
|
+
arguments: { pageId: 'ticket', device: 'mcp-phone', steps: [{ click: 'save' }] },
|
|
953
|
+
});
|
|
954
|
+
expect(mockScreenshotPage).not.toHaveBeenCalled();
|
|
955
|
+
expect(phone.requests.map(({ event, data }) => [event, data.step])).toEqual([
|
|
956
|
+
['step-request', { click: 'save' }],
|
|
957
|
+
['step-request', { screenshot: null }],
|
|
958
|
+
]);
|
|
959
|
+
const summary = JSON.parse(result.content[0].text);
|
|
960
|
+
expect(summary).toMatchObject({ passed: true, device: 'mcp-phone', capture: 'view' });
|
|
961
|
+
expect(result.content[1]).toEqual({ type: 'image', data: VIEW_PNG, mimeType: 'image/png' });
|
|
962
|
+
phone.close();
|
|
963
|
+
await client.close();
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
test('MCP lowdefy_screenshot_page with device refuses the headless-only params', async () => {
|
|
967
|
+
const client = await connectClient();
|
|
968
|
+
const result = await client.callTool({
|
|
969
|
+
name: 'lowdefy_screenshot_page',
|
|
970
|
+
arguments: { pageId: 'ticket', device: 'mcp-phone', width: 390, user: 'member' },
|
|
971
|
+
});
|
|
972
|
+
expect(result.isError).toBe(true);
|
|
973
|
+
expect(result.content[0].text).toContain('width, user apply to the headless browser only');
|
|
974
|
+
await client.close();
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
test('MCP lowdefy_run_journey with device runs on the phone and returns the journey shape', async () => {
|
|
978
|
+
const phone = createFakePhoneTab({
|
|
979
|
+
id: 'mcp-phone',
|
|
980
|
+
device: { shell: '7.1.0', platform: 'android', app: 'com.lowdefy.dev', paired: true },
|
|
981
|
+
page: { pageId: 'ticket', pathParams: {}, instanceKey: 'page:ticket' },
|
|
982
|
+
});
|
|
983
|
+
const client = await connectClient();
|
|
984
|
+
const result = await client.callTool({
|
|
985
|
+
name: 'lowdefy_run_journey',
|
|
986
|
+
arguments: {
|
|
987
|
+
pageId: 'ticket',
|
|
988
|
+
device: 'mcp-phone',
|
|
989
|
+
steps: [
|
|
990
|
+
{ fill: { blockId: 'title', value: 'Leak' } },
|
|
991
|
+
{ screenshot: 'filled' },
|
|
992
|
+
{ expect: { state: { path: 'title', equals: 'Leak' } } },
|
|
993
|
+
],
|
|
994
|
+
},
|
|
995
|
+
});
|
|
996
|
+
expect(mockRunJourney).not.toHaveBeenCalled();
|
|
997
|
+
const summary = JSON.parse(result.content[0].text);
|
|
998
|
+
expect(summary).toMatchObject({
|
|
999
|
+
pageId: 'ticket',
|
|
1000
|
+
device: 'mcp-phone',
|
|
1001
|
+
passed: true,
|
|
1002
|
+
state: { title: 'Leak' },
|
|
1003
|
+
screenshots: [{ name: 'filled' }],
|
|
1004
|
+
});
|
|
1005
|
+
expect(result.content[1]).toEqual({ type: 'image', data: VIEW_PNG, mimeType: 'image/png' });
|
|
1006
|
+
phone.close();
|
|
1007
|
+
await client.close();
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
test('MCP lowdefy_inspect_state passes the phone to inspectState', async () => {
|
|
1011
|
+
mockInspectState.mockResolvedValue({
|
|
1012
|
+
state: { title: 'Quarterly' },
|
|
1013
|
+
source: 'tab',
|
|
1014
|
+
device: 'mcp-phone',
|
|
1015
|
+
});
|
|
1016
|
+
const client = await connectClient();
|
|
1017
|
+
const result = await client.callTool({
|
|
1018
|
+
name: 'lowdefy_inspect_state',
|
|
1019
|
+
arguments: { pageId: 'ticket', device: 'mcp-phone', source: 'tab' },
|
|
1020
|
+
});
|
|
1021
|
+
expect(mockInspectState.mock.calls.at(-1)[0]).toMatchObject({
|
|
1022
|
+
pageId: 'ticket',
|
|
1023
|
+
device: 'mcp-phone',
|
|
1024
|
+
source: 'tab',
|
|
1025
|
+
});
|
|
1026
|
+
expect(JSON.parse(result.content[0].text)).toMatchObject({ source: 'tab', device: 'mcp-phone' });
|
|
1027
|
+
await client.close();
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
test('MCP lowdefy_device inject forwards the injection to the phone', async () => {
|
|
1031
|
+
const phone = createFakePhoneTab({
|
|
1032
|
+
id: 'mcp-phone',
|
|
1033
|
+
device: { shell: '7.1.0', platform: 'android', app: 'com.lowdefy.dev', paired: true },
|
|
1034
|
+
});
|
|
1035
|
+
const client = await connectClient();
|
|
1036
|
+
const result = await client.callTool({
|
|
1037
|
+
name: 'lowdefy_device',
|
|
1038
|
+
arguments: {
|
|
1039
|
+
action: 'inject',
|
|
1040
|
+
device: 'mcp-phone',
|
|
1041
|
+
inject: { kind: 'scan', value: { data: 'JOB-42' } },
|
|
1042
|
+
},
|
|
1043
|
+
});
|
|
1044
|
+
expect(phone.requests.map(({ event, data }) => [event, data.inject])).toEqual([
|
|
1045
|
+
['inject', { kind: 'scan', value: { data: 'JOB-42' } }],
|
|
1046
|
+
]);
|
|
1047
|
+
expect(JSON.parse(result.content[0].text)).toEqual({
|
|
1048
|
+
device: 'mcp-phone',
|
|
1049
|
+
kind: 'scan',
|
|
1050
|
+
app: { ok: true, kind: 'scan' },
|
|
1051
|
+
});
|
|
1052
|
+
phone.close();
|
|
1053
|
+
await client.close();
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
test('MCP tools/call answers a dev tool that throws as the tool at fault, not the app', async () => {
|
|
1057
|
+
mockScreenshotPage.mockRejectedValueOnce(
|
|
1058
|
+
new TypeError("Cannot read properties of undefined (reading 'page')")
|
|
1059
|
+
);
|
|
1060
|
+
const client = await connectClient();
|
|
1061
|
+
|
|
1062
|
+
const result = await client.callTool({
|
|
1063
|
+
name: 'lowdefy_screenshot_page',
|
|
1064
|
+
arguments: { pageId: 'tickets' },
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
expect(result.isError).toBe(true);
|
|
1068
|
+
expect(result.content[0].text).toBe(
|
|
1069
|
+
"TypeError: Cannot read properties of undefined (reading 'page') (a fault in the dev server's lowdefy_screenshot_page tool, not in the app; the dev server terminal has the stack)"
|
|
1070
|
+
);
|
|
1071
|
+
await client.close();
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
test('MCP tools/call answers an expected refusal from a dev tool with its message alone', async () => {
|
|
1075
|
+
const { UserError } = await import('@lowdefy/errors');
|
|
1076
|
+
mockScreenshotPage.mockRejectedValueOnce(new UserError('pageId must be a string.'));
|
|
1077
|
+
const client = await connectClient();
|
|
1078
|
+
|
|
1079
|
+
const result = await client.callTool({
|
|
1080
|
+
name: 'lowdefy_screenshot_page',
|
|
1081
|
+
arguments: { pageId: 'tickets' },
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
expect(result.isError).toBe(true);
|
|
1085
|
+
expect(result.content[0].text).toBe('pageId must be a string.');
|
|
1086
|
+
await client.close();
|
|
1087
|
+
});
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
18
18
|
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { vi, beforeEach, expect, test } from 'vitest';
|
|
21
21
|
|
|
22
22
|
import setupTestFixtures from './setupTestFixtures.mjs';
|
|
23
23
|
|
|
@@ -26,9 +26,9 @@ process.chdir(fixtureDir);
|
|
|
26
26
|
|
|
27
27
|
// An app served under a basePath: lowdefy_run_journey must hand it to the
|
|
28
28
|
// runner, which counts calls and app errors under it.
|
|
29
|
-
|
|
30
|
-
const mockRunJourney =
|
|
31
|
-
|
|
29
|
+
vi.doMock('../build/config.js', () => ({ default: { basePath: '/app' } }));
|
|
30
|
+
const mockRunJourney = vi.fn();
|
|
31
|
+
vi.doMock('./runJourney.js', () => ({ default: mockRunJourney }));
|
|
32
32
|
|
|
33
33
|
const { default: createDocsMcpServer } = await import('./createDocsMcpServer.js');
|
|
34
34
|
|
|
@@ -42,7 +42,7 @@ async function connectClient() {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
beforeEach(() => {
|
|
45
|
-
|
|
45
|
+
vi.clearAllMocks();
|
|
46
46
|
mockRunJourney.mockResolvedValue({ pageId: 'ticket', passed: true, steps: [], screenshots: [] });
|
|
47
47
|
});
|
|
48
48
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import http from 'node:http';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { vi, afterAll, beforeAll, expect, test } from 'vitest';
|
|
20
20
|
|
|
21
21
|
import pageReadyScript from '../../test-utils/pageReadyScript.mjs';
|
|
22
22
|
|
|
@@ -24,7 +24,7 @@ import pageReadyScript from '../../test-utils/pageReadyScript.mjs';
|
|
|
24
24
|
// routes, so the context-level request listener is exercised as a journey
|
|
25
25
|
// runs it: installed before the first navigation, and still counting after a
|
|
26
26
|
// full page load. Skipped when no Chromium can be launched.
|
|
27
|
-
|
|
27
|
+
vi.doMock('../build/config.js', () => ({ default: {} }));
|
|
28
28
|
|
|
29
29
|
const { getBrowser } = await import('./getBrowser.js');
|
|
30
30
|
const { default: createJourneyActors } = await import('./createJourneyActors.js');
|
|
@@ -97,7 +97,7 @@ beforeAll(async () => {
|
|
|
97
97
|
origin = `http://127.0.0.1:${server.address().port}`;
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
// Closing Chromium on Windows can take longer than
|
|
100
|
+
// Closing Chromium on Windows can take longer than the 10 s hook default.
|
|
101
101
|
afterAll(async () => {
|
|
102
102
|
await browser?.close();
|
|
103
103
|
server.closeAllConnections();
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { vi, beforeEach, expect, test } from 'vitest';
|
|
18
18
|
|
|
19
|
-
const mockOpenPage =
|
|
20
|
-
|
|
19
|
+
const mockOpenPage = vi.fn();
|
|
20
|
+
vi.doMock('./getBrowser.js', () => ({ openPage: mockOpenPage }));
|
|
21
21
|
|
|
22
22
|
const { default: createJourneyActors } = await import('./createJourneyActors.js');
|
|
23
23
|
|
|
24
24
|
beforeEach(() => {
|
|
25
25
|
mockOpenPage.mockReset();
|
|
26
26
|
mockOpenPage.mockImplementation(async ({ user }) => ({
|
|
27
|
-
context: { close:
|
|
27
|
+
context: { close: vi.fn(async () => {}) },
|
|
28
28
|
page: {},
|
|
29
29
|
user,
|
|
30
30
|
}));
|
|
@@ -21,13 +21,13 @@ import path from 'node:path';
|
|
|
21
21
|
import { fileURLToPath } from 'node:url';
|
|
22
22
|
import { promisify } from 'node:util';
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { vi, afterAll, beforeAll, expect, test } from 'vitest';
|
|
25
25
|
import { MongoClient } from 'mongodb';
|
|
26
26
|
|
|
27
27
|
// Data set journeys end to end: a real Chromium drives journeys through the dev server's own
|
|
28
28
|
// journey route, API context, endpoint, detached and websocket handlers and the MongoDB connection
|
|
29
29
|
// plugin, over a build of the fixture app in test/app. Its connections, its module's connection and
|
|
30
|
-
// its auth adapter read the MONGODB_URI secret, pointed at a database of its own on the
|
|
30
|
+
// its auth adapter read the MONGODB_URI secret, pointed at a database of its own on the suite's
|
|
31
31
|
// memory server (MONGO_URL), which stands in for the developer's real database. Journeys on the
|
|
32
32
|
// "shop" data set must reach the data store's session database for every request, module
|
|
33
33
|
// connection, detached call and change stream, must never reach the auth engine, and must leave the
|
|
@@ -35,7 +35,7 @@ import { MongoClient } from 'mongodb';
|
|
|
35
35
|
// small HTML stand-in for a Lowdefy page (window.lowdefy state, blocks as #bl-<id>), so no client
|
|
36
36
|
// bundle is built. Skipped when no Chromium can be launched.
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
vi.setConfig({ testTimeout: 240000, hookTimeout: 240000 });
|
|
39
39
|
|
|
40
40
|
const execFileAsync = promisify(execFile);
|
|
41
41
|
|
|
@@ -100,11 +100,11 @@ const pluginModules = {
|
|
|
100
100
|
};
|
|
101
101
|
pluginFiles.forEach((filePath) => {
|
|
102
102
|
const relative = path.relative(pluginsDirectory, filePath);
|
|
103
|
-
|
|
103
|
+
vi.doMock(filePath, () => pluginModules[relative] ?? { default: {} });
|
|
104
104
|
});
|
|
105
105
|
// The journeys run on a stand-in page, not a built Lowdefy page, so there is no page build to
|
|
106
106
|
// check their step references against; the fixture suite covers the checks.
|
|
107
|
-
|
|
107
|
+
vi.doMock('../checkStepReferences.js', () => ({
|
|
108
108
|
default: async () => {},
|
|
109
109
|
}));
|
|
110
110
|
|
|
@@ -131,7 +131,7 @@ const { default: websocketHandler } = await import('../../../src/routes/websocke
|
|
|
131
131
|
const { handleWebSocketUpgrade } = await import('../../../src/websocket/devWebSocket.js');
|
|
132
132
|
const { getBrowser } = await import('../getBrowser.js');
|
|
133
133
|
// The connection plugin keeps one driver client per URI for the life of the process; the suite
|
|
134
|
-
// closes them so
|
|
134
|
+
// closes them so the test worker can exit. Imported by file: the package does not export it.
|
|
135
135
|
const { closeClients } = await import(
|
|
136
136
|
path.join(
|
|
137
137
|
serverDevDirectory,
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { vi, afterEach, expect, test } from 'vitest';
|
|
18
18
|
|
|
19
19
|
import drainSessionWork from './drainSessionWork.js';
|
|
20
20
|
|
|
21
21
|
afterEach(() => {
|
|
22
|
-
|
|
22
|
+
vi.useRealTimers();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('drainSessionWork resolves true once every promise, including one added while waiting, settles', async () => {
|
|
@@ -49,16 +49,32 @@ test('drainSessionWork resolves true at once with no work', async () => {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
test('drainSessionWork resolves false after the timeout when work never settles', async () => {
|
|
52
|
-
|
|
52
|
+
vi.useFakeTimers({
|
|
53
|
+
toFake: [
|
|
54
|
+
'Date',
|
|
55
|
+
'hrtime',
|
|
56
|
+
'queueMicrotask',
|
|
57
|
+
'requestAnimationFrame',
|
|
58
|
+
'cancelAnimationFrame',
|
|
59
|
+
'requestIdleCallback',
|
|
60
|
+
'cancelIdleCallback',
|
|
61
|
+
'setImmediate',
|
|
62
|
+
'clearImmediate',
|
|
63
|
+
'setInterval',
|
|
64
|
+
'clearInterval',
|
|
65
|
+
'setTimeout',
|
|
66
|
+
'clearTimeout',
|
|
67
|
+
],
|
|
68
|
+
});
|
|
53
69
|
const work = new Set([new Promise(() => {})]);
|
|
54
70
|
const draining = drainSessionWork({ work, timeoutMs: 30000 });
|
|
55
71
|
let done = false;
|
|
56
72
|
draining.then(() => {
|
|
57
73
|
done = true;
|
|
58
74
|
});
|
|
59
|
-
|
|
75
|
+
vi.advanceTimersByTime(29999);
|
|
60
76
|
await Promise.resolve();
|
|
61
77
|
expect(done).toBe(false);
|
|
62
|
-
|
|
78
|
+
vi.advanceTimersByTime(1);
|
|
63
79
|
await expect(draining).resolves.toBe(false);
|
|
64
80
|
});
|
|
@@ -18,10 +18,13 @@ import { MongoClient } from 'mongodb';
|
|
|
18
18
|
import { MongoMemoryReplSet } from 'mongodb-memory-server-core';
|
|
19
19
|
import { DryMongoBinary } from 'mongodb-memory-server-core/lib/util/DryMongoBinary.js';
|
|
20
20
|
|
|
21
|
+
import createLogger from '../../server/log/createLogger.js';
|
|
21
22
|
import pickDataStorePort from './pickDataStorePort.js';
|
|
22
23
|
import registerDataStoreShutdown from './registerDataStoreShutdown.js';
|
|
23
24
|
import removeDataStoreFiles from './removeDataStoreFiles.js';
|
|
24
25
|
|
|
26
|
+
const logger = createLogger();
|
|
27
|
+
|
|
25
28
|
// One store per dev server process. Kept on globalThis because the journey route that opens a data
|
|
26
29
|
// session and the API context that reads it may load as separate module instances (Vite's SSR
|
|
27
30
|
// module graph and Node's), like the journey actor token.
|
|
@@ -35,17 +38,22 @@ async function announceDownload() {
|
|
|
35
38
|
const options = await DryMongoBinary.generateOptions();
|
|
36
39
|
const binary = await DryMongoBinary.locateBinary(options);
|
|
37
40
|
if (binary === undefined) {
|
|
38
|
-
|
|
39
|
-
console.info(`Downloading MongoDB ${options.version} for journey data sets (once).`);
|
|
41
|
+
logger.info(`Downloading MongoDB ${options.version} for journey data sets (once).`);
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
// WiredTiger's cache otherwise grows to half of (RAM - 1 GB), several GB on a laptop. Data sets
|
|
46
|
+
// are small capped snapshots, so a quarter of a GB holds them.
|
|
47
|
+
const CACHE_SIZE_GB = '0.25';
|
|
48
|
+
|
|
43
49
|
// A replica set, not a standalone server: transactions and change streams need one, and the app's
|
|
44
50
|
// own cluster is one. MONGOMS_VERSION, read by mongodb-memory-server, pins the MongoDB version.
|
|
45
51
|
async function startDataStore() {
|
|
46
52
|
await announceDownload();
|
|
47
53
|
const replSet = await MongoMemoryReplSet.create({
|
|
48
|
-
instanceOpts: [
|
|
54
|
+
instanceOpts: [
|
|
55
|
+
{ port: await pickDataStorePort(), args: ['--wiredTigerCacheSizeGB', CACHE_SIZE_GB] },
|
|
56
|
+
],
|
|
49
57
|
replSet: { count: 1, storageEngine: 'wiredTiger' },
|
|
50
58
|
});
|
|
51
59
|
const uri = replSet.getUri();
|