From 528e70733f39dfe49fd8db3d3d2cb5b0849ab64f Mon Sep 17 00:00:00 2001 From: Syd Amir Date: Fri, 26 Jan 2024 19:27:53 +0330 Subject: [PATCH] :bento: move faker from cdn to esh --- src/server/playground/comp/E2E.tsx | 979 ++++++++++---------- src/server/playground/comp/Setting.tsx | 3 +- src/server/playground/dist/bundle-es.js | 2 +- src/server/playground/dist/bundle-es.js.map | 4 +- src/server/playground/dist/bundleContent.ts | 2 +- 5 files changed, 503 insertions(+), 487 deletions(-) diff --git a/src/server/playground/comp/E2E.tsx b/src/server/playground/comp/E2E.tsx index 94f52bd2..8387b224 100644 --- a/src/server/playground/comp/E2E.tsx +++ b/src/server/playground/comp/E2E.tsx @@ -1,10 +1,9 @@ /** @jsx h */ import { Fragment, h, useRef, useState } from "../reactDeps.ts"; import { uid } from "../utils/uid.ts"; -import { faker } from "https://cdn.skypack.dev/@faker-js/faker"; +import { faker } from "https://esm.sh/@faker-js/faker"; import { E2eForm, TRequest } from "./context/actionType.ts"; import { e2eFirstInp } from "./context/initials.ts"; -import { Help } from "./Help.tsx"; import AddIcon from "./icon/AddIcon.tsx"; import BackIcon from "./icon/BackIcon.tsx"; import DeleteIcon from "./icon/DeleteIcon.tsx"; @@ -91,8 +90,9 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { }; const [isShowE2eButton, setIsShowE2eButton] = useState(false); - const [requestDetail, setRequestDetail] = - useState(initialRequestDetail); + const [requestDetail, setRequestDetail] = useState( + initialRequestDetail, + ); const handleMove = (fromIndex: any, toIndex: any) => { if (fromIndex === 0 && toIndex <= 0) { @@ -123,9 +123,11 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { const [view, setView] = useState<"help" | "e2e" | "result">("e2e"); const exportForm = () => { - const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent( - JSON.stringify(e2eForms) - )}`; + const jsonString = `data:text/json;chatset=utf-8,${ + encodeURIComponent( + JSON.stringify(e2eForms), + ) + }`; const link = document.createElement("a"); link.href = jsonString; link.download = "Configdata.json"; @@ -143,9 +145,11 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { }; const exportResults = () => { - const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent( - JSON.stringify(requestDetail) - )}`; + const jsonString = `data:text/json;chatset=utf-8,${ + encodeURIComponent( + JSON.stringify(requestDetail), + ) + }`; const link = document.createElement("a"); link.href = jsonString; link.download = "data.json"; @@ -167,7 +171,7 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { const replaceCaptureString = ( obj: Record, variablesSet: Set, - returnCaptures: captureType[] + returnCaptures: captureType[], ) => { for (const key in obj) { if (typeof obj[key] === "object") { @@ -197,7 +201,7 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { openBraceIndexes.forEach((openBrace, index) => { variablesName.push( - value.slice(openBrace + 1, closeBraceIndexes[index]) + value.slice(openBrace + 1, closeBraceIndexes[index]), ); }); } @@ -212,12 +216,12 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { fnInputs = secondSection .slice( secondSection.indexOf("(") + 1, - secondSection.indexOf(")") + secondSection.indexOf(")"), ) .replaceAll("'", '"'); secondSection = secondSection.slice( 0, - secondSection.indexOf("(") + secondSection.indexOf("("), ); } const callParsedFaker = (faker as any)[parsedFaker[1]][ @@ -264,7 +268,7 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { const usedCaptures = replaceCaptureString( parsedHeaderBody, parsedCaptures, - [] + [], ); const body: TRequest = { @@ -296,7 +300,7 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { setRequestDetail((preReqDetails) => { const sequnces = preReqDetails.sequenceDetail; const findedSequnceIdx = sequnces.findIndex( - (sq) => sq.id === sequnceId + (sq) => sq.id === sequnceId, ); let resultIdx = 1; if (findedSequnceIdx !== -1) { @@ -317,8 +321,8 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { sequnces[findedSequnceIdx].fails = sequnces[findedSequnceIdx].fails + 1; } - sequnces[findedSequnceIdx].time = - sequnces[findedSequnceIdx].time + tResPerformance; + sequnces[findedSequnceIdx].time = sequnces[findedSequnceIdx].time + + tResPerformance; sequnces[findedSequnceIdx].repeat = sequnces[findedSequnceIdx].repeat + 1; } else { @@ -341,17 +345,16 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { usedCaptures: usedCaptures.map(({ key, value }) => { const findedInsideParsedCapture = findInParsedCaptures( value, - parsedCaptures + parsedCaptures, ); return { key, value, captured: findedInsideParsedCapture?.captured, - sequenceIdx: - findedInsideParsedCapture?.sequenceIdx || - findedInsideParsedCapture?.sequenceIdx === 0 - ? findedInsideParsedCapture?.sequenceIdx + 1 - : undefined, + sequenceIdx: findedInsideParsedCapture?.sequenceIdx || + findedInsideParsedCapture?.sequenceIdx === 0 + ? findedInsideParsedCapture?.sequenceIdx + 1 + : undefined, model: findedInsideParsedCapture?.model, act: findedInsideParsedCapture?.act, }; @@ -361,8 +364,8 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { } return { - allReqPerformance: - preReqDetails.allReqPerformance + tResPerformance, + allReqPerformance: preReqDetails.allReqPerformance + + tResPerformance, numberRequest: preReqDetails.numberRequest + 1, success: jsonSendedRequest.success ? preReqDetails.success + 1 @@ -370,26 +373,24 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { fails: jsonSendedRequest.success ? preReqDetails.fails : preReqDetails.fails + 1, - bestTime: - preReqDetails.bestTime.time < tResPerformance - ? preReqDetails.bestTime - : { - resultIdx, - sequenceIdx: sequnces.length, - act: parsedHeaderBody.body.act, - model: parsedHeaderBody.body.model, - time: tResPerformance, - }, - worstTime: - preReqDetails.worstTime.time > tResPerformance - ? preReqDetails.worstTime - : { - resultIdx, - sequenceIdx: sequnces.length, - act: parsedHeaderBody.body.act, - model: parsedHeaderBody.body.model, - time: tResPerformance, - }, + bestTime: preReqDetails.bestTime.time < tResPerformance + ? preReqDetails.bestTime + : { + resultIdx, + sequenceIdx: sequnces.length, + act: parsedHeaderBody.body.act, + model: parsedHeaderBody.body.model, + time: tResPerformance, + }, + worstTime: preReqDetails.worstTime.time > tResPerformance + ? preReqDetails.worstTime + : { + resultIdx, + sequenceIdx: sequnces.length, + act: parsedHeaderBody.body.act, + model: parsedHeaderBody.body.model, + time: tResPerformance, + }, sequenceDetail: sequnces, allCaptureItems: Array.from(parsedCaptures), }; @@ -397,7 +398,7 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { } const captures = [...e2eForm.captures].filter( - (capture) => capture.key && capture.value + (capture) => capture.key && capture.value, ); const parsedCapuresValue = captures.map((capture) => { @@ -438,7 +439,7 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { const handeE2eFormDetails = ( idx: number, fieldName: keyof E2eForm, - value: any + value: any, ) => { const copy = [...e2eForms]; (copy[idx] as any)[fieldName] = value; @@ -454,457 +455,473 @@ export function E2E({ baseUrl }: { baseUrl: string; bodyHeaders?: string }) { return (
- {view === "result" ? ( -
-
- - -
-
- Information -
- Requests{" "} -
-

- All Request Count:{" "} - - {requestDetail.numberRequest} - {" "} - times -

{" "} -

- {" "} - All Request Time:{" "} - - {requestDetail.allReqPerformance} - {" "} - ms -

+ {view === "result" + ? ( +
+
+ + +
+
+ Information +
+ Requests + {" "} +
+

+ All Request Count:{" "} + + {requestDetail.numberRequest} + {" "} + times +

{" "} +

+ {" "} + All Request Time:{" "} + + {requestDetail.allReqPerformance} + {" "} + ms +

+
+
+

+ All Success Request: + {" "} + + {requestDetail.success} + {" "} + {" "} + times +

+

+ All Fails Request :{" "} + + {requestDetail.fails} + {" "} + + times +

+
-
-

- All Success Request:{" "} - - {requestDetail.success}{" "} - {" "} - times -

-

- All Fails Request :{" "} - - {requestDetail.fails}{" "} - - times -

+
+ Times{" "} +
    +
  • + {" "} + Best Request Time:{" "} + + {requestDetail.bestTime.time} + {" "} + + ms{" "} +
  • +
  • + {" "} + Seqeunce Number:{" "} + { + handleClick(requestDetail.bestTime.sequenceIdx); + }} + className="information-container--request--sections--item--content e2e-sequensce-number" + > + {requestDetail.bestTime.sequenceIdx} + {" "} + +
  • +
  • + {" "} + Request Number:{" "} + + {requestDetail.bestTime.resultIdx} + + {" "} +
  • +
  • + Model:{" "} + + {requestDetail.bestTime.model} + {" "} + + {" "} +
  • +
  • + Act:{" "} + + {requestDetail.bestTime.act} + {" "} + +
  • +
+
    +
  • + Worst Request Time:{" "} + + {requestDetail.worstTime.time} + {" "} + ms{" "} +
  • +
  • + {" "} + Seqeunce Number:{" "} + { + handleClick(requestDetail.worstTime.sequenceIdx); + }} + className="information-container--request--sections--item--content e2e-sequensce-number" + > + {requestDetail.worstTime.sequenceIdx} + {" "} + +
  • +
  • + {" "} + Request Number:{" "} + + {requestDetail.worstTime.resultIdx} + {" "} + +
  • +
  • + Model:{" "} + + {requestDetail.worstTime.model} + +
  • +
  • + act:{" "} + + {requestDetail.worstTime.act} + +
  • +
-
-
- Times{" "} -
    -
  • - {" "} - Best Request Time:{" "} - - {requestDetail.bestTime.time}{" "} - - ms{" "} -
  • -
  • - {" "} - Seqeunce Number:{" "} - { - handleClick(requestDetail.bestTime.sequenceIdx); - }} - className="information-container--request--sections--item--content e2e-sequensce-number" - > - {requestDetail.bestTime.sequenceIdx}{" "} - -
  • -
  • - {" "} - Request Number:{" "} - - {requestDetail.bestTime.resultIdx} + {requestDetail.allCaptureItems.length > 0 && ( +
    + + Captures Information {" "} -
  • -
  • - Model:{" "} - - {requestDetail.bestTime.model}{" "} - {" "} -
  • -
  • - Act:{" "} - - {requestDetail.bestTime.act}{" "} - -
  • -
-
    -
  • - Worst Request Time:{" "} - - {requestDetail.worstTime.time} - {" "} - ms{" "} -
  • -
  • - {" "} - Seqeunce Number:{" "} - { - handleClick(requestDetail.worstTime.sequenceIdx); - }} - className="information-container--request--sections--item--content e2e-sequensce-number" - > - {requestDetail.worstTime.sequenceIdx}{" "} - -
  • -
  • - {" "} - Request Number:{" "} - - {requestDetail.worstTime.resultIdx}{" "} - -
  • -
  • - Model:{" "} - - {requestDetail.worstTime.model} - -
  • -
  • - act:{" "} - - {requestDetail.worstTime.act} - -
  • -
-
- {requestDetail.allCaptureItems.length > 0 && ( -
- - Captures Information - {" "} - {requestDetail.allCaptureItems.map((ci) => ( -
    - - {ci.key} - -
  • - Captured From:{" "} - - {ci.captured} - -
  • -
  • - Value Of{" "} - - : {ci.value} - -
  • -
  • - Model :{" "} - - {ci.model} - -
  • -
  • - Act :{" "} - - {ci.act} - -
  • -
  • - Captured Inside Sequnce Number:{" "} - - {ci.sequenceIdx} + {requestDetail.allCaptureItems.map((ci) => ( +
      + + {ci.key} - -
    - ))} -
- )} -
+
  • + Captured From:{" "} + + {ci.captured} + +
  • +
  • + Value Of{" "} + + : {ci.value} + +
  • +
  • + Model :{" "} + + {ci.model} + +
  • +
  • + Act :{" "} + + {ci.act} + +
  • +
  • + Captured Inside Sequnce Number:{" "} + + {ci.sequenceIdx} + +
  • + + ))} +
    + )} +
    -
    - {requestDetail.sequenceDetail.map((sequence, idx) => { - return ; - })} +
    + {requestDetail.sequenceDetail.map((sequence, idx) => { + return ; + })} +
    -
    - ) : view === "e2e" ? ( - -
    - {e2eForms.map((e2eForm, idx) => ( - -
    -
    -
    handleDuplicate(idx)} - > - -
    - {e2eForms.length > 1 && ( - -
    handleMove(idx, idx - 1)} - > - -
    -
    handleMove(idx, idx + 1)} - > - -
    -
    handleDelete(idx)} - > - -
    -
    - )} -
    -
    -
    - set test body and headers -
    -