Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(links): r3-m1 add route contract properties
Josuéfb7ec39c0e3c
diff --git a/packages/desktop-app-links/index.test.cjs b/packages/desktop-app-links/index.test.cjsindex b6404ca4d..e252d1bb7 100644--- a/packages/desktop-app-links/index.test.cjs+++ b/packages/desktop-app-links/index.test.cjs@@ -1,6 +1,7 @@'use strict'const assert = require('node:assert/strict')+const fc = require('fast-check')const fs = require('node:fs')const path = require('node:path')const test = require('node:test')@@ -113,6 +114,65 @@ test('route normalization rejects unstable segment-edge whitespace', () => {)})+test('accepted generated routes preserve their canonical deep-link target', () => {+ const segmentArbitrary = fc+ .array(+ fc.constantFrom('a', 'Z', '0', '-', '_', '.', 'é', '中', '+', '%', ' ', '%20', '%2520'),+ { minLength: 1, maxLength: 8 }+ )+ .map(tokens => tokens.join(''))+ const routeArbitrary = fc+ .array(segmentArbitrary, { minLength: 1, maxLength: 6 })+ .map(segments => `/${segments.join('/')}`)++ fc.assert(+ fc.property(routeArbitrary, input => {+ const canonical = links.normalizeSandboxUiRoute(input)+ if (canonical === null || canonical === undefined) return++ assert.equal(links.normalizeSandboxUiRoute(canonical), canonical)++ const target = { appRef: 'sandbox-recipes/property-app', path: canonical }+ const parsed = links.parseSandboxUiDeepLink(+ links.buildSandboxUiDeepLink({+ recipeNs: 'sandbox-recipes',+ recipeName: 'property-app',+ path: canonical,+ })+ )+ assert.deepEqual(parsed, target)+ assert.equal(links.sandboxUiDeepLinkTargetsEqual(target, parsed), true)+ }),+ { numRuns: 1_000 }+ )+})++test('route contract covers canonical tokens and rejects unsafe encoded forms', () => {+ for (const [input, expected] of [+ ['/space%20here', '/space here'],+ ['/already%2520encoded', '/already encoded'],+ ['/literal%percent', '/literal%percent'],+ ['/literal%25percent', '/literal%percent'],+ ['/plus+sign', '/plus+sign'],+ ['/café', '/café'],+ ]) {+ assert.equal(links.normalizeSandboxUiRoute(input), expected)+ }++ for (const input of [+ '/%20leading',+ '/trailing%20',+ '/%2520recursive-leading',+ '/recursive-trailing%2520',+ '/safe/..',+ '/safe/%252e%252e',+ '/safe%252Fadmin',+ '/control%2500',+ ]) {+ assert.equal(links.normalizeSandboxUiRoute(input), null)+ }+})+test('shared app links carry only client-side pathnames', () => {for (const pathValue of ['/tasks?authorization=secret',diff --git a/packages/desktop-app-links/package-lock.json b/packages/desktop-app-links/package-lock.jsonindex c8ca7704f..7c4c68fb3 100644--- a/packages/desktop-app-links/package-lock.json+++ b/packages/desktop-app-links/package-lock.json@@ -6,7 +6,50 @@"packages": {"": {"name": "@clerum/desktop-app-links",- "version": "0.1.1"+ "version": "0.1.1",+ "devDependencies": {+ "fast-check": "^4.9.0"+ }+ },+ "node_modules/fast-check": {+ "version": "4.9.0",+ "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.9.0.tgz",+ "integrity": "sha512-7ms6T7SybUev/PQITciI0yLM2pOSFy5zpG8Ty7tQofcVaQUvrMXp6CBwqF6fThLCLOrfBtuHAtwq6Yu4XPCllg==",+ "dev": true,+ "funding": [+ {+ "type": "individual",+ "url": "https://github.com/sponsors/dubzzz"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/fast-check"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "pure-rand": "^8.0.0"+ },+ "engines": {+ "node": ">=12.17.0"+ }+ },+ "node_modules/pure-rand": {+ "version": "8.4.2",+ "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.2.tgz",+ "integrity": "sha512-vvuOGgcuPJAirlHvuQw1TrOiw7ptaIXXmIbNuiNOY6lNGJJH49PQ1Kj4nd783nPdQhQdicgOjVI2yI/9BD6/Ng==",+ "dev": true,+ "funding": [+ {+ "type": "individual",+ "url": "https://github.com/sponsors/dubzzz"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/fast-check"+ }+ ],+ "license": "MIT"}}}diff --git a/packages/desktop-app-links/package.json b/packages/desktop-app-links/package.jsonindex 016bf64fa..5e9bc1d4a 100644--- a/packages/desktop-app-links/package.json+++ b/packages/desktop-app-links/package.json@@ -8,5 +8,8 @@"scripts": {"build": "node --check index.cjs","test": "node --test index.test.cjs"+ },+ "devDependencies": {+ "fast-check": "^4.9.0"}}