mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
diffs in htlm
This commit is contained in:
@@ -186,7 +186,6 @@ export default function DraggingContextProvider({
|
|||||||
updateQuizMutation,
|
updateQuizMutation,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
console.log("rerender");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DraggingContext.Provider
|
<DraggingContext.Provider
|
||||||
|
|||||||
11
nextjs/src/services/utils/htmlIsCloseEnough.test.ts
Normal file
11
nextjs/src/services/utils/htmlIsCloseEnough.test.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { htmlIsCloseEnough, removeHtmlDetails } from "./htmlIsCloseEnough";
|
||||||
|
|
||||||
|
describe("html can be close enough", () => {
|
||||||
|
it("scenario 1", () => {
|
||||||
|
const localHTML = `<h2>Local Development Environment</h2><p>Integrate your api </p><ol><li>Set up a docker compose file for local development inside your react frontend git repo.<ul><li>Have two services, one for the client and the other for the api</li><li>Reference the <code>:latest</code> image for your api container</li></ul></li><li>Be sure to mount your react client code as a volume to enable hot reloading</li><li>Configure vite to proxy <code>/api</code> requests to the api container</li><li>Your api should still persist the data, even if the container gets re-created (use a volume)</li></ol><h2>Calling Your API from React</h2><p>Create an <code>apiService.ts</code> 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.</p><h2>Submission</h2><p>Submit screenshots of code relating to each rubric item. Include 1+ questions you would like to ask a the beginning of class</p>`;
|
||||||
|
const canvasHTML = `<link rel="stylesheet" href="https://instructure-uploads-2.s3.amazonaws.com/account_20000000000010/attachments/162497727/DesignPlus%20Mobile%20%25282024%20May%2013%2529.css"><h2>Local Development Environment</h2><p>Integrate your api </p><ol><li>Set up a docker compose file for local development inside your react frontend git repo.<ul><li>Have two services, one for the client and the other for the api</li><li>Reference the <code>:latest</code> image for your api container</li></ul></li><li>Be sure to mount your react client code as a volume to enable hot reloading</li><li>Configure vite to proxy <code>/api</code> requests to the api container</li><li>Your api should still persist the data, even if the container gets re-created (use a volume)</li></ol><h2>Calling Your API from React</h2><p>Create an <code>apiService.ts</code> 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.</p><h2>Submission</h2><p>Submit screenshots of code relating to each rubric item. Include 1+ questions you would like to ask a the beginning of class</p><script src="https://instructure-uploads-2.s3.amazonaws.com/account_20000000000010/attachments/162497726/DesignPlus%20Mobile%20Java%20%25282024%20May%2013%2529.js"></script>`;
|
||||||
|
|
||||||
|
expect(removeHtmlDetails(localHTML)).toBe(removeHtmlDetails(canvasHTML));
|
||||||
|
});
|
||||||
|
});
|
||||||
24
nextjs/src/services/utils/htmlIsCloseEnough.ts
Normal file
24
nextjs/src/services/utils/htmlIsCloseEnough.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
const scriptRegex = /<script.*?<\/script>/g;
|
||||||
|
const linkTagRegex = /<link\s+rel="[^"]*"\s+href="[^"]*"[^>]*>/g;
|
||||||
|
|
||||||
|
export const removeHtmlDetails = (html: string) => {
|
||||||
|
return html
|
||||||
|
.replaceAll(scriptRegex, "")
|
||||||
|
.replaceAll(linkTagRegex, "")
|
||||||
|
.replaceAll(/<hr\s*\/?>/g, "<hr>")
|
||||||
|
.replaceAll(/<br\s*\/?>/g, "<br>")
|
||||||
|
.replaceAll(/>/g, "")
|
||||||
|
.replaceAll(/</g, "")
|
||||||
|
.replaceAll(/>/g, "")
|
||||||
|
.replaceAll(/</g, "")
|
||||||
|
.replaceAll(/"/g, "")
|
||||||
|
.replaceAll(/"/g, "")
|
||||||
|
.replaceAll(/&/g, "")
|
||||||
|
.replaceAll(/&/g, "");
|
||||||
|
};
|
||||||
|
|
||||||
|
export const htmlIsCloseEnough = (html1: string, html2: string) => {
|
||||||
|
const simple1 = removeHtmlDetails(html1);
|
||||||
|
const simple2 = removeHtmlDetails(html2);
|
||||||
|
return simple1 === simple2;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user