Skip to content

Commit 799f399

Browse files
added tests to show snapshot data
1 parent 535ef07 commit 799f399

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

src/app/components/Action.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ interface ActionProps {
4141
// index and delta props were removed from Action.jsx */
4242
// viewIndex and handleonkeyDown added to props
4343
const Action = (props: ActionProps): JSX.Element => {
44+
4445
const {
4546
selected, last, index, sliderIndex, dispatch, displayName, componentName,
4647
componentData, viewIndex, handleOnkeyDown,
4748
} = props;
4849

50+
// nathan test for props
51+
console.log('componentName: ', componentName);
4952
/**
5053
* @function cleanTime: Displays render times for state changes
5154
* @returns render display time in seconds in miliseconds
@@ -91,7 +94,8 @@ const Action = (props: ActionProps): JSX.Element => {
9194
tabIndex={index}
9295
>
9396
<div className="action-component-text">
94-
{`${displayName}: ${componentName !== 'nameless' ? componentName : ''} `}
97+
{/* {`${displayName}: ${componentName !== 'nameless' ? componentName : ''} `} */}
98+
{`displayName: ${displayName}`}
9599
</div>
96100
<button
97101
className="time-button"

src/app/components/Diff.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function Diff(props: DiffProps) {
6161
// diff function returns a comparison of two objects, one has an updated change
6262
// just displays stateful data
6363
const delta = diff(previousDisplay, snapshot);
64+
// nathan test
65+
console.log('delta', delta);
6466
// returns html in string
6567
// just displays stateful data
6668
const html = formatters.html.format(delta, previousDisplay);

src/app/containers/ActionContainer.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function ActionContainer(props) {
2020
let actionsArr = [];
2121
const hierarchyArr: any[] = [];
2222

23+
24+
2325
// function to traverse state from hiararchy and also getting information on display name and component name
2426
const displayArray = (obj: {
2527
stateSnapshot: { children: any[] };
@@ -38,7 +40,9 @@ function ActionContainer(props) {
3840
index: obj.index,
3941
displayName: `${obj.name}.${obj.branch}`,
4042
state: obj.stateSnapshot.children[0].state,
41-
componentName: obj.stateSnapshot.children[0].name,
43+
// componentName: obj.stateSnapshot.children[0].name,
44+
// nathan testing new entries for component name, original above
45+
componentName: obj.stateSnapshot,
4246
componentData:
4347
JSON.stringify(obj.stateSnapshot.children[0].componentData) === '{}'
4448
? ''
@@ -60,7 +64,7 @@ function ActionContainer(props) {
6064
// handles keyboard presses, function passes an event and index of each action-component
6165
function handleOnKeyDown(e: KeyboardEvent, i: number) {
6266
let currIndex = i;
63-
// up array key pressed
67+
// up arrow key pressed
6468
if (e.keyCode === 38) {
6569
currIndex -= 1;
6670
if (currIndex < 0) return;
@@ -109,14 +113,14 @@ function ActionContainer(props) {
109113
viewIndex={viewIndex}
110114
/>
111115
);
112-
}
116+
},
113117
);
114118
useEffect(() => {
115119
setActionView(true);
116120
}, []);
117121

118-
//the conditional logic below will cause ActionContainer.test.tsx to fail as it cannot find the Empty button
119-
//UNLESS actionView={true} is passed into <ActionContainer /> in the beforeEach() call in ActionContainer.test.tsx
122+
// the conditional logic below will cause ActionContainer.test.tsx to fail as it cannot find the Empty button
123+
// UNLESS actionView={true} is passed into <ActionContainer /> in the beforeEach() call in ActionContainer.test.tsx
120124
return (
121125
<div id='action-id' className='action-container'>
122126
<div id='arrow'>

src/backend/linkFiber.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
8888
if (!snap.tree) {
8989
snap.tree = new Tree('root', 'root');
9090
}
91+
// nathan test breakpoint
92+
console.log('snap: ', snap);
93+
9194
const payload = snap.tree.cleanTreeCopy();
9295
// if it's Recoil - run different actions?
9396
if (isRecoil) {
@@ -103,6 +106,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
103106
// the postMessage action will be received on the content script to later update the tabsObj
104107
// this will fire off everytime there is a change in test application
105108
window.postMessage(
109+
106110
{
107111
action: 'recordSnap',
108112
payload,
@@ -213,6 +217,7 @@ function createTree(
213217
tree: Tree = new Tree('root', 'root'),
214218
fromSibling = false
215219
) {
220+
216221
// Base case: child or sibling pointed to null
217222
if (!currentFiber) return null;
218223
if (!tree) return tree;
@@ -233,6 +238,9 @@ function createTree(
233238
treeBaseDuration,
234239
} = currentFiber;
235240

241+
// console.log('currentFiber: ', currentFiber);
242+
// console.log('tag', tag);
243+
236244
//Checks Recoil Atom and Selector Relationships
237245
if (
238246
currentFiber.memoizedState &&
@@ -490,6 +498,8 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
490498
return () => {
491499
// react devtools global hook is a global object that was injected by the React Devtools content script, allows access to fiber nodes and react version
492500
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
501+
// nathan test
502+
console.log('devTools', devTools);
493503
const reactInstance = devTools ? devTools.renderers.get(1) : null;
494504
fiberRoot = devTools.getFiberRoots(1).values().next().value;
495505

src/extension/background.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ chrome.runtime.onConnect.addListener((port) => {
130130
port.onMessage.addListener((msg) => {
131131
// msg is action denoting a time jump in devtools
132132

133+
// nathan tests below
134+
console.log('msg: ', msg);
133135
// ---------------------------------------------------------------
134136
// message incoming from devTools should look like this:
135137
// {
@@ -190,8 +192,13 @@ chrome.runtime.onConnect.addListener((port) => {
190192
});
191193
});
192194

195+
// nathan test
196+
console.log('top level log in background.js');
193197
// background.js listening for a message from contentScript.js
194198
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
199+
// nathan test
200+
console.log('request: ', request);
201+
console.log('sender: ', sender);
195202
// IGNORE THE AUTOMATIC MESSAGE SENT BY CHROME WHEN CONTENT SCRIPT IS FIRST LOADED
196203
if (request.type === 'SIGN_CONNECT') {
197204
return true;
@@ -430,6 +437,7 @@ chrome.runtime.onInstalled.addListener(() => {
430437
// when context menu is clicked, listen for the menuItemId,
431438
// if user clicked on reactime, open the devtools window
432439
chrome.contextMenus.onClicked.addListener(({ menuItemId }) => {
440+
console.log('this is the menuItemId: ', menuItemId);
433441
const options = {
434442
type: 'panel',
435443
left: 0,

src/extension/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Reactime",
2+
"name": "ReactimeVnpr",
33
"version": "8.0.0",
44
"devtools_page": "devtools.html",
55
"description": "A Chrome extension that helps debug React applications by memorizing the state of components with every render.",

0 commit comments

Comments
 (0)