@donotdev/testing 0.1.42 → 0.1.44
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/dist/client/debugIsousou.js +1 -1
- package/dist/client/testEntity.js +1 -1
- package/dist/client/testImagePipeline.js +1 -1
- package/dist/client/testImageUpload.js +1 -1
- package/dist/common/index.js +1 -1
- package/dist/common/reporter.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getProvider as p}from"@donotdev/core";import{testStorage as d}from"./testStorage";import{testEntity as h}from"./testEntity";import{testImagePipeline as S}from"./testImagePipeline";import{testImageUpload as f}from"./testImageUpload";async function b(a,
|
|
1
|
+
import{getProvider as p}from"@donotdev/core";import{testStorage as d}from"./testStorage";import{testEntity as h}from"./testEntity";import{testImagePipeline as S}from"./testImagePipeline";import{testImageUpload as f}from"./testImageUpload";async function b(a,c={}){const{pipeline:i,crudFns:l,pictures:t,files:r,skipStorage:g=!1,skipPipeline:u=!1,skipCrud:m=!1}=c,o=p("storage"),w=p("crud"),P=p("callable"),n={reference:`TEST-${Date.now().toString(36).toUpperCase()}`,address:{formatted_address:"1 rue de Rivoli, 75001 Paris, France",latitude:48.8606,longitude:2.3376},district_code:1};if(!g){const e=await d({storage:o}),s=await d({storage:o,storagePath:"test"});if(!(!e.passed&&s.passed)&&!(e.passed&&!s.passed)&&!e.passed&&!s.passed)return}if(!u){const e={...n};if(t&&t.length>0&&(e.pictures=t),await S({entity:a,input:e,fns:l}),i&&(await f({fns:i}),r&&r.length>0))for(const s of r)await f({fns:i,file:s})}!m&&a&&await h(a,{providers:{crud:w,storage:o,callable:P},payload:{...n,...t&&t.length>0?{pictures:t}:{}}})}export{b as debugIsousou};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EDITABLE as v}from"@donotdev/core";import{generatePayload as
|
|
1
|
+
import{EDITABLE as v}from"@donotdev/core";import{generatePayload as D,getFileFields as P,isMultiFileField as $}from"../common/payloadGenerator";import{reportEntity as C}from"../common/reporter";import{createTestImageBlob as F,createTestFileBlob as M}from"./testStorage";async function y(a,w){const r=performance.now();try{const o=await w();return{step:a,passed:!0,duration:Math.round(performance.now()-r),data:o}}catch(o){return{step:a,passed:!1,duration:Math.round(performance.now()-r),error:o instanceof Error?o.message:String(o),errorDetail:o}}}async function _(a,w,r,o){const g=[],n={};for(const l of a){const p=["image","images","avatar"].includes(l.type),u=$(l),d=l.options?.fieldSpecific?.storagePath??r,h=p?"upload-image":"upload-file",s=await y(h,async()=>{const t=p?F():M(),E=p?"png":"txt",f=`dndev_test_${l.name}_${Date.now()}.${E}`,m=await w.upload(t,{storagePath:d,filename:f,signal:o,onProgress:e=>{}});if(p){const e={fullUrl:m.url,thumbUrl:m.url};n[l.name]=u?[e]:e}else{const e={url:m.url,filename:f,size:t.size,mimeType:t.type};n[l.name]=u?[e]:e}return m});g.push({...s,step:`${h}`}),s.passed||(n[l.name]=u?[]:null)}return{results:g,values:n}}async function k(a,w){const{providers:r,payload:o,cleanup:g=!0,skip:n=[],storagePath:l,signal:p}=w,{crud:u}=r,d=a.collection,h=performance.now(),s=[];let t;const E=await y("generate-payload",async()=>D(a.fields,o));if(s.push(E),!E.passed)return T(a,d,s,t,void 0,h);let f=E.data;const m=P(a.fields);if(m.length>0&&r.storage){const{results:e,values:i}=await _(m,r.storage,l,p);s.push(...e),f={...f,...i}}else m.length>0&&r.storage;if(!n.includes("create")){const e=await y("create",async()=>{const i=await u.add(d,f);return t=i.id,i});if(s.push(e),!e.passed)return T(a,d,s,t,f,h)}if(!n.includes("get")&&t){const e=await y("get",async()=>{const i=await u.get(d,t);if(!i)throw new Error(`get returned null for id=${t}`);return i});s.push(e)}if(!n.includes("list")){const e=await y("list",async()=>{const i=await u.query(d,{limit:5});if(t){const b=i.items.some(c=>c.id===t)}return i});s.push(e)}if(!n.includes("listCard")){const e=await y("listCard",async()=>await u.query(d,{limit:5},void 0,"listCard"));s.push(e)}if(!n.includes("update")&&t){const e=await y("update",async()=>{const i=Object.values(a.fields).find(c=>c.type==="text"&&c.editable!==!1&&c.editable!==v.GENERATED&&c.editable!==v.COMPUTED&&c.editable!==v.CREATE_ONLY&&c.visibility!=="hidden"&&c.visibility!=="technical"),b=i?{[i.name]:`updated_${Date.now().toString(36)}`}:{};return Object.keys(b).length===0?{skipped:!0}:(await u.update(d,t,b),b)});s.push(e)}if(!n.includes("delete")&&t&&g){const e=await y("delete",async()=>{await u.delete(d,t)});s.push(e)}return T(a,d,s,t,f,h)}function T(a,w,r,o,g,n){const l={entity:a.name,collection:w,passed:r.every(p=>p.passed),steps:r,createdId:o,payload:g,duration:Math.round(performance.now()-n)};return C(l),l}export{k as testEntity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reportImagePipeline as U}from"../common/reporter";import{generatePayload as
|
|
1
|
+
import{reportImagePipeline as U}from"../common/reporter";import{generatePayload as j,getFileFields as w}from"../common/payloadGenerator";async function d(e,a){const f=performance.now();try{const t=await a();return{step:e,passed:!0,duration:Math.round(performance.now()-f),data:t}}catch(t){return{step:e,passed:!1,duration:Math.round(performance.now()-f),error:t instanceof Error?t.message:String(t),errorDetail:t}}}async function v(e){const{entity:a,input:f={},fns:t}=e,y=performance.now(),c=[];let i;const m=await d("generate-payload",async()=>{const o=j(a.fields,f);for(const[r,s]of Object.entries(o)){const l=A(s),u=r in f?" (override)":""}const n=w(a.fields);if(n.length>0)for(const r of n){const s=o[r.name]}return o});if(c.push(m),!m.passed)return g(c,void 0,y);if(i=m.data,t?.validate){const o=await d("upload-pipeline",async()=>{const n=t.validate(i);return typeof n=="object"&&n!==null&&(i=n),n});if(c.push(o),!o.passed)return g(c,i,y)}const p=w(a.fields).filter(o=>["image","images","avatar"].includes(o.type));if(p.length>0){const o=await d("verify-full-url",async()=>{const r=[];for(const s of p){const l=i[s.name];l!=null&&(Array.isArray(l)?l:[l]).forEach((u,b)=>{const h=`${s.name}[${b}]`;u.fullUrl?u.fullUrl.startsWith("blob:")&&r.push(`${h}.fullUrl is blob: ${u.fullUrl}`):r.push(`${h}.fullUrl is empty`)})}if(r.length>0){for(const s of r);throw new Error(`${r.length} URL issue(s): ${r.join("; ")}`)}return{checked:p.length}});c.push(o);const n=await d("verify-thumb-url",async()=>{const r=[];for(const s of p){const l=i[s.name];l!=null&&(Array.isArray(l)?l:[l]).forEach((u,b)=>{const h=`${s.name}[${b}]`;u.thumbUrl?u.thumbUrl.startsWith("blob:")&&r.push(`${h}.thumbUrl is blob: ${u.thumbUrl}`):r.push(`${h}.thumbUrl is empty`)})}if(r.length>0){for(const s of r);throw new Error(`${r.length} thumbUrl issue(s): ${r.join("; ")}`)}return{checked:p.length}});c.push(n)}if(t?.createMetadata){const o=await d("cleanup-image",async()=>{const n=t.createMetadata();for(const[r,s]of Object.entries(n));return i={...i,...n},n});c.push(o)}for(const[o,n]of Object.entries(i));const $=g(c,i,y);return U($),$}function A(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>60?`"${e.slice(0,57)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const a=Object.keys(e);return`{${a.slice(0,4).join(", ")}${a.length>4?", ...":""}}`}return String(e)}function g(e,a,f){return{passed:e.every(t=>t.passed),steps:e,payload:a,duration:Math.round(performance.now()-f)}}export{v as testImagePipeline};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reportImageUpload as
|
|
1
|
+
import{reportImageUpload as E}from"../common/reporter";function U(s="dndev_test.png"){const r=document.createElement("canvas");r.width=100,r.height=100;const e=r.getContext("2d");if(!e)throw new Error("Failed to get canvas 2d context");e.fillStyle="#CC2200",e.fillRect(0,0,100,100),e.strokeStyle="#FFFFFF",e.lineWidth=3,e.beginPath(),e.moveTo(0,0),e.lineTo(100,100),e.stroke();const n=r.toDataURL("image/png").split(",")[1]??"",u=atob(n),c=new Uint8Array(u.length);for(let l=0;l<u.length;l++)c[l]=u.charCodeAt(l);return new File([c],s,{type:"image/png"})}async function p(s,r){const e=performance.now();try{const n=await r();return{step:s,passed:!0,duration:Math.round(performance.now()-e),data:n}}catch(n){return{step:s,passed:!1,duration:Math.round(performance.now()-e),error:n instanceof Error?n.message:String(n),errorDetail:n}}}async function I(s){const{fns:r,storagePath:e,verifyUrls:n=!0,cleanup:u=!0,signal:c}=s,l=s.file??U(),m=performance.now(),h=[];let o,f,d,g;if(r.processImage){const a=await p("process-image",async()=>{const t=await r.processImage(l);return t.fullBlob.size,t.thumbBlob.size,t.fullBlob.type,t.thumbBlob.type,d=t.fullBlob,g=t.thumbBlob,f={fullSize:t.fullBlob.size,thumbSize:t.thumbBlob.size,width:t.width,height:t.height},{fullSize:t.fullBlob.size,thumbSize:t.thumbBlob.size,width:t.width,height:t.height}});if(h.push(a),!a.passed)return w(h,o,f,m)}else d=l,g=l;const b=await p("upload-pipeline",async()=>{const a=await r.uploadImage(d,g,l.name,{storagePath:e,signal:c,onProgress:t=>{}});if(!a.fullUrl)throw new Error("uploadImage returned empty fullUrl");if(!a.thumbUrl)throw new Error("uploadImage returned empty thumbUrl");if(a.fullUrl.startsWith("blob:"))throw new Error(`fullUrl is a blob URL: ${a.fullUrl}`);if(a.thumbUrl.startsWith("blob:"))throw new Error(`thumbUrl is a blob URL: ${a.thumbUrl}`);return o=a,a});if(h.push(b),!b.passed)return w(h,o,f,m);if(n&&o){const a=await p("verify-full-url",async()=>{const i=await fetch(o.fullUrl,{method:"HEAD",signal:c});if(!i.ok)throw new Error(`fullUrl returned HTTP ${i.status}`);return{status:i.status,contentType:i.headers.get("content-type")}});h.push(a);const t=await p("verify-thumb-url",async()=>{const i=await fetch(o.thumbUrl,{method:"HEAD",signal:c});if(!i.ok)throw new Error(`thumbUrl returned HTTP ${i.status}`);return{status:i.status,contentType:i.headers.get("content-type")}});h.push(t)}if(u&&r.deleteImage&&o){const a=await p("cleanup-image",async()=>(await r.deleteImage(o),{deleted:[o.fullUrl,o.thumbUrl]}));h.push(a)}else u&&r.deleteImage;const y=w(h,o,f,m);return E(y),y}function w(s,r,e,n){return{passed:s.every(u=>u.passed),steps:s,picture:r,processed:e,duration:Math.round(performance.now()-n)}}export{U as createTestImageFile,I as testImageUpload};
|
package/dist/common/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generatePayload as e,getFileFields as i,isFileField as a,isMultiFileField as t}from"./payloadGenerator";import{reportEntity as
|
|
1
|
+
import{generatePayload as e,getFileFields as i,isFileField as a,isMultiFileField as t}from"./payloadGenerator";import{reportEntity as s,reportStorage as r}from"./reporter";export{e as generatePayload,i as getFileFields,a as isFileField,t as isMultiFileField,s as reportEntity,r as reportStorage};
|
package/dist/common/reporter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a(
|
|
1
|
+
function a(o){return o?"\x1B[32mPASS\x1B[0m":"\x1B[31mFAIL\x1B[0m"}function r(o){return o<1e3?`${o}ms`:`${(o/1e3).toFixed(2)}s`}function f(o){const s=o.passed?" +":" x",e=r(o.duration),n=o.error?` \u2014 ${o.error}`:"";return`${s} ${o.step} (${e})${n}`}function t(o){const s=`[${a(o.passed)}] ${o.entity} (${o.collection}) \u2014 ${r(o.duration)}`;o.createdId;for(const e of o.steps);if(!o.passed&&o.payload){const e=o.steps.find(n=>n.step==="create"&&!n.passed)}for(const e of o.steps)!e.passed&&e.errorDetail}function p(o){const s=`[${a(o.passed)}] Storage test \u2014 ${r(o.duration)}`;for(const e of o.steps);for(const e of o.steps)!e.passed&&e.errorDetail}function c(o){const s=`[${a(o.passed)}] Image Upload \u2014 ${r(o.duration)}`;o.processed,o.picture;for(const e of o.steps);for(const e of o.steps)!e.passed&&e.errorDetail}function i(o){const s=`[${a(o.passed)}] Image Pipeline \u2014 ${r(o.duration)}`;for(const e of o.steps);for(const e of o.steps)!e.passed&&e.errorDetail}export{t as reportEntity,i as reportImagePipeline,c as reportImageUpload,p as reportStorage};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{testEntity as e}from"./client/testEntity";import{testStorage as a,createTestImageBlob as t,createTestFileBlob as s}from"./client/testStorage";import{testImagePipeline as r}from"./client/testImagePipeline";import{testImageUpload as
|
|
1
|
+
import{testEntity as e}from"./client/testEntity";import{testStorage as a,createTestImageBlob as t,createTestFileBlob as s}from"./client/testStorage";import{testImagePipeline as r}from"./client/testImagePipeline";import{testImageUpload as o,createTestImageFile as i}from"./client/testImageUpload";import{debugIsousou as l}from"./client/debugIsousou";import{debugC4all as m}from"./client/debugC4all";import{generatePayload as p,getFileFields as g,isFileField as d,isMultiFileField as F}from"./common/payloadGenerator";import{reportEntity as I,reportStorage as n,reportImagePipeline as u,reportImageUpload as b}from"./common/reporter";export{s as createTestFileBlob,t as createTestImageBlob,i as createTestImageFile,m as debugC4all,l as debugIsousou,p as generatePayload,g as getFileFields,d as isFileField,F as isMultiFileField,I as reportEntity,u as reportImagePipeline,b as reportImageUpload,n as reportStorage,e as testEntity,r as testImagePipeline,o as testImageUpload,a as testStorage};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/testing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@donotdev/core": "^0.1.
|
|
26
|
+
"@donotdev/core": "^0.1.43"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|