From 3e974ca16f7c6e330ef95b7ec87ba069174c0c69 Mon Sep 17 00:00:00 2001 From: DonoCodePeriod <135299863+DonoCodePeriod@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:21:31 -0400 Subject: [PATCH 1/5] "uncommented Devtools for electron and config setting in package-lock --- package-lock.json | 11 ----------- public/electron.jsx | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 08f75217..d087d471 100644 --- a/package-lock.json +++ b/package-lock.json @@ -120,7 +120,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", - "dev": true, "dependencies": { "@jridgewell/gen-mapping": "^0.1.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -764,7 +763,6 @@ "version": "7.20.12", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.12.tgz", "integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==", - "dev": true, "dependencies": { "@ampproject/remapping": "^2.1.0", "@babel/code-frame": "^7.18.6", @@ -1118,7 +1116,6 @@ "version": "7.20.13", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.20.13.tgz", "integrity": "sha512-nzJ0DWCL3gB5RCXbUO3KIMMsBY2Eqbx8mBpKGE/02PgyRQFcPQLbkQ1vyy596mZLaP+dAfD+R4ckASzNVmW3jg==", - "dev": true, "dependencies": { "@babel/template": "^7.20.7", "@babel/traverse": "^7.20.13", @@ -3236,7 +3233,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.2.tgz", "integrity": "sha512-eFZVFoRXb3GFGd7Ak7W4+6jBl9wBtiZ4AaYOse97ej6mKj5tkyO0dUnUChs1IhJZtx1BENo4/p4WUTXpi6vT+g==", - "dev": true, "dependencies": { "debug": "^4.1.1", "env-paths": "^2.2.0", @@ -3257,7 +3253,6 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -3271,7 +3266,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -3280,7 +3274,6 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, "engines": { "node": ">= 4.0.0" } @@ -4528,7 +4521,6 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", - "dev": true, "dependencies": { "@jridgewell/set-array": "^1.0.0", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -10563,7 +10555,6 @@ "version": "24.8.3", "resolved": "https://registry.npmjs.org/electron/-/electron-24.8.3.tgz", "integrity": "sha512-6YTsEOIMIQNnOz0Fj5gAWtwCuDd66iYKkuRJGyc80jKKYI49jBeH+R7ZZry9uiVu4T4bZgBN2FAN24XfCioQZA==", - "dev": true, "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", @@ -11952,7 +11943,6 @@ "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", - "dev": true, "optional": true, "dependencies": { "iconv-lite": "^0.6.2" @@ -13637,7 +13627,6 @@ "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, "engines": { "node": ">=6.9.0" } diff --git a/public/electron.jsx b/public/electron.jsx index 01c65c97..bc3ab5b9 100644 --- a/public/electron.jsx +++ b/public/electron.jsx @@ -74,7 +74,7 @@ function createWindow() { // }); mainWindow.loadFile(path.join(__dirname, 'index.html')); // unsure why we need the path.join, but index.html not found without it - //mainWindow.webContents.openDevTools(); + mainWindow.webContents.openDevTools(); ////////////////////////////////////////////////// //Creates terminal, specifies dimensions based on columns and rows ////////////////////////////////////////////////// From afa8140ae790933882d62339d8bc1d080f53c978 Mon Sep 17 00:00:00 2001 From: DonoCodePeriod <135299863+DonoCodePeriod@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:58:17 -0400 Subject: [PATCH 2/5] more custom hook implementations --- Notes On Spearmintv15.md | 14 ++- .../TestCase/UpdatedReactTestCase.tsx | 10 ++- .../Action/Action.tsx | 9 +- .../Assertion/Assertion.tsx | 9 +- .../DescribeBlock/DescribeBlock.tsx | 20 +++-- .../Render/Render.tsx | 9 +- .../TestBlock/TestBlock.tsx | 7 +- src/context/RTFsContextsProvider.tsx | 87 +++++++++++++++---- ...updatedFrontendFrameworkTestCaseActions.ts | 53 ----------- .../reducers/updatedReactTestCaseReducer.ts | 56 +++++++++--- src/context/updatedUseGenerateTest.jsx | 2 +- 11 files changed, 169 insertions(+), 107 deletions(-) diff --git a/Notes On Spearmintv15.md b/Notes On Spearmintv15.md index ec99dc92..d515534a 100644 --- a/Notes On Spearmintv15.md +++ b/Notes On Spearmintv15.md @@ -14,8 +14,14 @@ Existed Since We've Started: -Some Accessibility Test existed only in name, not in functionality -Debugging. Error messages point to bundle. Also, unable to get Electrons "devtools" to run react DevTools --No Error Handler for Components +-No Error Handler for Components(Look into Error Boundary and componentDidCatch) -No Confirmation Dialogue before X'ing out of blocks +-No way to import a test file and make modifications on it using the UI +-No way to use the application as a functioning desktop app. Only as a github download +-Working Backend(MongoDB connection and CRUD functionality) can't be confirmed +-Mock Data functionality is tied between all testing widgets + +- Changes Implemented: For Accessibility Tool @@ -39,9 +45,15 @@ should look) Additinoal fixes/considerations needed needed For the React(Beta) +-File system structure: maybe grouping all files related to only 1 widget into 1 folder makes more sense then keeping them seperate(e.g., the 'ReactTestCase' and 'Reducer' files should be put inside a folder that contains the other files related to only the React tool widget) -Decide for yourself which state structure makes the the most sense for you, and lends itself to implementing full jest testing capabilities -AutoFill for options of Action and Assert Components needs to be updated wot work with new state structure and re-enabled +-Steps toward reduced Component rerenders +-Custom Hooks +-React.Memo +React useMemo +-React useCallback -debug the Props Component so it will render properly -Setup Teardowns need to be quanitfied in a way that can be represented by a form like setup(e.g. user either fills out inputs or uses drags and drops diff --git a/src/components/TestCase/UpdatedReactTestCase.tsx b/src/components/TestCase/UpdatedReactTestCase.tsx index 9057933a..92b1e04d 100644 --- a/src/components/TestCase/UpdatedReactTestCase.tsx +++ b/src/components/TestCase/UpdatedReactTestCase.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useContext, useReducer } from 'react'; +import React, { useContext } from 'react'; import styles from './TestCase.module.scss'; import { updateRenderComponent } from '../../context/actions/updatedFrontendFrameworkTestCaseActions'; import { GlobalContext } from '../../context/reducers/globalReducer'; @@ -8,7 +8,7 @@ import { createMockData } from '../../context/actions/mockDataActions'; import UpdatedReactTestMenu from '../TestMenu/UpdatedReactTestMenu'; import MockData from '../UpdatedReactTestComponent/MockData/MockData'; import { Button } from '@mui/material'; -import { RTFsContexts } from '../../context/RTFsContextsProvider'; +import { useRTFsContexts } from '../../context/RTFsContextsProvider'; import DescribeBlock from '../UpdatedReactTestComponent/DescribeBlock/DescribeBlock'; const UpdatedReactTestCase = ({ @@ -17,7 +17,11 @@ const UpdatedReactTestCase = ({ filterFileType: Function; }) => { const { reactTestFileState, rTFDispatch, handleAddBlock } = - useContext(RTFsContexts); + // useContext(RTFsContexts); + useRTFsContexts(); + console.log('updatereact rerendered'); + console.log('reactTestFileState rerendered', reactTestFileState); + const [{ mockData }, dispatchToMockData] = useContext(MockDataContext); const [{ filePathMap, theme }] = useContext(GlobalContext); diff --git a/src/components/UpdatedReactTestComponent/Action/Action.tsx b/src/components/UpdatedReactTestComponent/Action/Action.tsx index b592ecdb..4e4272da 100644 --- a/src/components/UpdatedReactTestComponent/Action/Action.tsx +++ b/src/components/UpdatedReactTestComponent/Action/Action.tsx @@ -6,7 +6,7 @@ import { MockDataContext } from '../../../context/reducers/updatedMockDataReduce import { GlobalContext } from '../../../context/reducers/globalReducer'; import { AiOutlineClose } from 'react-icons/ai'; import { ReactTestComponentAssertion } from '../../../utils/updatedReactTypes'; -import { RTFsContexts } from '../../../context/RTFsContextsProvider'; +import { useRTFsContexts } from '../../../context/RTFsContextsProvider'; const questionIcon = require('../../../assets/images/help-circle.png'); @@ -25,13 +25,14 @@ type FieldTypes = | 'queryValue'; // Action box in middle panel (testCase.jsx) -const Action = ({ blockObjectsState }) => { +const Action = React.memo(({ blockObjectsState }) => { const thisBlockObjectsState = blockObjectsState; const [{ mockData }] = useContext(MockDataContext); const [{ theme }] = useContext(GlobalContext); const { handleAddBlock, handleChange, handleDeleteBlock, rTFDispatch } = - useContext(RTFsContexts); + //useContext(RTFsContexts); + useRTFsContexts(); /*const handleChangeActionFields = (e: EventTypes, field: FieldTypes) => { let updatedAction = { ...statement }; @@ -199,6 +200,6 @@ const Action = ({ blockObjectsState }) => { ); -}; +}); export default Action; diff --git a/src/components/UpdatedReactTestComponent/Assertion/Assertion.tsx b/src/components/UpdatedReactTestComponent/Assertion/Assertion.tsx index f400339b..29d40368 100644 --- a/src/components/UpdatedReactTestComponent/Assertion/Assertion.tsx +++ b/src/components/UpdatedReactTestComponent/Assertion/Assertion.tsx @@ -12,7 +12,7 @@ import UpdatedAutoComplete from '../../AutoComplete/UpdatedAutoComplete'; import { GlobalContext } from '../../../context/reducers/globalReducer'; import { AiOutlineClose } from 'react-icons/ai'; import { ReactTestComponentAssertion } from '../../../utils/updatedReactTypes'; -import { RTFsContexts } from '../../../context/RTFsContextsProvider'; +import { useRTFsContexts } from '../../../context/RTFsContextsProvider'; const questionIcon = require('../../../assets/images/help-circle.png'); @@ -29,11 +29,12 @@ type FieldTypes = | 'queryValue' | 'matcherValue'; -const Assertion = ({ blockObjectsState }) => { +const Assertion = React.memo(({ blockObjectsState }) => { const thisBlockObjectsState = blockObjectsState; const { handleAddBlock, handleChange, handleDeleteBlock, rTFDispatch } = - useContext(RTFsContexts); + // useContext(RTFsContexts); + useRTFsContexts(); const [{ theme }] = useContext(GlobalContext); /*const handleChangeAssertionFields = (e: EventTypes, field: FieldTypes) => { @@ -295,6 +296,6 @@ const Assertion = ({ blockObjectsState }) => { ); -}; +}); export default Assertion; diff --git a/src/components/UpdatedReactTestComponent/DescribeBlock/DescribeBlock.tsx b/src/components/UpdatedReactTestComponent/DescribeBlock/DescribeBlock.tsx index 329e3b76..e7d7a9b9 100644 --- a/src/components/UpdatedReactTestComponent/DescribeBlock/DescribeBlock.tsx +++ b/src/components/UpdatedReactTestComponent/DescribeBlock/DescribeBlock.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useContext } from 'react'; +import React, { useContext, useMemo, useCallback } from 'react'; import cn from 'classnames'; import describeBlockStyles from './DescribeRenderer.module.scss'; import { AiOutlineCloseCircle } from 'react-icons/ai'; @@ -11,7 +11,7 @@ import { } from '@mui/material'; import { DescribeBlocks } from '../../../utils/reactTypes'; import { GlobalContext } from '../../../context/reducers/globalReducer'; -import { RTFsContexts } from '../../../context/RTFsContextsProvider'; +import { useRTFsContexts } from '../../../context/RTFsContextsProvider'; import styles from '../../Modals/Modal.module.scss'; @@ -34,8 +34,7 @@ const DescribeBlock = ({ blockObjectsState }) => { handleChange, handleDeleteBlock, setChildrenComponents, - } = useContext(RTFsContexts); - + } = useRTFsContexts(); // useEffect(() => { // setHasSetupTeardown(false); // }, []); @@ -46,11 +45,16 @@ const DescribeBlock = ({ blockObjectsState }) => { //} - const { setupTeardownBlock, arrayOfChildComponents } = setChildrenComponents( - blockObjectsState, - theme + const { setupTeardownBlock, arrayOfChildComponents } = useMemo( + () => + setChildrenComponents( + blockObjectsState + //theme + ), + [blockObjectsState] ); + console.log('describe rerendered', thisBlockObjectsState.key); return ( <>