From f5ed405c7997b9b6cf822663273c3fb5e4c3ee69 Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Fri, 27 Sep 2024 13:30:13 -0600 Subject: [PATCH] diffs in htlm --- .../context/DraggingContextProvider.tsx | 1 - .../services/utils/htmlIsCloseEnough.test.ts | 11 +++++++++ .../src/services/utils/htmlIsCloseEnough.ts | 24 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 nextjs/src/services/utils/htmlIsCloseEnough.test.ts create mode 100644 nextjs/src/services/utils/htmlIsCloseEnough.ts diff --git a/nextjs/src/app/course/[courseName]/context/DraggingContextProvider.tsx b/nextjs/src/app/course/[courseName]/context/DraggingContextProvider.tsx index 331b87c..0d38bf3 100644 --- a/nextjs/src/app/course/[courseName]/context/DraggingContextProvider.tsx +++ b/nextjs/src/app/course/[courseName]/context/DraggingContextProvider.tsx @@ -186,7 +186,6 @@ export default function DraggingContextProvider({ updateQuizMutation, ] ); - console.log("rerender"); return ( { + it("scenario 1", () => { + const localHTML = `

Local Development Environment

Integrate your api

  1. Set up a docker compose file for local development inside your react frontend git repo.
    • Have two services, one for the client and the other for the api
    • Reference the :latest image for your api container
  2. Be sure to mount your react client code as a volume to enable hot reloading
  3. Configure vite to proxy /api requests to the api container
  4. Your api should still persist the data, even if the container gets re-created (use a volume)

Calling Your API from React

Create an apiService.ts file to store all functions that make api calls. Have your inventory item context load your items from the api on startup. Use the api calls for all CRUD operations on your app. When modifying the list of items, ensure the item is modified on the api before you show the modified value on the client.

Submission

Submit screenshots of code relating to each rubric item. Include 1+ questions you would like to ask a the beginning of class

`; + const canvasHTML = `

Local Development Environment

Integrate your api

  1. Set up a docker compose file for local development inside your react frontend git repo.
    • Have two services, one for the client and the other for the api
    • Reference the :latest image for your api container
  2. Be sure to mount your react client code as a volume to enable hot reloading
  3. Configure vite to proxy /api requests to the api container
  4. Your api should still persist the data, even if the container gets re-created (use a volume)

Calling Your API from React

Create an apiService.ts file to store all functions that make api calls. Have your inventory item context load your items from the api on startup. Use the api calls for all CRUD operations on your app. When modifying the list of items, ensure the item is modified on the api before you show the modified value on the client.

Submission

Submit screenshots of code relating to each rubric item. Include 1+ questions you would like to ask a the beginning of class

`; + + expect(removeHtmlDetails(localHTML)).toBe(removeHtmlDetails(canvasHTML)); + }); +}); diff --git a/nextjs/src/services/utils/htmlIsCloseEnough.ts b/nextjs/src/services/utils/htmlIsCloseEnough.ts new file mode 100644 index 0000000..36aa402 --- /dev/null +++ b/nextjs/src/services/utils/htmlIsCloseEnough.ts @@ -0,0 +1,24 @@ +const scriptRegex = //g; +const linkTagRegex = /]*>/g; + +export const removeHtmlDetails = (html: string) => { + return html + .replaceAll(scriptRegex, "") + .replaceAll(linkTagRegex, "") + .replaceAll(//g, "
") + .replaceAll(//g, "
") + .replaceAll(/>/g, "") + .replaceAll(/</g, "") + .replaceAll(/>/g, "") + .replaceAll(/ { + const simple1 = removeHtmlDetails(html1); + const simple2 = removeHtmlDetails(html2); + return simple1 === simple2; +};