@wenathlan/devthink 2.0.13 → 2.0.15
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/CHANGELOG.md +27 -0
- package/accounts.ts +2087 -0
- package/agent.ts +2331 -0
- package/antigravity.ts +2139 -0
- package/apifreeze.ts +4146 -0
- package/auth.ts +642 -0
- package/background.ts +16837 -0
- package/bridge.ts +2080 -0
- package/build.ts +54 -0
- package/bun.ts +26 -0
- package/capture.ts +1614 -0
- package/checksecrets.ts +72 -0
- package/cjs.ts +9 -0
- package/cli.ts +3500 -0
- package/commands.ts +1101 -0
- package/companion.ts +450 -0
- package/compatibility.ts +37 -0
- package/config.ts +3137 -0
- package/constants.ts +943 -0
- package/core.ts +1473 -0
- package/crossbrowser.ts +1359 -0
- package/dashdone.ts +605 -0
- package/data.ts +943 -0
- package/database.ts +133 -0
- package/debug.ts +850 -0
- package/deno.ts +27 -0
- package/devthink.ts +707 -0
- package/dist/accounts.d.ts +409 -0
- package/dist/agent.d.ts +837 -0
- package/dist/antigravity.d.ts +380 -0
- package/dist/apifreeze.d.ts +113 -0
- package/dist/auth.d.ts +224 -0
- package/{bridge.d.ts → dist/bridge.d.ts} +1 -1
- package/dist/capture.d.ts +595 -0
- package/dist/cjs.d.ts +6 -0
- package/{cli.js → dist/cli.js} +2 -2
- package/dist/commands.d.ts +310 -0
- package/dist/compatibility.d.ts +17 -0
- package/dist/config.d.ts +1853 -0
- package/dist/constants.d.ts +637 -0
- package/dist/core.d.ts +361 -0
- package/dist/data.d.ts +330 -0
- package/dist/database.d.ts +24 -0
- package/dist/debug.d.ts +270 -0
- package/dist/engine.d.ts +74 -0
- package/dist/environments.d.ts +244 -0
- package/dist/evidence.d.ts +277 -0
- package/dist/export.d.ts +311 -0
- package/dist/fingerprint.d.ts +594 -0
- package/dist/flow.d.ts +300 -0
- package/dist/gates.d.ts +103 -0
- package/dist/identity.d.ts +51 -0
- package/dist/ids.d.ts +7 -0
- package/dist/llm.d.ts +652 -0
- package/dist/models.d.ts +1807 -0
- package/dist/net.d.ts +325 -0
- package/dist/neutral.d.ts +41 -0
- package/dist/oauth.d.ts +703 -0
- package/dist/page.d.ts +1166 -0
- package/dist/perf.d.ts +481 -0
- package/dist/plan.d.ts +134 -0
- package/dist/project.d.ts +395 -0
- package/dist/providers.d.ts +37 -0
- package/dist/quota.d.ts +453 -0
- package/dist/recovery.d.ts +621 -0
- package/dist/request.d.ts +1492 -0
- package/dist/run.d.ts +779 -0
- package/dist/runtime.d.ts +212 -0
- package/dist/search.d.ts +375 -0
- package/dist/security.d.ts +534 -0
- package/dist/serve.d.ts +136 -0
- package/dist/session.d.ts +296 -0
- package/dist/storage.d.ts +53 -0
- package/dist/streaming.d.ts +1119 -0
- package/dist/swarm.d.ts +328 -0
- package/dist/tools.d.ts +170 -0
- package/dist/types.d.ts +8357 -0
- package/dist/utils.d.ts +82 -0
- package/dist/version.d.ts +7 -0
- package/dist/versionregistry.d.ts +406 -0
- package/dist/views.d.ts +579 -0
- package/dist/workbenchsession.d.ts +69 -0
- package/dist/workflow.d.ts +649 -0
- package/docs/readme.md +92 -0
- package/docs/schemas/antigravity.json +192 -0
- package/engine.ts +1524 -0
- package/environments.ts +1005 -0
- package/evidence.ts +643 -0
- package/export.ts +889 -0
- package/fingerprint.ts +1458 -0
- package/flow.ts +1190 -0
- package/gates.ts +307 -0
- package/gateway.ts +34 -0
- package/hardening.ts +191 -0
- package/headless.ts +369 -0
- package/http.ts +2110 -0
- package/identity.ts +246 -0
- package/ids.ts +26 -0
- package/index.ts +369 -0
- package/llm.ts +2682 -0
- package/mcp.ts +1835 -0
- package/{memory.js → memory.ts} +3834 -2310
- package/models.ts +3805 -0
- package/modes.ts +43 -0
- package/net.ts +1214 -0
- package/neutral.ts +362 -0
- package/node.ts +26 -0
- package/oauth.ts +2216 -0
- package/offscreen.ts +170 -0
- package/pack.ts +956 -0
- package/package.json +175 -82
- package/page.ts +7824 -0
- package/pagebridge.ts +1116 -0
- package/perf.ts +957 -0
- package/plan.ts +672 -0
- package/plugin.ts +76 -0
- package/{policy.js → policy.ts} +5073 -4679
- package/prisma.config.ts +27 -0
- package/progress.ts +1308 -0
- package/project.ts +1291 -0
- package/protocol.ts +4187 -0
- package/providers.ts +246 -0
- package/quota.ts +1887 -0
- package/recovery.ts +2433 -0
- package/request.ts +4482 -0
- package/run.ts +2135 -0
- package/runtime.ts +526 -0
- package/search.ts +1760 -0
- package/security.ts +1673 -0
- package/serve.ts +419 -0
- package/server.ts +5538 -0
- package/session.ts +1162 -0
- package/storage.ts +182 -0
- package/streaming.ts +4101 -0
- package/swarm.ts +884 -0
- package/sync.ts +56 -0
- package/tests/agentcert.test.ts +128 -0
- package/tests/agentfleet.test.ts +214 -0
- package/tests/agentreview.test.ts +241 -0
- package/tests/agentstream.test.ts +335 -0
- package/tests/agentwork.test.ts +356 -0
- package/tests/apifreeze.test.ts +290 -0
- package/tests/apimap.test.ts +112 -0
- package/tests/approvalgate.test.ts +175 -0
- package/tests/artifactmanifest.test.ts +204 -0
- package/tests/attentionfeed.test.ts +163 -0
- package/tests/backgroundruns.test.ts +100 -0
- package/tests/batchscheduling.test.ts +131 -0
- package/tests/blackboard.test.ts +238 -0
- package/tests/bridge.test.ts +1088 -0
- package/tests/browsercoverage.test.ts +134 -0
- package/tests/browserpolyfills.test.ts +124 -0
- package/tests/build.mjs +1260 -0
- package/tests/clientauth.test.ts +223 -0
- package/tests/clitools.test.ts +578 -0
- package/tests/confirmgates.test.ts +190 -0
- package/tests/containerpack.test.ts +143 -0
- package/tests/controlflow.test.ts +2120 -0
- package/tests/coordination.test.ts +345 -0
- package/tests/copyscreen.test.ts +139 -0
- package/tests/core.test.ts +417 -0
- package/tests/costcert.test.ts +95 -0
- package/tests/crossbrowser.test.ts +115 -0
- package/tests/cspaudit.test.ts +79 -0
- package/tests/dashdone.test.ts +615 -0
- package/tests/datagrid.test.ts +137 -0
- package/tests/doccheck.test.ts +107 -0
- package/tests/dombatch.test.ts +109 -0
- package/tests/emulation.test.ts +282 -0
- package/tests/environments.test.ts +259 -0
- package/tests/evidenceviews.test.ts +88 -0
- package/tests/exporttools.test.ts +185 -0
- package/tests/firefoxprep.test.ts +134 -0
- package/tests/flowlibrary.test.ts +242 -0
- package/tests/flowrun.test.ts +303 -0
- package/tests/forensics.test.ts +439 -0
- package/tests/gateway.test.ts +939 -0
- package/tests/headlesslib.test.ts +171 -0
- package/tests/httpstream.test.ts +277 -0
- package/tests/immutablelog.test.ts +157 -0
- package/tests/inboundguard.test.ts +177 -0
- package/tests/lazyload.test.ts +72 -0
- package/tests/librarymodes.test.ts +623 -0
- package/tests/llm.test.ts +696 -0
- package/tests/manifest.test.ts +226 -0
- package/tests/maskinputs.test.ts +150 -0
- package/tests/matrixverify.test.ts +111 -0
- package/tests/mavenpack.test.ts +75 -0
- package/tests/mcpserver.test.ts +704 -0
- package/tests/memory.test.ts +4155 -0
- package/tests/memorycare.test.ts +230 -0
- package/tests/migrateplan.test.ts +349 -0
- package/tests/minimization.test.ts +414 -0
- package/tests/modelroute.test.ts +112 -0
- package/tests/multiagent.test.ts +440 -0
- package/tests/nativebridge.test.ts +807 -0
- package/tests/navigation.test.ts +284 -0
- package/tests/nugetpack.test.ts +83 -0
- package/tests/orchestration.test.ts +449 -0
- package/tests/originpolicy.test.ts +405 -0
- package/tests/outputcompare.test.ts +97 -0
- package/tests/package.test.ts +91 -0
- package/tests/pagebridge.test.ts +5909 -0
- package/tests/pentest.test.ts +75 -0
- package/tests/perfrecords.test.ts +257 -0
- package/tests/permdiff.test.ts +85 -0
- package/tests/phishguard.test.ts +128 -0
- package/tests/pickerviews.test.ts +155 -0
- package/tests/pipelines.test.ts +381 -0
- package/tests/planlint.test.ts +240 -0
- package/tests/planreview.test.ts +383 -0
- package/tests/platformtargets.test.ts +56 -0
- package/tests/policy.test.ts +8284 -0
- package/tests/portability.test.ts +96 -0
- package/tests/progress.test.ts +1036 -0
- package/tests/promptlibrary.test.ts +116 -0
- package/tests/protocol.test.ts +4793 -0
- package/tests/publishingpipeline.test.ts +314 -0
- package/tests/quickactions.test.ts +164 -0
- package/tests/readiness.test.ts +78 -0
- package/tests/recipes.test.ts +163 -0
- package/tests/redactshots.test.ts +216 -0
- package/tests/registernvidiakeys.ts +51 -0
- package/tests/relayserve.test.ts +304 -0
- package/tests/releasenotes.test.ts +276 -0
- package/tests/resilience.test.ts +467 -0
- package/tests/resourceaware.test.ts +187 -0
- package/tests/runbudget.test.ts +125 -0
- package/tests/runhistory.test.ts +299 -0
- package/tests/runreplay.test.ts +113 -0
- package/tests/runresume.test.ts +184 -0
- package/tests/runstate.test.ts +288 -0
- package/tests/runtimeadapters.test.ts +251 -0
- package/tests/safariskeleton.test.ts +115 -0
- package/tests/sandboxframe.test.ts +196 -0
- package/tests/sbom.test.ts +105 -0
- package/tests/secretvault.test.ts +188 -0
- package/tests/selcache.test.ts +111 -0
- package/tests/sessioninterface.test.ts +791 -0
- package/tests/sessions.test.ts +591 -0
- package/tests/siteprefs.test.ts +228 -0
- package/tests/snapshotdelta.test.ts +165 -0
- package/tests/statusviews.test.ts +237 -0
- package/tests/stepmeter.test.ts +200 -0
- package/tests/streamparse.test.ts +163 -0
- package/tests/stylepruning.test.ts +90 -0
- package/tests/surfaces.test.ts +282 -0
- package/tests/sweep.test.ts +78 -0
- package/tests/syncbridge.test.ts +164 -0
- package/tests/taskqueue.test.ts +206 -0
- package/tests/toolcalls.test.ts +336 -0
- package/tests/toolcatalog.test.ts +201 -0
- package/tests/torture-agent.test.ts +706 -0
- package/tests/torture-auth.test.ts +461 -0
- package/tests/torture-commands.test.ts +895 -0
- package/tests/torture-data.test.ts +923 -0
- package/tests/torture-environments.test.ts +285 -0
- package/tests/torture-export.test.ts +263 -0
- package/tests/torture-http.test.ts +1379 -0
- package/tests/torture-llm.test.ts +808 -0
- package/tests/torture-memory.test.ts +1084 -0
- package/tests/torture-plan.test.ts +829 -0
- package/tests/torture-run.test.ts +626 -0
- package/tests/torture-session.test.ts +928 -0
- package/tests/torture-swarm.test.ts +1245 -0
- package/tests/torture-tools.test.ts +964 -0
- package/tests/torture-workflow.test.ts +2354 -0
- package/tests/tourviews.test.ts +52 -0
- package/tests/transparency.test.ts +147 -0
- package/tests/trigger.test.ts +941 -0
- package/tests/v1sunset.test.ts +428 -0
- package/tests/virtlist.test.ts +94 -0
- package/tests/vision.test.ts +540 -0
- package/tests/vsixpack.test.ts +145 -0
- package/tests/webapi.test.ts +523 -0
- package/tests/workflow.test.ts +1785 -0
- package/tests/workfloweditor.test.ts +759 -0
- package/tests/xpipack.test.ts +128 -0
- package/tools.ts +734 -0
- package/types.ts +9908 -0
- package/umd.ts +9 -0
- package/utils.ts +249 -0
- package/version.ts +8 -0
- package/versionregistry.ts +1310 -0
- package/views.ts +2153 -0
- package/vitest.config.ts +12 -0
- package/web/App.tsx +78 -0
- package/web/README.md +47 -0
- package/web/capacitor.config.ts +46 -0
- package/web/const.ts +19 -0
- package/web/control.shell.tsx +66 -0
- package/web/dashboardpage.ts +554 -0
- package/web/db.ts +493 -0
- package/web/design.html +541 -0
- package/web/gatewayview/Gateway.tsx +345 -0
- package/web/gatewayview/config.ts +1042 -0
- package/web/gatewayview/definition.ts +174 -0
- package/web/icons.ts +15 -0
- package/{manifest.json → web/manifest.json} +1 -1
- package/web/optionspage.ts +691 -0
- package/web/popup.ts +1651 -0
- package/web/schema.prisma +176 -0
- package/web/sidepanel.ts +7941 -0
- package/web/sitemanifest.json +13 -0
- package/web/terminal-ui.tsx +622 -0
- package/web/transparencypage.ts +541 -0
- package/web/vite.config.ts +39 -0
- package/web/workspace.ts +23 -0
- package/workbenchmemory.ts +104 -0
- package/workbenchsession.ts +304 -0
- package/workflow.ts +4495 -0
- package/bridge.d.ts.map +0 -1
- package/bridge.js +0 -1877
- package/bun.d.ts.map +0 -1
- package/bun.js +0 -52329
- package/caps/background.json +0 -712
- package/caps/cli.json +0 -360
- package/caps/library.json +0 -3611
- package/caps/mcp.json +0 -126
- package/caps/pagebridge.json +0 -377
- package/caps/popup.json +0 -51
- package/caps/sidepanel.json +0 -522
- package/checksums.txt +0 -142
- package/cli.d.ts.map +0 -1
- package/companion.d.ts.map +0 -1
- package/companion.js +0 -389
- package/crossbrowser.d.ts.map +0 -1
- package/crossbrowser.js +0 -1191
- package/dashdone.d.ts.map +0 -1
- package/dashdone.js +0 -368
- package/deno.d.ts.map +0 -1
- package/deno.js +0 -52325
- package/devthink.umd.js +0 -52346
- package/fixtures/bun.ts +0 -7
- package/fixtures/cjs.js +0 -6
- package/fixtures/deno.ts +0 -6
- package/fixtures/example-org-pagestate.json +0 -22
- package/fixtures/importers/automa-workflow.json +0 -18
- package/fixtures/importers/selenium-side.json +0 -20
- package/fixtures/importers/tabular-plan.csv +0 -7
- package/fixtures/importers/uivision-macro.json +0 -10
- package/fixtures/importers/v1-plan.json +0 -13
- package/fixtures/mcp-client.mjs +0 -14
- package/fixtures/pages/checkout.html +0 -192
- package/fixtures/pages/dashboard.html +0 -110
- package/fixtures/pages/feed.html +0 -113
- package/fixtures/pages/product-grid.html +0 -150
- package/fixtures/plans/form-inventory-plan.json +0 -11
- package/fixtures/plans/release-notes-plan.json +0 -11
- package/fixtures/recipes/agentscompete.json +0 -11
- package/fixtures/recipes/agentsforms.json +0 -11
- package/fixtures/recipes/agentsmonitor.json +0 -11
- package/fixtures/recipes/agentsreview.json +0 -29
- package/fixtures/recipes/agentswarm.json +0 -11
- package/fixtures/recipes/fillcalendar.json +0 -12
- package/fixtures/recipes/fillcheckout.json +0 -13
- package/fixtures/recipes/filldependentdropdowns.json +0 -12
- package/fixtures/recipes/fillfromcsv.json +0 -13
- package/fixtures/recipes/fillloginform.json +0 -12
- package/fixtures/recipes/fillmultistepwizard.json +0 -13
- package/fixtures/recipes/fillregistration.json +0 -12
- package/fixtures/recipes/fillsearchfilters.json +0 -12
- package/fixtures/recipes/filltypeahead.json +0 -11
- package/fixtures/recipes/monitoralerts.json +0 -12
- package/fixtures/recipes/monitoravailability.json +0 -11
- package/fixtures/recipes/monitornetworkquiet.json +0 -12
- package/fixtures/recipes/monitorpagechanges.json +0 -11
- package/fixtures/recipes/monitorpricechange.json +0 -11
- package/fixtures/recipes/monitorschedule.json +0 -12
- package/fixtures/recipes/scrapedynamicprices.json +0 -13
- package/fixtures/recipes/scrapeimagegallery.json +0 -12
- package/fixtures/recipes/scrapeinfinitefeed.json +0 -13
- package/fixtures/recipes/scrapenestedlists.json +0 -12
- package/fixtures/recipes/scrapeproductgrid.json +0 -12
- package/fixtures/recipes/scrapereviews.json +0 -12
- package/fixtures/recipes/scrapesearchresults.json +0 -12
- package/fixtures/recipes/scrapetablepagination.json +0 -12
- package/fixtures/recipes/testaccessibility.json +0 -34
- package/fixtures/recipes/testconsoleerrors.json +0 -12
- package/fixtures/recipes/testdeeplinks.json +0 -12
- package/fixtures/recipes/testformvalidation.json +0 -13
- package/fixtures/recipes/testlayoutshift.json +0 -12
- package/fixtures/recipes/testlinkcheck.json +0 -12
- package/fixtures/recipes/testloadtiming.json +0 -12
- package/fixtures/recipes/testvisualdiff.json +0 -12
- package/fixtures/workflows/changelog-digest-workflow.json +0 -13
- package/fixtures/workflows/form-survey-workflow.json +0 -13
- package/gallery.json +0 -706
- package/hardening.d.ts.map +0 -1
- package/hardening.js +0 -188
- package/headless.d.ts.map +0 -1
- package/headless.js +0 -11522
- package/http.d.ts.map +0 -1
- package/http.js +0 -2165
- package/index.cjs +0 -54682
- package/index.d.ts.map +0 -1
- package/index.js +0 -52310
- package/index.neutral.js +0 -46343
- package/mcp.d.ts.map +0 -1
- package/mcp.js +0 -20515
- package/memory.d.ts.map +0 -1
- package/nativehost.template.json +0 -10
- package/node.cjs +0 -54686
- package/node.d.ts.map +0 -1
- package/pack.d.ts.map +0 -1
- package/pack.js +0 -805
- package/policy.d.ts.map +0 -1
- package/progress.d.ts.map +0 -1
- package/progress.js +0 -645
- package/protocol.d.ts.map +0 -1
- package/protocol.js +0 -8334
- package/schemas/audit.schema.json +0 -226
- package/schemas/capability.schema.json +0 -113
- package/schemas/envelope.schema.json +0 -162
- package/schemas/memory.schema.json +0 -51
- package/schemas/observation.schema.json +0 -113
- package/schemas/plan.schema.json +0 -208
- package/schemas/progress.schema.json +0 -126
- package/schemas/proposal.schema.json +0 -68
- package/schemas/session.schema.json +0 -82
- package/schemas/tool.schema.json +0 -94
- package/server.d.ts.map +0 -1
- package/server.js +0 -28877
- package/umd-example.html +0 -18
- package/umd.d.ts.map +0 -1
- /package/{bun.d.ts → dist/bun.d.ts} +0 -0
- /package/{cli.d.ts → dist/cli.d.ts} +0 -0
- /package/{companion.d.ts → dist/companion.d.ts} +0 -0
- /package/{crossbrowser.d.ts → dist/crossbrowser.d.ts} +0 -0
- /package/{dashdone.d.ts → dist/dashdone.d.ts} +0 -0
- /package/{deno.d.ts → dist/deno.d.ts} +0 -0
- /package/{hardening.d.ts → dist/hardening.d.ts} +0 -0
- /package/{headless.d.ts → dist/headless.d.ts} +0 -0
- /package/{http.d.ts → dist/http.d.ts} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{mcp.d.ts → dist/mcp.d.ts} +0 -0
- /package/{memory.d.ts → dist/memory.d.ts} +0 -0
- /package/{node.d.ts → dist/node.d.ts} +0 -0
- /package/{pack.d.ts → dist/pack.d.ts} +0 -0
- /package/{policy.d.ts → dist/policy.d.ts} +0 -0
- /package/{progress.d.ts → dist/progress.d.ts} +0 -0
- /package/{protocol.d.ts → dist/protocol.d.ts} +0 -0
- /package/{server.d.ts → dist/server.d.ts} +0 -0
- /package/{umd.d.ts → dist/umd.d.ts} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
attachprovenance,
|
|
4
|
+
auditexportof,
|
|
5
|
+
bytesreclaimed,
|
|
6
|
+
cleanupbatch,
|
|
7
|
+
derivekey,
|
|
8
|
+
decryptvalue,
|
|
9
|
+
encryptvalue,
|
|
10
|
+
expireditems,
|
|
11
|
+
expiryof,
|
|
12
|
+
exportchunks,
|
|
13
|
+
exportready,
|
|
14
|
+
issensitiveclass,
|
|
15
|
+
matchingrule,
|
|
16
|
+
memoryitemof,
|
|
17
|
+
migrateitem,
|
|
18
|
+
purgeitems,
|
|
19
|
+
provenanceof,
|
|
20
|
+
quotareportof,
|
|
21
|
+
rankedcandidates,
|
|
22
|
+
stepsummaryfor,
|
|
23
|
+
} from "../memory.js";
|
|
24
|
+
import {
|
|
25
|
+
auditexportgate,
|
|
26
|
+
encryptionsecretgate,
|
|
27
|
+
encryptmemorygate,
|
|
28
|
+
expirygate,
|
|
29
|
+
exportprovenancegate,
|
|
30
|
+
quotacleanupgate,
|
|
31
|
+
} from "../policy.js";
|
|
32
|
+
import { auditexportreport } from "../protocol.js";
|
|
33
|
+
import { sessionmemory } from "../memory.js";
|
|
34
|
+
import type { purgeoutcome } from "../memory.js";
|
|
35
|
+
import type { expiryrule, memoryitem, toolstep } from "../types.js";
|
|
36
|
+
|
|
37
|
+
const now = 1_800_000_000_000;
|
|
38
|
+
const origin = "https://example.com";
|
|
39
|
+
const steps: toolstep[] = [
|
|
40
|
+
{ id: "s1", kind: "click", target: "#submit", summary: "Click the reviewed submit control.", risk: "sensitive" },
|
|
41
|
+
{ id: "s2", kind: "observe", summary: "Read the page.", risk: "read" },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function itemof(key: string, memoryclass?: string, capturedat = now, expiresat?: number): memoryitem {
|
|
45
|
+
return memoryitemof({
|
|
46
|
+
key,
|
|
47
|
+
value: { text: `value of ${key}` },
|
|
48
|
+
provenance: provenanceof({ origin, runid: "run1", stepid: "s1", now: capturedat }),
|
|
49
|
+
...(memoryclass !== undefined ? { memoryclass } : {}),
|
|
50
|
+
...(expiresat !== undefined ? { expiresat } : {}),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class fakeadapter {
|
|
55
|
+
private readonly data = new Map<string, unknown>();
|
|
56
|
+
async get<T>(key: string): Promise<T | undefined> {
|
|
57
|
+
return this.data.get(key) as T | undefined;
|
|
58
|
+
}
|
|
59
|
+
async set<T>(key: string, value: T): Promise<void> {
|
|
60
|
+
this.data.set(key, value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe("provenance", () => {
|
|
65
|
+
it("attaches a provenance record to every stored memory item and resolves its originating step summary", () => {
|
|
66
|
+
const provenance = provenanceof({ origin, runid: "run1", stepid: "s1", now });
|
|
67
|
+
expect(provenance).toEqual({ origin, runid: "run1", stepid: "s1", capturedat: now });
|
|
68
|
+
expect(() => provenanceof({ origin: " ", runid: "run1", stepid: "s1", now })).toThrow(/origin/i);
|
|
69
|
+
expect(() => provenanceof({ origin, runid: " ", stepid: "s1", now })).toThrow(/run id/i);
|
|
70
|
+
expect(() => provenanceof({ origin, runid: "run1", stepid: " ", now })).toThrow(/step id/i);
|
|
71
|
+
const item = itemof("note:1", "general");
|
|
72
|
+
expect(item.provenance).toEqual(provenance);
|
|
73
|
+
expect(() => memoryitemof({ key: " ", value: 1, provenance })).toThrow(/key/i);
|
|
74
|
+
expect(attachprovenance(item, provenance).provenance).toEqual(provenance);
|
|
75
|
+
expect(stepsummaryfor(item, steps)).toBe("Click the reviewed submit control.");
|
|
76
|
+
const unknown = { ...item, provenance: { ...provenance, stepid: "sX" } };
|
|
77
|
+
expect(stepsummaryfor(unknown, steps)).toMatch(/no longer carries/i);
|
|
78
|
+
expect(issensitiveclass("credential")).toBe(true);
|
|
79
|
+
expect(issensitiveclass("general")).toBe(false);
|
|
80
|
+
expect(issensitiveclass(undefined)).toBe(false);
|
|
81
|
+
expect(exportready([item]).ready).toBe(true);
|
|
82
|
+
expect(exportready([{ ...item, provenance: { ...provenance, stepid: " " } }]).ready).toBe(false);
|
|
83
|
+
expect(exportprovenancegate({ items: [item] }).allowed).toBe(true);
|
|
84
|
+
expect(exportprovenancegate({ items: [{ ...item, provenance: { ...provenance, stepid: " " } }] }).allowed).toBe(
|
|
85
|
+
false,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("expirememory", () => {
|
|
91
|
+
it("evaluates the user expiryrules, purges behind the confirmation and keeps the summaries for the audit trail", () => {
|
|
92
|
+
const rules: expiryrule[] = [
|
|
93
|
+
{ pattern: "note:", lifetime: 60_000 },
|
|
94
|
+
{ pattern: "*", lifetime: 600_000 },
|
|
95
|
+
];
|
|
96
|
+
const fresh = itemof("note:1", "general", now);
|
|
97
|
+
const stale = itemof("note:2", "general", now - 120_000);
|
|
98
|
+
expect(matchingrule(rules, "note:1")?.pattern).toBe("note:");
|
|
99
|
+
expect(matchingrule(rules, "anything")?.pattern).toBe("*");
|
|
100
|
+
expect(matchingrule([], "note:1")).toBeUndefined();
|
|
101
|
+
expect(expiryof(fresh, rules)).toBe(now + 60_000);
|
|
102
|
+
expect(expiryof({ ...fresh, expiresat: now + 5 }, rules)).toBe(now + 5);
|
|
103
|
+
expect(expiryof(fresh, [])).toBeUndefined();
|
|
104
|
+
expect(expireditems([fresh, stale], rules, now).map((item) => item.key)).toEqual(["note:2"]);
|
|
105
|
+
const unconfirmed = purgeitems({ items: [fresh, stale], rules, confirmed: false, now });
|
|
106
|
+
expect(unconfirmed.purged).toHaveLength(0);
|
|
107
|
+
expect(unconfirmed.kept).toHaveLength(2);
|
|
108
|
+
const gate = expirygate({ confirmed: false, count: 1 });
|
|
109
|
+
expect(gate.allowed).toBe(false);
|
|
110
|
+
expect(gate.reason).toMatch(/waits behind the explicit confirmation/i);
|
|
111
|
+
expect(expirygate({ confirmed: true, count: 1 }).allowed).toBe(true);
|
|
112
|
+
expect(expirygate({ confirmed: true, count: 0 }).allowed).toBe(false);
|
|
113
|
+
const purged = purgeitems({ items: [fresh, stale], rules, confirmed: true, now });
|
|
114
|
+
expect(purged.kept.map((item) => item.key)).toEqual(["note:1"]);
|
|
115
|
+
expect(purged.purged.map((entry) => entry.key)).toEqual(["note:2"]);
|
|
116
|
+
expect(purged.purged[0]?.summary).toMatch(/purged/i);
|
|
117
|
+
expect(purged.purged[0]?.provenance.stepid).toBe("s1");
|
|
118
|
+
const outcome: purgeoutcome = purged.purged[0]!;
|
|
119
|
+
expect(outcome.at).toBe(now);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("quotawatch", () => {
|
|
124
|
+
it("ranks the cleanup candidates by age and expiry policy, proposes batches behind the per batch approval and reports the reclaimed bytes", () => {
|
|
125
|
+
const rules: expiryrule[] = [{ pattern: "note:", lifetime: 60_000 }];
|
|
126
|
+
const expired = itemof("note:expired", "general", now - 120_000);
|
|
127
|
+
const aged = itemof("cache:1", "capture", now - 500_000);
|
|
128
|
+
const young = itemof("cache:2", "capture", now - 1_000);
|
|
129
|
+
const plain = itemof("other:1", undefined, now);
|
|
130
|
+
const report = quotareportof({ usage: 500, quota: 1_000, items: [expired, aged, young, plain], rules, now });
|
|
131
|
+
expect(report.remaining).toBe(500);
|
|
132
|
+
expect(report.candidates?.map((candidate) => candidate.key)).toEqual(["note:expired", "cache:1", "cache:2"]);
|
|
133
|
+
expect(report.candidates?.[0]?.reason).toMatch(/expired under its user expiryrule/i);
|
|
134
|
+
expect(report.candidates?.[1]?.reason).toMatch(/aged past its capture/i);
|
|
135
|
+
expect(bytesreclaimed(report.candidates ?? []) > 0).toBe(true);
|
|
136
|
+
const batch = cleanupbatch(report.candidates ?? [], 2);
|
|
137
|
+
expect(batch).toHaveLength(2);
|
|
138
|
+
expect(cleanupbatch(report.candidates ?? [], undefined)).toHaveLength(3);
|
|
139
|
+
expect(quotacleanupgate({ approved: false, batch, touchesaudit: false }).allowed).toBe(false);
|
|
140
|
+
expect(quotacleanupgate({ approved: true, batch, touchesaudit: false }).allowed).toBe(true);
|
|
141
|
+
expect(quotacleanupgate({ approved: true, batch, touchesaudit: true }).allowed).toBe(false);
|
|
142
|
+
expect(quotacleanupgate({ approved: true, batch: [], touchesaudit: false }).allowed).toBe(false);
|
|
143
|
+
expect(bytesreclaimed(batch)).toBe(batch.reduce((total, candidate) => total + candidate.bytes, 0));
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("encryptrest", () => {
|
|
148
|
+
it("derives the key from the user secret through the webcrypto api, roundtrips the value and migrates the predating items lazily", async () => {
|
|
149
|
+
const key = await derivekey("user secret", "salt:run1");
|
|
150
|
+
const value = { text: "sensitive body", count: 2 };
|
|
151
|
+
const envelope = await encryptvalue(key, value);
|
|
152
|
+
expect(envelope.iv).not.toBe("");
|
|
153
|
+
expect(envelope.payload).not.toContain("sensitive body");
|
|
154
|
+
const decrypted = await decryptvalue(key, envelope);
|
|
155
|
+
expect(decrypted).toEqual(value);
|
|
156
|
+
await expect(decryptvalue(await derivekey("other secret", "salt:run1"), envelope)).rejects.toThrow();
|
|
157
|
+
await expect(derivekey("", "salt")).rejects.toThrow(/secret/i);
|
|
158
|
+
const item = itemof("vault:1", "credential");
|
|
159
|
+
const migrated = await migrateitem({ item, key, enabled: true });
|
|
160
|
+
expect(migrated.encrypted).toBe(true);
|
|
161
|
+
expect(await migrateitem({ item: migrated, key, enabled: true })).toEqual(migrated);
|
|
162
|
+
expect(await migrateitem({ item, key, enabled: false })).toEqual(item);
|
|
163
|
+
expect(encryptmemorygate({ memoryclass: "credential", enabled: true, encrypted: false }).allowed).toBe(false);
|
|
164
|
+
expect(encryptmemorygate({ memoryclass: "credential", enabled: true, encrypted: true }).allowed).toBe(true);
|
|
165
|
+
expect(encryptmemorygate({ memoryclass: "credential", enabled: false, encrypted: false }).allowed).toBe(true);
|
|
166
|
+
expect(encryptmemorygate({ memoryclass: "general", enabled: true, encrypted: false }).allowed).toBe(true);
|
|
167
|
+
const secretgate = encryptionsecretgate({ secret: "user secret", consented: true });
|
|
168
|
+
expect(secretgate.allowed).toBe(true);
|
|
169
|
+
expect(encryptionsecretgate({ secret: "", consented: true }).allowed).toBe(false);
|
|
170
|
+
expect(encryptionsecretgate({ secret: "user secret", consented: false }).allowed).toBe(false);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe("auditexport", () => {
|
|
175
|
+
it("bundles runs, memory, provenance and expiry rules into one record that streams without a size cap behind the explicit user action", () => {
|
|
176
|
+
const items = [itemof("note:1", "general"), itemof("vault:1", "credential")];
|
|
177
|
+
const rules: expiryrule[] = [{ pattern: "note:", lifetime: 60_000 }];
|
|
178
|
+
const record = auditexportof({
|
|
179
|
+
runs: [
|
|
180
|
+
{ runid: "run1", planid: "plan", sessionid: "session", state: "completed", createdat: now, updatedat: now },
|
|
181
|
+
],
|
|
182
|
+
items,
|
|
183
|
+
rules,
|
|
184
|
+
timeline: [{ at: now, runid: "run1", source: "step", summary: "completed" }],
|
|
185
|
+
locks: [{ holder: "run1", runid: "run1", sessionid: "session", acquiredat: now, expiresat: now + 1 }],
|
|
186
|
+
now,
|
|
187
|
+
});
|
|
188
|
+
expect(record.memory).toHaveLength(2);
|
|
189
|
+
expect(record.expiryrules).toEqual(rules);
|
|
190
|
+
const chunks = exportchunks(record, 200);
|
|
191
|
+
expect(chunks.length).toBeGreaterThan(1);
|
|
192
|
+
expect(chunks.at(-1)?.done).toBe(true);
|
|
193
|
+
expect(JSON.parse(chunks.map((chunk) => chunk.payload).join(""))).toEqual(record);
|
|
194
|
+
expect(() => exportchunks(record, 0)).toThrow(/chunk size/i);
|
|
195
|
+
expect(auditexportgate({ useraction: true }).allowed).toBe(true);
|
|
196
|
+
expect(auditexportgate({ useraction: false }).allowed).toBe(false);
|
|
197
|
+
const envelope = auditexportreport({ record });
|
|
198
|
+
expect(envelope.record.at).toBe(now);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it("persists the memory items, the expiry rules, the quotareport, the encryption flag and the purge summaries through the memory accessors", async () => {
|
|
202
|
+
const store = new sessionmemory(new fakeadapter());
|
|
203
|
+
await store.setmemoryitem(itemof("note:1", "general"));
|
|
204
|
+
await store.setmemoryitem(itemof("note:2", "general", now, now + 60_000));
|
|
205
|
+
expect((await store.getmemoryitems()).map((item) => item.key)).toEqual(["note:1", "note:2"]);
|
|
206
|
+
await store.setmemoryitem({ ...itemof("note:1", "general"), value: { text: "updated" } });
|
|
207
|
+
expect(await store.getmemoryitems()).toHaveLength(2);
|
|
208
|
+
await store.removememoryitems(["note:1"]);
|
|
209
|
+
expect((await store.getmemoryitems()).map((item) => item.key)).toEqual(["note:2"]);
|
|
210
|
+
await store.setexpiry([{ pattern: "note:", lifetime: 60_000 }]);
|
|
211
|
+
expect(await store.getexpiry()).toEqual([{ pattern: "note:", lifetime: 60_000 }]);
|
|
212
|
+
await store.setquotareport({ usage: 10, quota: 100, remaining: 90 });
|
|
213
|
+
expect((await store.getquotareport())?.remaining).toBe(90);
|
|
214
|
+
expect(await store.getencryptrest()).toBe(false);
|
|
215
|
+
await store.setencryptrest(true);
|
|
216
|
+
expect(await store.getencryptrest()).toBe(true);
|
|
217
|
+
await store.addpurgesummary({
|
|
218
|
+
key: "note:1",
|
|
219
|
+
summary: "purged",
|
|
220
|
+
provenance: provenanceof({ origin, runid: "run1", stepid: "s1", now }),
|
|
221
|
+
at: now,
|
|
222
|
+
});
|
|
223
|
+
expect((await store.listpurgesummaries()).map((entry) => entry.key)).toEqual(["note:1"]);
|
|
224
|
+
await store.setlastexpirepass(now);
|
|
225
|
+
expect(await store.getlastexpirepass()).toBe(now);
|
|
226
|
+
const exported = await store.getexport(now);
|
|
227
|
+
expect(exported.memory).toHaveLength(1);
|
|
228
|
+
expect(exported.expiryrules).toHaveLength(1);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
importautoma,
|
|
4
|
+
importselenium,
|
|
5
|
+
importtabular,
|
|
6
|
+
importuivision,
|
|
7
|
+
importv1plan,
|
|
8
|
+
migrateplanconversion,
|
|
9
|
+
parsecsvrows,
|
|
10
|
+
planlintfindings,
|
|
11
|
+
} from "../cli.js";
|
|
12
|
+
import { lintplanfile, parseplanfile } from "../plan.js";
|
|
13
|
+
import { actionkindcatalog, portablerulesetof } from "../policy.js";
|
|
14
|
+
import { clicommands, surfacepalette } from "../views.js";
|
|
15
|
+
import { packageversion } from "../version.js";
|
|
16
|
+
import { readFile } from "node:fs/promises";
|
|
17
|
+
import type { planfile, planlintdiagnostic, portableruleset } from "../types.js";
|
|
18
|
+
|
|
19
|
+
const now = 1_800_000_000_000;
|
|
20
|
+
const ruleset: portableruleset = portablerulesetof(now);
|
|
21
|
+
const capabilities = actionkindcatalog();
|
|
22
|
+
|
|
23
|
+
/** Reads one importer fixture of the tests/code/importers source set the build copies into dist/fixtures/importers. */
|
|
24
|
+
async function fixture(name: string): Promise<string> {
|
|
25
|
+
return readFile(`tests/code/importers/${name}`, "utf8");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Reads one json importer fixture as the parsed source object its importer reads. */
|
|
29
|
+
async function jsonfixture(name: string): Promise<unknown> {
|
|
30
|
+
return JSON.parse(await fixture(name));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Lints one converted plan through the same lint engine the planlint command runs: the portable rule set, the cli findings and the full action kind capability set. */
|
|
34
|
+
function lintconverted(file: planfile): planlintdiagnostic[] {
|
|
35
|
+
return [...lintplanfile({ file, ruleset, capabilities, now }), ...planlintfindings({ file, capabilities })];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The happy path fixtures of every importer with the format the migrateplan command declares for them. */
|
|
39
|
+
const happy: Array<{ name: string; format: string }> = [
|
|
40
|
+
{ name: "v1-plan.json", format: "v1" },
|
|
41
|
+
{ name: "automa-workflow.json", format: "automa" },
|
|
42
|
+
{ name: "selenium-side.json", format: "selenium" },
|
|
43
|
+
{ name: "uivision-macro.json", format: "uivision" },
|
|
44
|
+
{ name: "tabular-plan.csv", format: "tabular" },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
/** The refusal fixtures of every importer: each one carries one entry the importer must refuse with the entry named. */
|
|
48
|
+
const refusals: Array<{ name: string; format: string; pattern: RegExp }> = [
|
|
49
|
+
{
|
|
50
|
+
name: "v1-unknown.json",
|
|
51
|
+
format: "v1",
|
|
52
|
+
pattern: /version one step snap[\s\S]*screenshotpage outside the reviewed catalog/,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "automa-unknown.json",
|
|
56
|
+
format: "automa",
|
|
57
|
+
pattern: /automa block ping of type notification stays outside the conversion table/,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "selenium-unknown.json",
|
|
61
|
+
format: "selenium",
|
|
62
|
+
pattern: /selenium command roll of mouseOver stays outside the conversion table/,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "uivision-unknown.json",
|
|
66
|
+
format: "uivision",
|
|
67
|
+
pattern: /ui vision command xclick-2 of XClick stays outside the conversion table/,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "tabular-unknown.csv",
|
|
71
|
+
format: "tabular",
|
|
72
|
+
pattern: /tabular row 2[\s\S]*dragdrop outside the reviewed catalog/,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
describe("migrateplan importer conversion", () => {
|
|
77
|
+
it("converts every happy fixture into a plan file that parses under schemastrict and lints with zero diagnostics", async () => {
|
|
78
|
+
for (const source of happy) {
|
|
79
|
+
const conversion = migrateplanconversion({ format: source.format, text: await fixture(source.name), now });
|
|
80
|
+
expect(conversion.file.version).toBe(packageversion);
|
|
81
|
+
expect(conversion.file.origin).toBe("https://example.org");
|
|
82
|
+
expect(conversion.file.steps.length).toBeGreaterThan(0);
|
|
83
|
+
const parsed = parseplanfile(JSON.parse(JSON.stringify(conversion.file)));
|
|
84
|
+
expect(parsed).toEqual(conversion.file);
|
|
85
|
+
expect(lintconverted(conversion.file)).toEqual([]);
|
|
86
|
+
expect(conversion.format).toBe(source.format);
|
|
87
|
+
expect(conversion.mapped).toBe(conversion.file.steps.length);
|
|
88
|
+
expect(conversion.notes[0]).toContain(`${source.format} importer converted the source`);
|
|
89
|
+
expect(conversion.notes[0]).toContain("the frozen plan file grammar carries no metadata field");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("marks every converted sensitive step with the explicit gate declaration while the read steps carry none", async () => {
|
|
94
|
+
const v1 = importv1plan({ source: await jsonfixture("v1-plan.json"), now });
|
|
95
|
+
expect(v1.file.steps.map((step) => [step.id, step.kind, step.gate])).toEqual([
|
|
96
|
+
["observe", "observe", undefined],
|
|
97
|
+
["read", "readforms", undefined],
|
|
98
|
+
["inspect", "inspect", undefined],
|
|
99
|
+
["answer", "type", true],
|
|
100
|
+
["pause", "delay", undefined],
|
|
101
|
+
]);
|
|
102
|
+
expect(v1.file.grants).toEqual(["observe", "readforms", "inspect", "type", "delay"]);
|
|
103
|
+
const lifted = v1.file.steps.find((step) => step.id === "pause");
|
|
104
|
+
expect(lifted?.options).toBe('{"delay":3000}');
|
|
105
|
+
expect(v1.sourceversion).toBe("1");
|
|
106
|
+
expect(v1.notes.some((note) => note.includes("milliseconds field of 1 delay step lifted"))).toBe(true);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("converts the automa blocks through the documented table and lands the trigger block in the report as the paused trigger", async () => {
|
|
110
|
+
const conversion = importautoma({ source: await jsonfixture("automa-workflow.json"), now });
|
|
111
|
+
expect(conversion.file.goal).toBe("contact survey sweep");
|
|
112
|
+
expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
|
|
113
|
+
["tab", "tabcreate", undefined, "https://example.org/contact", true],
|
|
114
|
+
["survey", "fillform", undefined, undefined, true],
|
|
115
|
+
["send", "click", "button.primary", undefined, true],
|
|
116
|
+
["hold", "delay", undefined, undefined, undefined],
|
|
117
|
+
]);
|
|
118
|
+
const fields = JSON.parse(conversion.file.steps.find((step) => step.id === "survey")?.options ?? "{}") as {
|
|
119
|
+
fields: Array<Record<string, string>>;
|
|
120
|
+
};
|
|
121
|
+
expect(fields.fields).toEqual([
|
|
122
|
+
{ name: "email", value: "survey@example.org", selector: "input[name=email]" },
|
|
123
|
+
{ name: "message", value: "hello from the sweep", selector: "textarea" },
|
|
124
|
+
]);
|
|
125
|
+
expect(JSON.parse(conversion.file.steps.find((step) => step.id === "hold")?.options ?? "{}")).toEqual({
|
|
126
|
+
delay: 1500,
|
|
127
|
+
});
|
|
128
|
+
expect(conversion.notes.some((note) => note.includes("paused trigger"))).toBe(true);
|
|
129
|
+
expect(conversion.sourceversion).toBe("1.0.0");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("resolves the selenium locators, the open target and the pause milliseconds onto the reviewed grammar", async () => {
|
|
133
|
+
const conversion = importselenium({ source: await jsonfixture("selenium-side.json"), now });
|
|
134
|
+
expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
|
|
135
|
+
["open", "navigate", undefined, "https://example.org/contact", true],
|
|
136
|
+
["email", "type", "input[name=email]", "survey@example.org", true],
|
|
137
|
+
["keys", "appendtext", "input[name=email]", " hello", true],
|
|
138
|
+
["pick", "select", "#topic", "general", true],
|
|
139
|
+
["send", "click", "button.primary", undefined, true],
|
|
140
|
+
["hold", "delay", undefined, undefined, undefined],
|
|
141
|
+
]);
|
|
142
|
+
expect(JSON.parse(conversion.file.steps.find((step) => step.id === "hold")?.options ?? "{}")).toEqual({
|
|
143
|
+
delay: 2000,
|
|
144
|
+
});
|
|
145
|
+
expect(conversion.sourceversion).toBe("2.0");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("converts the ui vision macro with its derived stable step ids and the waittext verification", async () => {
|
|
149
|
+
const conversion = importuivision({ source: await jsonfixture("uivision-macro.json"), now });
|
|
150
|
+
expect(conversion.file.goal).toBe("example releases read");
|
|
151
|
+
expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
|
|
152
|
+
["open-1", "navigate", undefined, "https://example.org/releases", true],
|
|
153
|
+
["click-2", "click", "nav a.releases", undefined, true],
|
|
154
|
+
["type-3", "type", "input[name=filter]", "release notes", true],
|
|
155
|
+
["verifytext-4", "waittext", "main h1", "Releases", undefined],
|
|
156
|
+
]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("converts the tabular rows onto the step grammar with the preface metadata and the quoted csv cells", async () => {
|
|
160
|
+
const conversion = importtabular({ text: await fixture("tabular-plan.csv"), now });
|
|
161
|
+
expect(conversion.file.goal).toBe("Survey the releases page of the example project");
|
|
162
|
+
expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
|
|
163
|
+
["observe-1", "observe", undefined, undefined, undefined],
|
|
164
|
+
["readtext-2", "readtext", "main", undefined, undefined],
|
|
165
|
+
["countelements-3", "countelements", "main section", undefined, undefined],
|
|
166
|
+
["type-4", "type", "input[name=filter]", "release notes, digest", true],
|
|
167
|
+
]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("reads the tabular preface markers through the linear scan that closed the polynomial regular expression alerts", async () => {
|
|
171
|
+
/* the marker body accepts any spacing after the hash and the colon, and a marker line with no value never clears a value an earlier line set */
|
|
172
|
+
const tight = importtabular({
|
|
173
|
+
text: "#goal:tight\n#origin:https://example.org\nstep,target,value\nobserve,,\n",
|
|
174
|
+
now,
|
|
175
|
+
});
|
|
176
|
+
expect(tight.file.goal).toBe("tight");
|
|
177
|
+
expect(tight.file.origin).toBe("https://example.org");
|
|
178
|
+
const spaced = importtabular({
|
|
179
|
+
text: "# goal: spaced survey\n# origin: https://example.org\nstep,target,value\nobserve,,\n",
|
|
180
|
+
now,
|
|
181
|
+
});
|
|
182
|
+
expect(spaced.file.goal).toBe("spaced survey");
|
|
183
|
+
expect(spaced.file.origin).toBe("https://example.org");
|
|
184
|
+
const kept = importtabular({
|
|
185
|
+
text: "# goal: kept\n# goal:\n# origin: https://example.org\nstep,target,value\nobserve,,\n",
|
|
186
|
+
now,
|
|
187
|
+
});
|
|
188
|
+
expect(kept.file.goal).toBe("kept");
|
|
189
|
+
const sameorigin = importtabular({
|
|
190
|
+
text: "# goal: g\n# origin: https://example.org\n# origin:\nstep,target,value\nobserve,,\n",
|
|
191
|
+
now,
|
|
192
|
+
});
|
|
193
|
+
expect(sameorigin.file.origin).toBe("https://example.org");
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("migrateplan refusal semantics", () => {
|
|
198
|
+
it("refuses every unmappable entry with the source entry named, never with a silent drop", async () => {
|
|
199
|
+
for (const source of refusals) {
|
|
200
|
+
const text = await fixture(source.name);
|
|
201
|
+
expect(() => migrateplanconversion({ format: source.format, text, now })).toThrow(source.pattern);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("refuses the formats, the shapes and the locators it cannot map instead of guessing", async () => {
|
|
206
|
+
expect(() => migrateplanconversion({ format: "playwright", text: "{}", now })).toThrow(
|
|
207
|
+
/stays outside the v1, automa, selenium, uivision and tabular source formats/,
|
|
208
|
+
);
|
|
209
|
+
expect(() => migrateplanconversion({ format: "v1", text: "not json", now })).toThrow(/v1 source parses no json/);
|
|
210
|
+
expect(() =>
|
|
211
|
+
importv1plan({
|
|
212
|
+
source: {
|
|
213
|
+
version: "1",
|
|
214
|
+
goal: "g",
|
|
215
|
+
origin: "https://example.org",
|
|
216
|
+
steps: [{ id: "s", action: "observe", label: "l", legacy: true }],
|
|
217
|
+
},
|
|
218
|
+
now,
|
|
219
|
+
}),
|
|
220
|
+
).toThrow(/unknown field legacy/);
|
|
221
|
+
expect(() =>
|
|
222
|
+
importv1plan({
|
|
223
|
+
source: {
|
|
224
|
+
version: "1",
|
|
225
|
+
goal: "g",
|
|
226
|
+
origin: "http://example.org",
|
|
227
|
+
steps: [{ id: "s", action: "observe", label: "l" }],
|
|
228
|
+
},
|
|
229
|
+
now,
|
|
230
|
+
}),
|
|
231
|
+
).toThrow(/HTTPS/);
|
|
232
|
+
expect(() =>
|
|
233
|
+
importv1plan({
|
|
234
|
+
source: {
|
|
235
|
+
version: "1",
|
|
236
|
+
goal: "g",
|
|
237
|
+
origin: "https://example.org",
|
|
238
|
+
steps: [{ id: "s", action: "click", label: "l", milliseconds: 5 }],
|
|
239
|
+
},
|
|
240
|
+
now,
|
|
241
|
+
}),
|
|
242
|
+
).toThrow(/only the delay action lifts/);
|
|
243
|
+
expect(() =>
|
|
244
|
+
importautoma({
|
|
245
|
+
source: {
|
|
246
|
+
name: "n",
|
|
247
|
+
blocks: {
|
|
248
|
+
tab: { type: "newtab", data: { url: "https://example.org" } },
|
|
249
|
+
away: { type: "newtab", data: { url: "https://other.example" } },
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
now,
|
|
253
|
+
}),
|
|
254
|
+
).toThrow(/automa block away of type newtab navigates to https:\/\/other\.example/);
|
|
255
|
+
expect(() =>
|
|
256
|
+
importautoma({
|
|
257
|
+
source: { name: "n", blocks: { only: { type: "click-element", data: { selector: "button" } } } },
|
|
258
|
+
now,
|
|
259
|
+
}),
|
|
260
|
+
).toThrow(/carries no newtab block/);
|
|
261
|
+
expect(() =>
|
|
262
|
+
importselenium({ source: { version: "2.0", name: "n", url: "https://example.org", tests: [] }, now }),
|
|
263
|
+
).toThrow(/carries 0 tests; one plan addresses exactly one test/);
|
|
264
|
+
expect(() =>
|
|
265
|
+
importselenium({
|
|
266
|
+
source: {
|
|
267
|
+
version: "2.0",
|
|
268
|
+
name: "n",
|
|
269
|
+
url: "https://example.org",
|
|
270
|
+
tests: [{ name: "t", commands: [{ id: "x", command: "click", target: "xpath=//button", value: "" }] }],
|
|
271
|
+
},
|
|
272
|
+
now,
|
|
273
|
+
}),
|
|
274
|
+
).toThrow(/outside the css=, id= and name= locator prefixes/);
|
|
275
|
+
expect(() =>
|
|
276
|
+
importuivision({ source: { Name: "n", Commands: [{ Command: "click", Target: "css=button", Value: "" }] }, now }),
|
|
277
|
+
).toThrow(/carries no open command/);
|
|
278
|
+
expect(() => importtabular({ text: "step,target,value\nobserve,,\n", now })).toThrow(/no `# goal:` preface line/);
|
|
279
|
+
expect(() => importtabular({ text: "# goal: g\nstep,target,value\nobserve,,\n", now })).toThrow(
|
|
280
|
+
/no `# origin:` preface line/,
|
|
281
|
+
);
|
|
282
|
+
expect(() =>
|
|
283
|
+
importtabular({ text: "# goal: g\n# origin: http://example.org\nstep,target,value\nobserve,,\n", now }),
|
|
284
|
+
).toThrow(/HTTPS origin/);
|
|
285
|
+
expect(() =>
|
|
286
|
+
importtabular({ text: "# goal: g\n# origin: https://example.org\nstep,target,extra\nobserve,,\n", now }),
|
|
287
|
+
).toThrow(/column extra outside the step, target and value columns/);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
describe("the csv parser of the tabular importer", () => {
|
|
292
|
+
it("parses headers, quoted cells, escaped quotes, embedded newlines and crlf line endings while refusing an unterminated quote", () => {
|
|
293
|
+
expect(parsecsvrows("step,target,value\nobserve,,\n")).toEqual([
|
|
294
|
+
["step", "target", "value"],
|
|
295
|
+
["observe", "", ""],
|
|
296
|
+
]);
|
|
297
|
+
expect(parsecsvrows('a,b\n1,"x,y"\n')).toEqual([
|
|
298
|
+
["a", "b"],
|
|
299
|
+
["1", "x,y"],
|
|
300
|
+
]);
|
|
301
|
+
expect(parsecsvrows('a,b\n1,"say ""hi"""\n')).toEqual([
|
|
302
|
+
["a", "b"],
|
|
303
|
+
["1", 'say "hi"'],
|
|
304
|
+
]);
|
|
305
|
+
expect(parsecsvrows('a,b,c\n1,"two\nlines",3')).toEqual([
|
|
306
|
+
["a", "b", "c"],
|
|
307
|
+
["1", "two\nlines", "3"],
|
|
308
|
+
]);
|
|
309
|
+
expect(parsecsvrows("a,b\r\n1,2\r\n")).toEqual([
|
|
310
|
+
["a", "b"],
|
|
311
|
+
["1", "2"],
|
|
312
|
+
]);
|
|
313
|
+
expect(parsecsvrows('a,b\n,"","x"\n')).toEqual([
|
|
314
|
+
["a", "b"],
|
|
315
|
+
["", "", "x"],
|
|
316
|
+
]);
|
|
317
|
+
expect(parsecsvrows('a,b\n,"""",x\n')).toEqual([
|
|
318
|
+
["a", "b"],
|
|
319
|
+
["", '"', "x"],
|
|
320
|
+
]);
|
|
321
|
+
expect(parsecsvrows("")).toEqual([]);
|
|
322
|
+
expect(() => parsecsvrows('a,"unterminated')).toThrow(/ends inside a quoted cell/);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
describe("the migrateplan command surface", () => {
|
|
327
|
+
it("registers the migrateplan command in the shared registry the cli help prints", () => {
|
|
328
|
+
const entry = clicommands(surfacepalette()).find((command) => command.id === "migrateplan");
|
|
329
|
+
expect(entry?.terminal).toBe(true);
|
|
330
|
+
expect(entry?.label).toContain("foreign plan source");
|
|
331
|
+
expect(entry?.keywords).toContain("automa");
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it("keeps the conversion idempotent: converting the already converted output yields the same plan", async () => {
|
|
335
|
+
const first = migrateplanconversion({ format: "v1", text: await fixture("v1-plan.json"), now });
|
|
336
|
+
const serialized = JSON.stringify(first.file, null, 2);
|
|
337
|
+
const second = migrateplanconversion({ format: "v1", text: serialized, now: now + 5_000 });
|
|
338
|
+
expect(second.file).toEqual(first.file);
|
|
339
|
+
expect(second.mapped).toBe(first.mapped);
|
|
340
|
+
expect(second.notes.some((note) => note.includes("passes it through unchanged"))).toBe(true);
|
|
341
|
+
const tabular = migrateplanconversion({ format: "tabular", text: await fixture("tabular-plan.csv"), now });
|
|
342
|
+
const reimported = migrateplanconversion({
|
|
343
|
+
format: "tabular",
|
|
344
|
+
text: await fixture("tabular-plan.csv"),
|
|
345
|
+
now: now + 5_000,
|
|
346
|
+
});
|
|
347
|
+
expect(reimported.file).toEqual(tabular.file);
|
|
348
|
+
});
|
|
349
|
+
});
|