Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Remove extra free-tool verification dependencies (#645)
Ben Senescu76fdba6144f4
diff --git a/.agents/PAPERCUTS.md b/.agents/PAPERCUTS.mdindex 5072be9f..98e6fc49 100644--- a/.agents/PAPERCUTS.md+++ b/.agents/PAPERCUTS.md@@ -10,6 +10,7 @@ data, or sensitive paths.## Open+- [ ] `2026-09-18T10:06:56Z` — `codex` — Website browser tests flood Vite output with "Assets in public directory cannot be imported from JavaScript" for MDX library images. Adjust the MDX image handling to retain public image URLs instead of generating imports, so useful test failures remain visible.- [ ] `2026-09-03T00:00:00Z` — `claude` — `pnpm ci:check` does not run `pnpm build`, so a route file that pulls `cloudflare:workers` into the client bundle passes every check and still breaks the build (hit on the dynamic-reports branch). Add a build step to `ci:check`, or document that `pnpm build` must be run separately before opening a PR.- [ ] `2026-09-11T00:13:05Z` — `codex` — The web-content review skill points to the removed `src/server/features/onboarding/openseo-fact-sheet.md`; the reference now lives at `src/server/features/sam/openseo-fact-sheet.md`. Update the skill's pointer so content reviews reach the current fact sheet.diff --git a/package.json b/package.jsonindex df97c40b..43623d94 100644--- a/package.json+++ b/package.json@@ -42,6 +42,7 @@"test:watch": "vitest","test:ci": "vitest run --reporter=dot","test:e2e": "playwright test",+ "test:e2e:free-tools": "playwright test --config playwright.free-tools.config.ts","test:e2e:domain": "playwright test e2e/domain-overview-filters.spec.ts","test:e2e:domain:perf": "playwright test e2e/domain-overview-filters.perf.spec.ts","test:e2e:keywords": "playwright test e2e/keyword-research-navigation.spec.ts",diff --git a/playwright.free-tools.config.ts b/playwright.free-tools.config.tsnew file mode 100644index 00000000..4cf6f6da--- /dev/null+++ b/playwright.free-tools.config.ts@@ -0,0 +1,18 @@+import { defineConfig } from "@playwright/test";++export default defineConfig({+ testDir: "./web/tests",+ testMatch: "**/*.spec.ts",+ workers: 1,+ timeout: 45_000,+ use: {+ baseURL: "http://localhost:4324",+ trace: "retain-on-failure",+ },+ webServer: {+ command: "pnpm --dir web dev --host 127.0.0.1 --port 4324 --strictPort",+ url: "http://localhost:4324",+ env: { VITE_TURNSTILE_SITE_KEY: "1x00000000000000000000AA" },+ timeout: 120_000,+ },+});diff --git a/web/package.json b/web/package.jsonindex 9a760423..98914985 100644--- a/web/package.json+++ b/web/package.json@@ -19,7 +19,6 @@"test:protection": "vitest run && node scripts/check-free-tool-budget.cjs"},"dependencies": {- "@marsidev/react-turnstile": "1.6.1","@tanstack/react-router": "^1.170.16","@tanstack/react-router-devtools": "^1.167.0","@tanstack/react-start": "^1.168.26",@@ -41,7 +40,6 @@"@types/react": "^19.2.13","@types/react-dom": "^19.2.3","@vitejs/plugin-react": "^5.1.3",- "jsdom": "^30.0.1","prettier": "^3.6.2","srvx": "^0.11.22","tailwindcss": "^4.1.18",diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yamlindex 54fa7c8d..0e8814b3 100644--- a/web/pnpm-lock.yaml+++ b/web/pnpm-lock.yaml@@ -22,9 +22,6 @@ importers:.:dependencies:- '@marsidev/react-turnstile':- specifier: 1.6.1'@radix-ui/react-popover':specifier: ^1.1.15version: 1.1.23(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])@@ -83,9 +80,6 @@ importers:'@vitejs/plugin-react':specifier: ^5.1.3version: 5.1.4([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))- jsdom:- specifier: ^30.0.1- version: 30.0.1prettier:specifier: ^3.6.2version: 3.8.1@@ -103,21 +97,13 @@ importers:version: 6.1.1([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))vitest:specifier: 3.2.6- version: 3.2.6(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ version: 3.2.6(@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])wrangler:specifier: ^4.67.0version: 4.71.0(@cloudflare/[email protected])(@types/[email protected])packages:- '@asamuzakjp/[email protected]':- resolution: {integrity: sha512-vC/bk1Lz7Tn/EfU9/apOTBk80/8dyGyWMowPoV1tJ52muDGsDqt2HPT2klrFUiY60MQmQv9q8yIht15JnBgDGw==}- engines: {node: ^22.13.0 || >=24.0.0}-- '@asamuzakjp/[email protected]':- resolution: {integrity: sha512-93Z1N+BQNXysodoicpOIyNh2drHfz/CTf9nnT0FEx72GJcIiwgydD7tGAr78j41LsYn3hlRn+LdGPuBLn1Bl8Q==}- engines: {node: ^22.13.0 || >=24.0.0}-'@babel/[email protected]':resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==}engines: {node: '>=6.9.0'}@@ -222,10 +208,6 @@ packages:resolution: {integrity: sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==}engines: {node: '>=6.9.0'}- '@bramus/[email protected]':- resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==}- hasBin: true-'@cloudflare/[email protected]':resolution: {integrity: sha512-SIOD2DxrRRwQ+jgzlXCqoEFiKOFqaPjhnNTGKXSRLvp1HiOvapLaFG2kEr9dYQTYe8rKrd9uvDUzmAITeNyaHQ==}engines: {node: '>=18.0.0'}@@ -282,42 +264,6 @@ packages:resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}engines: {node: '>=12'}- '@csstools/[email protected]':- resolution: {integrity: sha512-gLNsunvwf3mCi5u5o46/Z/JcJMnhbHSaZ69rkgPzNM3J4s8hWwpPUQB6/tt0EDFyCiWzxANlx+2LJwpYj4zS1w==}- engines: {node: '>=20.19.0'}-- '@csstools/[email protected]':- resolution: {integrity: sha512-c5ihYsPkdG6JCkU2zTMm4+k6r7RXuGxtWYhu5DHMIiF1FHzrfmHL5so11AoFpUv/tu61xfcmT4AmKoFfMPoqdQ==}- engines: {node: '>=20.19.0'}- peerDependencies:- '@csstools/css-parser-algorithms': ^4.0.0- '@csstools/css-tokenizer': ^4.0.0-- '@csstools/[email protected]':- resolution: {integrity: sha512-3QKjR/vxyjcSXBLgb6lP0S3MGdvwbmqSsvLPbYdVORqPDc8FX1HAJ0Spk38bxaRXgvENTA47tlhhbb5Z2e8hEg==}- engines: {node: '>=20.19.0'}- peerDependencies:- '@csstools/css-parser-algorithms': ^4.0.0- '@csstools/css-tokenizer': ^4.0.0-- '@csstools/[email protected]':- resolution: {integrity: sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==}- engines: {node: '>=20.19.0'}- peerDependencies:- '@csstools/css-tokenizer': ^4.0.0-- '@csstools/[email protected]':- resolution: {integrity: sha512-3vLQK+dXxhBMR2Wx99PTCifE+vHtW2ndZWyla8yK813ev6oGhyn8Lja8jCyGAWTJ+LEYZK7EVtJxrDj8ztevJw==}- peerDependencies:- css-tree: ^3.2.1- peerDependenciesMeta:- css-tree:- optional: true-- '@csstools/[email protected]':- resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==}- engines: {node: '>=20.19.0'}-'@emnapi/[email protected]':resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==}@@ -633,15 +579,6 @@ packages:cpu: [x64]os: [win32]- '@exodus/[email protected]':- resolution: {integrity: sha512-S6mL0yNB/Abt9Ei4tq8gDhcczc4S3+vQ4ra7vxnAf+YHC02srtqxKKZghx2Dq6p0e66THKwR6r8N6P95wEty7Q==}- engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}- peerDependencies:- '@noble/hashes': ^1.8.0 || ^2.0.0- peerDependenciesMeta:- '@noble/hashes':- optional: true-'@floating-ui/[email protected]':resolution: {integrity: sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==}@@ -859,12 +796,6 @@ packages:'@jridgewell/[email protected]':resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}- '@marsidev/[email protected]':- resolution: {integrity: sha512-ojI9NLYv821IRKi7KraTkxTto6KC/m58hNNyKxvYxm/cQBu5MI5eMkaiJs2JSQBFiXE3LPQI3seJVjv/2lgALA==}- peerDependencies:- react: ^17.0.2 || ^18.0.0 || ^19.0- react-dom: ^17.0.2 || ^18.0.0 || ^19.0-'@mdx-js/[email protected]':resolution: {integrity: sha512-f6ZO2ifpwAQIpzGWaBQT2TXxPv6z3RBzQKpVftEWN78Vl/YweF1uwussDx8ECAXVtr3Rs89fKyG9YlzUs9DyGQ==}@@ -1832,9 +1763,6 @@ packages:engines: {node: '>=6.0.0'}hasBin: true- resolution: {integrity: sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==}-resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==}@@ -1912,17 +1840,9 @@ packages:resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==}engines: {node: '>=18'}- resolution: {integrity: sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==}- engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}-resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}- resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==}- engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}-resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}engines: {node: '>=6.0'}@@ -1932,9 +1852,6 @@ packages:supports-color:optional: true- resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}-resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}@@ -1971,10 +1888,6 @@ packages:resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==}engines: {node: '>=0.12'}- resolution: {integrity: sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==}- engines: {node: '>=20.19.0'}-resolution: {integrity: sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==}@@ -2227,10 +2140,6 @@ packages:resolution: {integrity: sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==}- resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==}- engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}-resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}@@ -2253,9 +2162,6 @@ packages:resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}engines: {node: '>=12'}- resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}-resolution: {integrity: sha512-iQcBXcd+Rv/pkubRyGh2utW2j1oPG5hZY6TUhVPpqK4G+o3IbxpJNx04hgksjc/N7GK5pEorUxDeg31cFgEk/w==}engines: {node: '>=18'}@@ -2278,15 +2184,6 @@ packages:resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==}hasBin: true- resolution: {integrity: sha512-52v7mUVUfNQVYYqE1lcdaymWL0njO7lTLUog6ZvW2U5KsbiLk/GnZlVJ+qx0xfNJZ6Gn+KSpPNE52vurbxZwrA==}- engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}- peerDependencies:- canvas: ^3.2.3- peerDependenciesMeta:- canvas:- optional: true-resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}engines: {node: '>=6'}@@ -2525,9 +2422,6 @@ packages:resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}- resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}-resolution: {integrity: sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==}@@ -2689,9 +2583,6 @@ packages:resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==}- resolution: {integrity: sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==}-resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==}@@ -2721,10 +2612,6 @@ packages:resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==}- resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}- engines: {node: '>=6'}-resolution: {integrity: sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==}peerDependencies:@@ -2823,10 +2710,6 @@ packages:resolution: {integrity: sha512-Eht5w30ruCXgFmxVUSlNWQ9iiimq07URKeFS3hNc8cUWy1llX4KDWfyEDZRycMc+znsN9Ux5/tJ/BFdgdOwA3A==}- resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}- engines: {node: '>=0.10.0'}-resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}@@ -2838,10 +2721,6 @@ packages:resolution: {integrity: sha512-ePa+XGk00/3HuCqrEnK3LxJW7I0SdNg6EFzKUJG73hMAdDcOUC/i/aSz7LSDwLrGr33kal/rqOGydzwl6U7zBA==}- resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}- engines: {node: '>=v12.22.7'}-resolution: {integrity: sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==}@@ -2921,9 +2800,6 @@ packages:resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==}engines: {node: '>=18'}- resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}-resolution: {integrity: sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw==}@@ -2957,21 +2833,6 @@ packages:resolution: {integrity: sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg==}engines: {node: '>=14.0.0'}- resolution: {integrity: sha512-nYNzS2WRf4QJmjzFFgAxLOBjyBxAGRbCy9PVBPaglcYyYajh40VBn+v5Ngr96ZMc7oM0+aCJdtQnNejvdBnXMQ==}-- resolution: {integrity: sha512-WylhSDKVeYnWXL3a+vKTaOxjnOeEGw938hImY8zoRWJjRRK/Jp1K+IihBzIONpUmW4e3WmXT6q5FW6vlESVZCA==}- hasBin: true-- resolution: {integrity: sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==}- engines: {node: '>=16'}-- resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==}- engines: {node: '>=20'}-resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}@@ -3197,32 +3058,12 @@ packages:jsdom:optional: true- resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}- engines: {node: '>=18'}-resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==}- resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}- engines: {node: '>=20'}-resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==}- resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==}- engines: {node: '>=20'}-- resolution: {integrity: sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==}- engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}-- resolution: {integrity: sha512-ohjk1mdUebJVadRt3bAhQhx8lSnISq+GDttK79LFl8EHQkAPvzwctoasC4hs8tBt6kLAncBWWyq1N52qEfKvDw==}- engines: {node: ^22.14.0 || >=24.0.0}-resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}engines: {node: '>=8'}@@ -3255,17 +3096,10 @@ packages:utf-8-validate:optional: true- resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}- engines: {node: '>=18'}-resolution: {integrity: sha512-bx8Q1STctnNaaDymWnkfQLKofs0mGNN7rLLapJlGuV3VlvegD7Ls4ggMjE3aUSWItCCzU0PEv45lI87iSigiCA==}engines: {node: '>=20.0'}- resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}-resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}@@ -3292,21 +3126,6 @@ packages:snapshots:- '@asamuzakjp/[email protected]':- dependencies:- '@csstools/css-calc': 3.3.0(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])- '@csstools/css-color-parser': 4.2.2(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])- '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])- '@csstools/css-tokenizer': 4.0.0- lru-cache: 11.5.2-- '@asamuzakjp/[email protected]':- dependencies:- bidi-js: 1.1.0- css-tree: 3.2.1- is-potential-custom-element-name: 1.0.1- lru-cache: 11.5.2-'@babel/[email protected]':dependencies:'@babel/helper-validator-identifier': 7.29.7@@ -3438,10 +3257,6 @@ snapshots:'@babel/helper-string-parser': 7.29.7'@babel/helper-validator-identifier': 7.29.7- '@bramus/[email protected]':- dependencies:- css-tree: 3.2.1-'@cloudflare/[email protected]': {}@@ -3485,30 +3300,6 @@ snapshots:dependencies:'@jridgewell/trace-mapping': 0.3.9- '@csstools/[email protected]': {}-- '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':- dependencies:- '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])- '@csstools/css-tokenizer': 4.0.0-- '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':- dependencies:- '@csstools/color-helpers': 6.1.1- '@csstools/css-calc': 3.3.0(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])- '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])- '@csstools/css-tokenizer': 4.0.0-- '@csstools/[email protected](@csstools/[email protected])':- dependencies:- '@csstools/css-tokenizer': 4.0.0-- '@csstools/[email protected]([email protected])':- optionalDependencies:- css-tree: 3.2.1-- '@csstools/[email protected]': {}-'@emnapi/[email protected]':dependencies:tslib: 2.8.1@@ -3670,8 +3461,6 @@ snapshots:'@esbuild/[email protected]':optional: true- '@exodus/[email protected]': {}-'@floating-ui/[email protected]':dependencies:'@floating-ui/utils': 0.2.12@@ -3832,11 +3621,6 @@ snapshots:'@jridgewell/resolve-uri': 3.1.2'@jridgewell/sourcemap-codec': 1.5.5- dependencies:- react: 19.3.0- react-dom: 19.3.0([email protected])-'@mdx-js/[email protected]':dependencies:'@types/estree': 1.0.9@@ -4842,10 +4626,6 @@ snapshots:- dependencies:- require-from-string: 2.0.2-@@ -4908,26 +4688,12 @@ snapshots:- dependencies:- mdn-data: 2.27.1- source-map-js: 1.2.1-- dependencies:- whatwg-mimetype: 5.0.0- whatwg-url: 16.0.1- transitivePeerDependencies:- - '@noble/hashes'-dependencies:ms: 2.1.3- [email protected]: {}-dependencies:character-entities: 2.0.2@@ -4955,8 +4721,6 @@ snapshots:- [email protected]: {}-@@ -5325,12 +5089,6 @@ snapshots:property-information: 7.2.0space-separated-tokens: 2.0.2- dependencies:- '@exodus/bytes': 1.15.1- transitivePeerDependencies:- - '@noble/hashes'-@@ -5348,8 +5106,6 @@ snapshots:- [email protected]: {}-@@ -5364,32 +5120,6 @@ snapshots:dependencies:argparse: 2.0.1- dependencies:- '@asamuzakjp/css-color': 6.0.7- '@asamuzakjp/dom-selector': 8.3.2- '@bramus/specificity': 2.4.2- '@csstools/css-syntax-patches-for-csstree': 1.1.12([email protected])- '@exodus/bytes': 1.15.1- css-tree: 3.2.1- data-urls: 7.0.0- decimal.js: 10.6.0- html-encoding-sniffer: 6.0.0- is-potential-custom-element-name: 1.0.1- lru-cache: 11.5.2- parse5: 8.0.1- saxes: 6.0.0- symbol-tree: 3.2.4- tough-cookie: 6.0.2- undici: 7.29.1- w3c-xmlserializer: 5.0.0- webidl-conversions: 8.0.1- whatwg-mimetype: 5.0.0- whatwg-url: 17.1.1- xml-name-validator: 5.0.0- transitivePeerDependencies:- - '@noble/hashes'-@@ -5679,8 +5409,6 @@ snapshots:dependencies:'@types/mdast': 4.0.4- [email protected]: {}-dependencies:decode-named-character-reference: 1.3.0@@ -6007,10 +5735,6 @@ snapshots:dependencies:entities: 6.0.1- dependencies:- entities: 8.1.0-@@ -6031,8 +5755,6 @@ snapshots:- [email protected]: {}-dependencies:react: 19.3.0@@ -6176,8 +5898,6 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected]: {}-optional: true@@ -6215,10 +5935,6 @@ snapshots:- dependencies:- xmlchars: 2.2.0-@@ -6312,8 +6028,6 @@ snapshots:- [email protected]: {}-@@ -6335,20 +6049,6 @@ snapshots:- [email protected]: {}-- dependencies:- tldts-core: 7.4.12-- dependencies:- tldts: 7.4.12-- dependencies:- punycode: 2.3.1-@@ -6522,7 +6222,7 @@ snapshots:optionalDependencies:vite: 7.3.6(@types/[email protected])([email protected])([email protected])([email protected])([email protected])- [email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):+ [email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected]):dependencies:'@types/chai': 5.2.3'@vitest/expect': 3.2.6@@ -6550,7 +6250,6 @@ snapshots:optionalDependencies:'@types/debug': 4.1.13'@types/node': 22.19.15- jsdom: 30.0.1transitivePeerDependencies:- jiti- less@@ -6565,34 +6264,10 @@ snapshots:- tsx- yaml- dependencies:- xml-name-validator: 5.0.0-- [email protected]: {}-- [email protected]: {}-- dependencies:- '@exodus/bytes': 1.15.1- tr46: 6.0.0- webidl-conversions: 8.0.1- transitivePeerDependencies:- - '@noble/hashes'-- dependencies:- '@exodus/bytes': 1.15.1- tr46: 6.0.0- webidl-conversions: 8.0.1- transitivePeerDependencies:- - '@noble/hashes'-dependencies:siginfo: 2.0.0@@ -6626,8 +6301,6 @@ snapshots:- [email protected]: {}-dependencies:'@oozcitak/dom': 2.0.2@@ -6635,8 +6308,6 @@ snapshots:'@oozcitak/util': 10.0.0js-yaml: 4.3.2- [email protected]: {}-diff --git a/web/src/lib/free-tools/form.tsx b/web/src/lib/free-tools/form.tsxindex f9fb6655..6cd65b9c 100644--- a/web/src/lib/free-tools/form.tsx+++ b/web/src/lib/free-tools/form.tsx@@ -6,12 +6,8 @@ import {type FormEvent,type ReactNode,} from "react";-import {- Turnstile,- DEFAULT_SCRIPT_ID,- type TurnstileInstance,-} from "@marsidev/react-turnstile";import { TOOL_COUNTRIES } from "@/lib/free-tools/countries";+import { useTurnstile } from "@/lib/free-tools/turnstile";const SITE_KEY =import.meta.env.VITE_TURNSTILE_SITE_KEY?.trim() ||@@ -114,11 +110,8 @@ export function ToolForm({cacheDuration?: string;children: ReactNode;}) {- const widget = useRef<TurnstileInstance>(null);const token = useRef("");const submitting = useRef(false);- const scriptFailed = useRef(false);- const [widgetKey, setWidgetKey] = useState(0);const [verification, setVerification] = useState<VerificationStatus>(SITE_KEY ? "loading" : "error",);@@ -130,21 +123,16 @@ export function ToolForm({token.current = "";setVerification("error");};+ const widget = useTurnstile(SITE_KEY, updateToken, fail);const retry = () => {if (!SITE_KEY) return;updateToken();- if (scriptFailed.current) {- document.getElementById(DEFAULT_SCRIPT_ID)?.remove();- scriptFailed.current = false;- setWidgetKey((key) => key + 1);- } else {- widget.current?.reset();- }+ widget.reset();};const submit = async (event: FormEvent) => {event.preventDefault();if (submitting.current || !token.current) return;- if (widget.current?.isExpired()) return retry();+ if (widget.isExpired()) return retry();const verifiedToken = token.current;updateToken();submitting.current = true;@@ -153,7 +141,7 @@ export function ToolForm({} finally {submitting.current = false;updateToken();- widget.current?.reset();+ widget.reset();}};return (@@ -164,25 +152,7 @@ export function ToolForm({<VerificationContext.Provider value={verification}>{children}</VerificationContext.Provider>- {SITE_KEY ? (- <Turnstile- key={widgetKey}- ref={widget}- siteKey={SITE_KEY}- options={{ appearance: "interaction-only", action: "free_tool" }}- onSuccess={updateToken}- onExpire={() => updateToken()}- onError={fail}- onTimeout={fail}- onUnsupported={fail}- scriptOptions={{- onError: () => {- scriptFailed.current = true;- fail();- },- }}- />- ) : null}+ {SITE_KEY ? <div ref={widget.container} /> : null}<p className="mt-2.5 text-xs text-[var(--color-brand-muted)]">Free · No signup</p>diff --git a/web/src/lib/free-tools/turnstile.ts b/web/src/lib/free-tools/turnstile.tsnew file mode 100644index 00000000..91c653a3--- /dev/null+++ b/web/src/lib/free-tools/turnstile.ts@@ -0,0 +1,99 @@+import { useEffect, useRef, useState } from "react";++type TurnstileApi = {+ render: (+ container: HTMLElement,+ options: {+ sitekey: string;+ action: string;+ appearance: "interaction-only";+ callback: (token: string) => void;+ "expired-callback": () => void;+ "error-callback": () => void;+ "timeout-callback": () => void;+ "unsupported-callback": () => void;+ },+ ) => string;+ reset: (id: string) => void;+ remove: (id: string) => void;+ isExpired: (id: string) => boolean;+};++// Share one script across tool pages, including navigation while it is loading.+let scriptPromise: Promise<TurnstileApi> | undefined;+function loadTurnstile() {+ if (scriptPromise) return scriptPromise;+ scriptPromise = new Promise<TurnstileApi>((resolve, reject) => {+ const script = document.createElement("script");+ const fail = () => {+ script.remove();+ scriptPromise = undefined;+ reject(new Error("Turnstile could not load"));+ };+ script.src =+ "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";+ script.async = true;+ script.onerror = fail;+ script.onload = () => {+ const api = (window as Window & { turnstile?: TurnstileApi }).turnstile;+ if (api) resolve(api);+ else fail();+ };+ document.head.appendChild(script);+ });+ return scriptPromise;+}++export function useTurnstile(+ siteKey: string,+ onToken: (token?: string) => void,+ onError: () => void,+) {+ const container = useRef<HTMLDivElement>(null);+ const widget = useRef<{ api: TurnstileApi; id: string } | null>(null);+ const callbacks = useRef({ onToken, onError });+ callbacks.current = { onToken, onError };+ const [attempt, setAttempt] = useState(0);++ useEffect(() => {+ if (!siteKey) return;+ let cancelled = false;+ const fail = () => {+ if (!cancelled) callbacks.current.onError();+ };+ const updateToken = (token?: string) => {+ if (!cancelled) callbacks.current.onToken(token);+ };+ void loadTurnstile()+ .then((api) => {+ if (cancelled || !container.current) return;+ const id = api.render(container.current, {+ sitekey: siteKey,+ action: "free_tool",+ appearance: "interaction-only",+ callback: updateToken,+ "expired-callback": () => updateToken(),+ "error-callback": fail,+ "timeout-callback": fail,+ "unsupported-callback": fail,+ });+ widget.current = { api, id };+ })+ .catch(fail);+ return () => {+ cancelled = true;+ if (widget.current) widget.current.api.remove(widget.current.id);+ widget.current = null;+ };+ }, [siteKey, attempt]);++ return {+ container,+ isExpired: () =>+ !widget.current || widget.current.api.isExpired(widget.current.id),+ reset: () => {+ if (widget.current) widget.current.api.reset(widget.current.id);+ else setAttempt((value) => value + 1);+ },+ };+}diff --git a/web/tests/free-tool-verification.spec.ts b/web/tests/free-tool-verification.spec.tsnew file mode 100644index 00000000..a8f39512--- /dev/null+++ b/web/tests/free-tool-verification.spec.ts@@ -0,0 +1,182 @@+import { expect, test, type Page } from "@playwright/test";++declare global {+ interface Window {+ turnstileTest: {+ callbacks: Record<string, (token?: string) => void>;+ expired: boolean;+ resets: number;+ removed: number;+ rendered: number;+ };+ }+}++const scriptUrl = "**/turnstile/v0/api.js*";+const script = `+ const state = window.turnstileTest = {+ callbacks: {}, expired: false, resets: 0, removed: 0, rendered: 0+ };+ window.turnstile = {+ render(container, options) { state.callbacks = options; return String(++state.rendered); },+ reset() { state.resets++; state.expired = false; },+ remove() { state.removed++; },+ isExpired() { return state.expired; }+ };+`;+let requests: { path: string; token: string }[];+test.beforeEach(async ({ page }) => {+ requests = [];+ await page.route(scriptUrl, (route) =>+ route.fulfill({ contentType: "text/javascript", body: script }),+ );+ // Never call the paid provider endpoints from these browser tests.+ await page.route("**/api/**", (route) => {+ requests.push({+ path: new URL(route.request().url()).pathname,+ token: route.request().postDataJSON()?.turnstileToken,+ });+ return route.fulfill({ status: 503, json: { error: "Test response" } });+ });+});++async function openTool(+ page: Page,+ path = "backlink-checker",+ id = "backlink-target",+) {+ await page.goto(`/${path}`);+ await page.waitForFunction(() => window.turnstileTest?.rendered === 1);+ await page.locator(`#${id}`).fill("example.com");+ return page.locator("form").filter({ has: page.locator(`#${id}`) });+}+const solve = (page: Page, token = "verified-token") =>+ page.evaluate(+ (value) => window.turnstileTest.callbacks.callback(value),+ token,+ );++const tools = [+ ["backlink-checker", "backlink-target", "backlink-check"],+ ["spam-score-checker", "spam-target", "spam-score-checker"],+ ["website-traffic-checker", "traffic-target", "website-traffic-checker"],+ ["competitor-analysis", "competitor-domain", "competitor-analysis"],+ ["domain-age-checker", "age-domains", "domain-age-checker"],+ ["keyword-generator", "keyword-generator-input", "keyword-generator"],+ [+ "competitor-keyword-finder",+ "competitor-keyword-finder-input",+ "competitor-keyword-finder",+ ],+];+for (const [path, id, endpoint] of tools) {+ test(`${path} waits for verification and consumes each token once`, async ({+ page,+ }) => {+ const form = await openTool(page, path, id);+ const button = form.locator('button[type="submit"]');+ await expect(button).toBeDisabled();+ await form.dispatchEvent("submit");+ // Exceed the old three-second fallback: a slow solve must never send a request.+ await page.waitForTimeout(3_100);+ expect(requests).toEqual([]);+ expect(await page.evaluate(() => window.turnstileTest.resets)).toBe(0);++ await solve(page);+ await expect(button).toBeEnabled();+ await form.evaluate((element) => {+ element.dispatchEvent(+ new Event("submit", { bubbles: true, cancelable: true }),+ );+ element.dispatchEvent(+ new Event("submit", { bubbles: true, cancelable: true }),+ );+ });+ await expect(+ form.getByText("Test response", { exact: true }),+ ).toBeVisible();+ expect(requests).toEqual([+ { path: `/api/${endpoint}`, token: "verified-token" },+ ]);+ await expect(button).toBeDisabled();+ await form.dispatchEvent("submit");+ expect(requests).toHaveLength(1);++ await solve(page, "fresh-token");+ await button.click();+ await expect.poll(() => requests.length).toBe(2);+ expect(requests[1].token).toBe("fresh-token");+ });+}++for (const callback of [+ "expired-callback",+ "error-callback",+ "timeout-callback",+ "unsupported-callback",+]) {+ test(`${callback} invalidates the token`, async ({ page }) => {+ const form = await openTool(page);+ await solve(page);+ await page.evaluate(+ (name) => window.turnstileTest.callbacks[name](),+ callback,+ );+ await form.dispatchEvent("submit");+ await expect(form.locator('button[type="submit"]')).toBeDisabled();+ expect(requests).toEqual([]);+ if (callback !== "expired-callback") {+ await form.getByRole("button", { name: "Retry verification" }).click();+ expect(await page.evaluate(() => window.turnstileTest.resets)).toBe(1);+ }+ await solve(page);+ await expect(form.locator('button[type="submit"]')).toBeEnabled();+ });+}++test("checks expiry again at submission", async ({ page }) => {+ const form = await openTool(page);+ await solve(page);+ await page.evaluate(() => {+ window.turnstileTest.expired = true;+ });+ await form.dispatchEvent("submit");+ expect(requests).toEqual([]);+ await expect(form.locator('button[type="submit"]')).toBeDisabled();+ expect(await page.evaluate(() => window.turnstileTest.resets)).toBe(1);+});++test("retries a failed script load", async ({ page }) => {+ await page.route(scriptUrl, (route) => route.abort(), { times: 1 });+ await page.goto("/backlink-checker");+ await page.getByRole("button", { name: "Retry verification" }).click();+ await page.waitForFunction(() => window.turnstileTest?.rendered === 1);+ await solve(page);+ await expect(+ page.getByRole("button", { name: "Check backlinks", exact: true }),+ ).toBeEnabled();+ expect(requests).toEqual([]);+});++test("removes the old widget and reuses the script on client navigation", async ({+ page,+}) => {+ await openTool(page);+ await solve(page);+ const oldCallback = await page.evaluateHandle(+ () => window.turnstileTest.callbacks.callback,+ );+ await page.getByRole("link", { name: "All free tools", exact: true }).click();+ await page.waitForFunction(() => window.turnstileTest.removed === 1);+ await page.goBack();+ await page.waitForFunction(() => window.turnstileTest.rendered === 2);+ expect(await page.evaluate(() => window.turnstileTest.removed)).toBe(1);+ await oldCallback.evaluate((callback) => callback("stale-token"));+ await expect(+ page.locator('form:has(#backlink-target) button[type="submit"]'),+ ).toBeDisabled();+ await solve(page);+ await expect(+ page.getByRole("button", { name: "Check backlinks", exact: true }),+ ).toBeEnabled();+});diff --git a/web/tests/free-tool-verification.test.ts b/web/tests/free-tool-verification.test.tsdeleted file mode 100644index 373393fb..00000000--- a/web/tests/free-tool-verification.test.ts+++ /dev/null@@ -1,172 +0,0 @@-// @vitest-environment jsdom-import { act, createElement, type ComponentType } from "react";-import { createRoot, type Root } from "react-dom/client";-import type { TurnstileProps } from "@marsidev/react-turnstile";-import { afterEach, beforeEach, expect, it, vi } from "vitest";-import { ToolForm, SubmitButton } from "../src/lib/free-tools/form";--const widget = vi.hoisted(() => ({- props: {} as TurnstileProps,- reset: vi.fn(),- isExpired: vi.fn(() => false),-}));-vi.mock("@marsidev/react-turnstile", async () => {- const { forwardRef, useImperativeHandle } = await import("react");- return {- DEFAULT_SCRIPT_ID: "cf-turnstile-script",- Turnstile: forwardRef((props: TurnstileProps, ref) => {- widget.props = props;- useImperativeHandle(ref, () => widget);- return null;- }),- };-});-let root: Root;-let host: HTMLDivElement;-let onSubmit: ReturnType<typeof vi.fn>;-beforeEach(async () => {- vi.clearAllMocks();- vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);- host = document.createElement("div");- document.body.appendChild(host);- root = createRoot(host);- onSubmit = vi.fn().mockResolvedValue(undefined);- await act(async () =>- root.render(- createElement(ToolForm, {- onSubmit,- input: { target: "example.com" },- status: "idle",- errorMessage: "",- children: createElement(SubmitButton, {- status: "idle",- idleLabel: "Check",- }),- }),- ),- );-});-afterEach(async () => {- await act(async () => root.unmount());- host.remove();- vi.unstubAllGlobals();-});-const submit = async () =>- act(async () => {- host- .querySelector("form")!- .dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));- });-const solve = async () =>- act(async () => widget.props.onSuccess!("verified-token"));-const button = () =>- host.querySelector<HTMLButtonElement>('button[type="submit"]')!;--it("does not submit or restart verification until a token exists", async () => {- expect(button().disabled).toBe(true);- await submit();- expect(onSubmit).not.toHaveBeenCalled();- expect(widget.reset).not.toHaveBeenCalled();- await solve();- expect(button().disabled).toBe(false);- await submit();- expect(onSubmit).toHaveBeenCalledWith(- { target: "example.com" },- "verified-token",- );- expect(widget.reset).toHaveBeenCalledOnce();- await submit();- expect(onSubmit).toHaveBeenCalledOnce();-});--it("blocks duplicate submissions and requires a fresh token for the next request", async () => {- let finish!: () => void;- onSubmit.mockImplementationOnce(- () =>- new Promise<void>((resolve) => {- finish = resolve;- }),- );- await solve();- await submit();- await submit();- expect(onSubmit).toHaveBeenCalledOnce();- await act(async () => finish());- expect(button().disabled).toBe(true);- await solve();- await submit();- expect(onSubmit).toHaveBeenCalledTimes(2);-});--it.each(["onExpire", "onError", "onTimeout", "onUnsupported"] as const)(- "%s invalidates a ready token",- async (callback) => {- await solve();- await act(async () => widget.props[callback]!("test-error"));- await submit();- expect(onSubmit).not.toHaveBeenCalled();- expect(button().disabled).toBe(true);- await solve();- await submit();- expect(onSubmit).toHaveBeenCalledOnce();- },-);--it("checks expiry at submit time and retries script failures without submitting", async () => {- await solve();- widget.isExpired.mockReturnValueOnce(true);- await submit();- expect(onSubmit).not.toHaveBeenCalled();- const script = document.createElement("script");- script.id = "cf-turnstile-script";- document.head.appendChild(script);- await act(async () => widget.props.scriptOptions!.onError!());- expect(host.textContent).toContain("Verification could not complete");- await act(async () =>- host.querySelector<HTMLButtonElement>('button[type="button"]')!.click(),- );- expect(script.isConnected).toBe(false);- await solve();- await submit();- expect(onSubmit).toHaveBeenCalledOnce();-});--const tools = [- ["backlink-checker", "BacklinkCheckerTool", "backlink-check"],- ["spam-score-checker", "SpamScoreCheckerTool", "spam-score-checker"],- [- "website-traffic-checker",- "WebsiteTrafficCheckerTool",- "website-traffic-checker",- ],- ["competitor-analysis", "CompetitorAnalysisTool", "competitor-analysis"],- ["domain-age-checker", "DomainAgeCheckerTool", "domain-age-checker"],- ["keyword-discovery", "KeywordDiscoveryTool", "keyword-generator"],- ["keyword-discovery", "KeywordDiscoveryTool", "competitor-keyword-finder"],-];-it.each(tools)(- "%s routes %s through the verified form (%s)",- async (file, name, endpoint) => {- const module = await import(`../src/components/${file}-tool.tsx`);- const Component = module[name] as ComponentType<Record<string, unknown>>;- const fetchMock = vi- .fn()- .mockResolvedValue(- Response.json({ error: "Try again" }, { status: 503 }),- );- vi.stubGlobal("fetch", fetchMock);- await act(async () =>- root.render(createElement(Component, { tool: endpoint })),- );- await submit();- expect(fetchMock).not.toHaveBeenCalled();- await solve();- await submit();- expect(fetchMock).toHaveBeenCalledOnce();- expect(fetchMock.mock.calls[0][0]).toBe(`/api/${endpoint}`);- expect(JSON.parse(fetchMock.mock.calls[0][1].body).turnstileToken).toBe(- "verified-token",- );- expect(button().disabled).toBe(true);- },-);