Skip to content

Dev #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 109 commits into from
May 10, 2024
Merged

Dev #57

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
7356d18
combined changes, added vue and svelte example, and refactored extension
austin-cavanagh Jan 2, 2024
af97b2f
combined the examples and extension changes
austin-cavanagh Jan 2, 2024
94af393
Merge pull request #45 from oslabs-beta/austin/combined-changes
johnwdunn20 Jan 2, 2024
3e6489b
added 2 way connection betweem content.ts and background.ts
austin-cavanagh Jan 4, 2024
3734652
added content script injection when the devtool is opened
austin-cavanagh Jan 4, 2024
36f1416
added logic to cleanup content script when new one is injected
austin-cavanagh Jan 4, 2024
25efb1e
saving before deleting commented code
austin-cavanagh Jan 5, 2024
9fba073
saving before handling disconnected background port
austin-cavanagh Jan 5, 2024
f4146cc
fixed issue of service worker going inactive after 30 seconds
austin-cavanagh Jan 5, 2024
b93971c
sending message to background script every 30 seconds to keep it from…
austin-cavanagh Jan 5, 2024
54fddb0
Pushing updated code to save on github
austin-cavanagh Feb 21, 2024
da3e953
added automated deployment to npm
johnwdunn20 Feb 22, 2024
84b6aa8
updated to be clean install
johnwdunn20 Feb 22, 2024
c66fd86
placeholder chrome yaml file
johnwdunn20 Feb 22, 2024
1f8871b
added notes for chrome
johnwdunn20 Feb 22, 2024
b448ce3
Added tests and snapshots for jsondiff
johnwdunn20 Feb 22, 2024
cfe19cf
added tests for continuous slider
johnwdunn20 Feb 22, 2024
3be4d1c
started difftab test
johnwdunn20 Feb 22, 2024
7e39f57
added snapshots and tests for difftab
johnwdunn20 Feb 22, 2024
e31553e
ignored test coverage files
johnwdunn20 Feb 22, 2024
27efcd0
updated gitignore
johnwdunn20 Feb 22, 2024
056f367
initial set up of eslint
johnwdunn20 Feb 22, 2024
8a7f1b9
initial set up of eslint
johnwdunn20 Feb 22, 2024
3c1f669
Converted vue components to react, not working yet
austin-cavanagh Feb 27, 2024
b5d5ec7
Messages from react app are being passed to the dev tool
austin-cavanagh Feb 28, 2024
2ea2704
React app message queue storing messages until it connects to the dev…
austin-cavanagh Feb 28, 2024
3ada975
Removed commented out code and refactored parts between index and sub…
austin-cavanagh Feb 28, 2024
24a2d9d
The content script was sending the connection message to the app befo…
austin-cavanagh Feb 28, 2024
ff187a0
Time travel correctly being set and components are switching in react…
austin-cavanagh Feb 28, 2024
c37411a
Time travel updates are working for the react app
austin-cavanagh Feb 28, 2024
afaf638
pulled austins branch
johnwdunn20 Mar 5, 2024
c4a657c
wrapped dev tools around if statement to prevent errors
johnwdunn20 Mar 5, 2024
fc00b3c
updated manifest browser_action to action to comply with manifest v3
johnwdunn20 Mar 5, 2024
6c7cd91
update jsondiffpatch version to0.5 instead of 0.6
johnwdunn20 Mar 7, 2024
47bd63a
removed console logs
johnwdunn20 Mar 7, 2024
e212202
updated inject script to have tree
johnwdunn20 Mar 7, 2024
a6a9827
initial types for inject.ts
johnwdunn20 Mar 7, 2024
323ff09
succesfully injecting script for component tree
johnwdunn20 Mar 7, 2024
cc2b697
succesfully inject script for react tree
johnwdunn20 Mar 7, 2024
bae762f
renamed metrics tab to tree tab
johnwdunn20 Mar 7, 2024
c998f39
got data in app
johnwdunn20 Mar 7, 2024
697c607
now displaying json tree
johnwdunn20 Mar 7, 2024
adbe462
added notes
johnwdunn20 Mar 7, 2024
5fd6041
sending message when profiling enabled
johnwdunn20 Mar 7, 2024
fba5c02
updated tree to display message
johnwdunn20 Mar 7, 2024
d2e97f3
cleaned up work
johnwdunn20 Mar 7, 2024
e482052
more clean up
johnwdunn20 Mar 7, 2024
53d4bed
Added commands to install the react and vue examples at the package d…
austin-cavanagh Mar 7, 2024
cbd0e83
Removed npm package vulnerabilities in the react example
austin-cavanagh Mar 8, 2024
b305060
Fixed the high severity vulnerability in the vue example
austin-cavanagh Mar 8, 2024
2e2a786
Merge pull request #47 from oslabs-beta/austin/npm-commands
johnwdunn20 Mar 8, 2024
78a5407
merged latest
johnwdunn20 Mar 8, 2024
b6392bd
initial testing set up
johnwdunn20 Mar 8, 2024
443df8a
testing setup complete
johnwdunn20 Mar 8, 2024
8fe6821
ran all tests
johnwdunn20 Mar 8, 2024
967372b
test suite setup
johnwdunn20 Mar 8, 2024
1742a85
update jest config to ignore files in coverage folder
johnwdunn20 Mar 8, 2024
330abd8
udpated scripts
johnwdunn20 Mar 8, 2024
2d0486a
logging if port gets disconnected and send message when toggle profil…
johnwdunn20 Mar 8, 2024
858a052
logging port devtoolsport object on disconnect too
johnwdunn20 Mar 8, 2024
3251899
added inject script back to content
johnwdunn20 Mar 8, 2024
6fa0da6
succesfully injecting script on toggle
johnwdunn20 Mar 8, 2024
e6bc3af
only adding tree script once now
johnwdunn20 Mar 8, 2024
6c23726
cleaned up inject.ts
johnwdunn20 Mar 8, 2024
e79fea1
unable to immedaiately invoke tree
johnwdunn20 Mar 8, 2024
822a57e
added a message about clicking in app to see tree
johnwdunn20 Mar 8, 2024
a4db9e4
moved tree state to parent so it persists between renders
johnwdunn20 Mar 8, 2024
adb14c9
updated profiling toggle component to organize state centrally in par…
johnwdunn20 Mar 8, 2024
62826e4
Merge pull request #50 from oslabs-beta/john/tree
austin-cavanagh Mar 8, 2024
16b42aa
Added new folders for vue and svelte implementations so each package …
austin-cavanagh Mar 8, 2024
f6f7b99
Removed the examples directory with 3 frameworks and changed it to an…
austin-cavanagh Mar 8, 2024
546c325
Updated install and run commands for the example in the react package
austin-cavanagh Mar 8, 2024
5fe7cd4
Updated install and run commands for the vue example in the vue direc…
austin-cavanagh Mar 8, 2024
9007f13
Updated commands to install and run the example in the svelte npm pac…
austin-cavanagh Mar 8, 2024
e73da26
Finished refactoring file structure, replaced extension with test-ext…
austin-cavanagh Mar 8, 2024
abe6a3c
Merge pull request #52 from oslabs-beta/austin/new-npm-folders
johnwdunn20 Mar 8, 2024
76e19b8
pulled latest
johnwdunn20 Mar 8, 2024
273dcd3
updated scripts
johnwdunn20 Mar 9, 2024
e1d7532
updated scripts
johnwdunn20 Mar 11, 2024
aad85c5
finalized scripts and moved files in example/link to the src folder s…
johnwdunn20 Mar 11, 2024
ad8a70e
tested all of react package
johnwdunn20 Mar 11, 2024
260ea0a
updated github actions
johnwdunn20 Mar 11, 2024
f002025
updated tests yml file
johnwdunn20 Mar 11, 2024
ba387dc
added unique query key
johnwdunn20 Mar 11, 2024
e1f5f63
combined scripts to be easier to run
johnwdunn20 Mar 11, 2024
47e231d
Merge pull request #53 from oslabs-beta/john/link
austin-cavanagh Mar 12, 2024
aede2af
Updated react example with nicer ui for users to use during development
austin-cavanagh Mar 13, 2024
b7b7723
Finalized new tailwind example
austin-cavanagh Mar 13, 2024
885b6eb
Updated imports for the react query rewind component
austin-cavanagh Mar 13, 2024
b36b1c6
Removed divs returned from the react query rewind component and repla…
austin-cavanagh Mar 13, 2024
df799c4
Merge pull request #54 from oslabs-beta/austin/new-tailwind-example
johnwdunn20 Mar 14, 2024
c5bb680
moved nav bar right for better recording
johnwdunn20 Mar 21, 2024
718b4e8
moved nav bar right for better recording
johnwdunn20 Mar 21, 2024
a905785
updated padding on react example nav bar
johnwdunn20 Mar 21, 2024
32b05fa
updated component tree gif
johnwdunn20 Mar 23, 2024
1009c4d
updated prev state gif
johnwdunn20 Mar 23, 2024
4ff3a6a
finalized github readme
johnwdunn20 Mar 24, 2024
da3d448
updated license link
johnwdunn20 Mar 24, 2024
9b08afd
updated react npm readme
johnwdunn20 Mar 24, 2024
96c7001
removed unnecessary github workflows
johnwdunn20 May 8, 2024
7a0d5d6
removed unnecessary permissions
johnwdunn20 May 8, 2024
45117b2
removed build folder
johnwdunn20 May 8, 2024
cfd2aa7
added back scripting permission
johnwdunn20 May 8, 2024
a4ed265
Merge pull request #55 from oslabs-beta/john/movies
austin-cavanagh May 8, 2024
bf03786
Updated tsconfig.json so it included backgr
austin-cavanagh May 8, 2024
8cc572f
Commented out the console logs in the content and background scripts
austin-cavanagh May 8, 2024
61afcc7
Removed console logs from the package components in the package-react…
austin-cavanagh May 8, 2024
d1300d9
Searched all files for console logs and commented them out to prepare…
austin-cavanagh May 8, 2024
03281a0
Merge pull request #56 from oslabs-beta/austin/remove-console-logs
johnwdunn20 May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Run Tests and Build
on:
# Updated to only run on pull requests to dev because all pushed to main will go through dev
pull_request:
branches:
- main
- dev
push:
branches:
- main
# - main
- dev
# push:
# branches:
# - main
# - dev
jobs:
unit-testing-extension:
runs-on: ubuntu-latest
Expand All @@ -16,7 +17,7 @@ jobs:
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
node-version: '20.7.0'
cache: 'npm'
- name: Install Extension dependencies
run: |
Expand All @@ -30,7 +31,7 @@ jobs:
run: |
cd extension
npm test
unit-testing-package:
unit-testing-package-react:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -41,18 +42,18 @@ jobs:
cache: 'npm'
- name: Install Package dependencies
run: |
cd package
cd package-react
npm ci
- name: Install linux handler for github actions
run: |
cd package
cd package-react
npm i @rollup/rollup-linux-x64-gnu
- name: Build Package
run: |
cd package
cd package-react
npm run build
- name: Test Package
run: |
cd package
cd package-react
npm test

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist
coverage/
53 changes: 8 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ React Query Rewind introduces a powerful DevTool extension designed to work in c
_picture of importing the component_

```javascript
import ReactQueryRewind from 'react-query-rewind';
import ReactQueryRewind from "react-query-rewind";
```

3. Place ReactQueryRewind next to the root of your application inside the QueryClientProvider component.
Expand All @@ -61,26 +61,26 @@ React Query Rewind introduces a powerful DevTool extension designed to work in c
4. Open the Chrome DevTool Extension and start coding!

<p align="left">
<img src="./assets/chrome-devtool.png" alt="Component Placement" width="600"/>
<img src="https://i.imgur.com/xTEPI20.png" alt="Component Placement" width="600"/>
</p>

# Features

- <b>Query States: </b>Upon opening RQRewind in Chrome Dev Tools, you will see the Queries tab open with a drop down menu listing the query keys of all the incoming queries. Select the queries that you want to monitor, make changes on the web app, and the changes of query states will be logged as reflected by the growing number above the play bar. Use the play bar to navigate to a particular state snapshot that you would like to inspect.

<p align="center"><img src="./assets/query-states.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>
<p align="center"><img src="https://i.imgur.com/g8KrqAg.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>

- <b>State Diff: </b>Toggle on the Diff button to see state changes between each snapshot highlighted. Turn on the switch on top of the page to show only parts of the state that are changed.

<p align="center"><img src="./assets/state-diff.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>
<p align="center"><img src="https://i.imgur.com/a8KAgXZ.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>

- <b>Live UI Change: </b>As you review the state change history, there is also the option to turn on the time travel mode by clicking on the clock icon button. Under time travel mode, when visiting a logged state snapshot on RQRewindl, the UI of the app will change accordingly. Turn off time travel mode for RQRewind to continue logging future state changes.

<p align="center"><img src="./assets/UI-change.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>
<p align="center"><img src="https://i.imgur.com/AZ3QGuf.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>

- <b>Component Tree: </b> Click on the Component Tree tab and turn on the Start Profiling switch. Click on any component on the app, and view the component tree that is rendered on the dev tools panel.

<p align="center"><img src="./assets/component-tree.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>
<p align="center"><img src="https://i.imgur.com/qa5UJTW.gif" width='800' style="margin-top: 1em; margin-bottom: 1em;"></p>

# Contributing

Expand Down Expand Up @@ -111,43 +111,6 @@ Rui Fan - [GitHub](https://github.com/ruifan-IU) - [LinkedIn](https://www.linked
Project Link: [React Query Rewind](https://github.com/oslabs-beta/react-query-rewind-chrome)

# License
[MIT](https://www.mit.edu/~amini/LICENSE.md)

_MIT Link_

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- TABLE OF CONTENTS -->
<!-- <details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a></li>
<li><a href="#roadmap">Roadmap</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgments">Acknowledgments</a></li>
</ol>
</details> -->

<!-- <p align="right">(<a href="#readme-top">back to top</a>)</p> -->

<!-- <a name="website" href="ARE WE GONNA HAVE A WEBSITE">Website</a> -->

<!-- [![Contributors](https://img.shields.io/github/contributors/oslabs-beta/react-query-rewind-chrome.svg?style=for-the-badge)](https://github.com/oslabs-beta/react-query-rewind-chrome/graphs/contributors)
[![Forks](https://img.shields.io/github/forks/oslabs-beta/react-query-rewind-chrome.svg?style=for-the-badge)](https://github.com/oslabs-beta/react-query-rewind-chrome/forks)
[![Stargazers](https://img.shields.io/github/stars/oslabs-beta/react-query-rewind-chrome.svg?style=for-the-badge)](https://github.com/oslabs-beta/react-query-rewind-chrome/stargazers)
[![Issues](https://img.shields.io/github/issues/oslabs-beta/react-query-rewind-chrome.svg?style=for-the-badge)](https://github.com/oslabs-beta/react-query-rewind-chrome/issues)
[![MIT License](https://img.shields.io/github/license/oslabs-beta/react-query-rewind-chrome.svg?style=for-the-badge)](https://github.com/oslabs-beta/react-query-rewind-chrome/blob/main/LICENSE) -->
<p align="right">(<a href="#readme-top">back to top</a>)</p>
4 changes: 2 additions & 2 deletions extension/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
build/
node_modules/
dist/
21 changes: 0 additions & 21 deletions extension/LICENSE

This file was deleted.

31 changes: 31 additions & 0 deletions extension/__tests__/ContinuousSlider.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import ContinuousSlider from '../src/components/ContinuousSlider'; // Adjust the import path as necessary
import '@testing-library/jest-dom';

describe('ContinuousSlider', () => {
it('renders correctly with given props', () => {
const handleChange = jest.fn();
const { asFragment } = render(<ContinuousSlider value={30} maxValue={100} onChange={handleChange} />);

const slider = screen.getByRole('slider');
expect(slider).toBeInTheDocument();
expect(slider).toHaveAttribute('aria-valuemax', '100');
expect(slider).toHaveAttribute('aria-valuenow', '30');
expect(asFragment()).toMatchSnapshot();
});

it('calls onChange with the new value when changed', async () => {
const handleChange = jest.fn();
render(<ContinuousSlider value={30} maxValue={100} onChange={handleChange} />);

// Assuming the slider allows keyboard input, you can simulate changes like this
const slider = screen.getByRole('slider');
await userEvent.click(slider);
await userEvent.keyboard('{arrowright}'); // Simulates pressing the right arrow key to increase the value

expect(handleChange).toHaveBeenCalledWith(expect.any(Number));
});

});
60 changes: 60 additions & 0 deletions extension/__tests__/DiffTab.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import DiffTab from '../src/containers/DiffTab';
import '@testing-library/jest-dom';
import { QueryDisplay } from '../src/types';
import exp from 'constants';

describe('DiffTab Component', () => {
const queryDisplayMock: QueryDisplay[][] = [
[
{
queryKey: 'Query 1',
queryData: { some: 'data' }
},
{
queryKey: 'Query 2',
queryData: { more: 'data' }
}
],
[
{
queryKey: 'Query 1',
queryData: { some: 'different data' }
}
]
];

it('renders correctly with initial state', () => {
const { asFragment } = render(<DiffTab queryDisplay={queryDisplayMock} currentIndex={0} />);
expect(screen.getByLabelText(/Hide Unchanged Properties/i)).toBeInTheDocument();
expect(screen.getByText(/Query 1/i)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();
});

it('toggles isHidden state on switch toggle', () => {
const { asFragment } = render(<DiffTab queryDisplay={queryDisplayMock} currentIndex={0} />);
fireEvent.click(screen.getByRole('checkbox')); // Clicks the switch
expect(screen.getByLabelText(/Show Unchanged Properties/i)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();
});

it('renders JsonDiff component with correct props based on isHidden state', () => {
const { rerender, asFragment } = render(<DiffTab queryDisplay={queryDisplayMock} currentIndex={1} />);
let switchControl = screen.getByRole('checkbox');

// Initially, isHidden should be false, so "Hide" should be in the label
expect(switchControl).not.toBeChecked();
expect(screen.getByText(/Hide Unchanged Properties/i)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();

// Toggle the switch to change isHidden state
fireEvent.click(switchControl);
// Rerendering is necessary only if the component's response to state changes cannot be detected without it
rerender(<DiffTab queryDisplay={queryDisplayMock} currentIndex={1} />);

// Now, isHidden should be true, so "Show" should be in the label
expect(screen.getByLabelText(/Show Unchanged Properties/i)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();
});
});
79 changes: 79 additions & 0 deletions extension/__tests__/JsonDiff.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import JsonDiff from '../src/components/JsonDiff';

describe('JsonDiff Component', () => {
it('displays initial state message for empty currentJson and snapshot', () => {
const { getByText, asFragment } = render(
<JsonDiff
oldJson={undefined}
currentJson=""
queryKey="testQueryKey"
isHidden={false}
/>
);
expect(getByText(/Initial state - no comparison available/i)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();
});

it('displays a diff when there are differences between oldJson and currentJson and snapshot', () => {
const oldJson = { key: "oldValue" };
const currentJson = { key: "newValue" };
const { container, asFragment } = render(
<JsonDiff
oldJson={oldJson}
currentJson={currentJson}
queryKey="testQueryKey"
isHidden={false}
/>
);
// Assert that the diff is displayed
expect(container.querySelector('.jsondiffpatch-delta')).not.toBeNull();
expect(asFragment()).toMatchSnapshot();
});


it('displays no changes message when oldJson and currentJson are the same', () => {
const json = { key: "value" };
const { getByText, asFragment } = render(
<JsonDiff
oldJson={json}
currentJson={json}
queryKey="testQueryKey"
isHidden={false}
/>
);
expect(getByText(/QueryKey data not modified on this state change/i)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();
});

it('toggles visibility based on isHidden prop', () => {
const json = { key: "value" };
const newJson = { key: "newValue" };
const { container, rerender, asFragment } = render(
<JsonDiff
oldJson={json}
currentJson={newJson}
queryKey="testQueryKey"
isHidden={true}
/>
);
// Initially, the class indicating hidden changes should be present
expect(container.querySelector('.jsondiffpatch-unchanged-hidden')).not.toBeNull();
expect(asFragment()).toMatchSnapshot();

// Rerender with isHidden = false and check if the class is removed
rerender(
<JsonDiff
oldJson={json}
currentJson={newJson}
queryKey="testQueryKey"
isHidden={false}
/>
);
expect(container.querySelector('.jsondiffpatch-unchanged-hidden')).toBeNull();
expect(asFragment()).toMatchSnapshot();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { render } from '@testing-library/react';
import JsonFormatter from '../src/components/JsonFormatter';

describe('JsonFormatter component', () => {
it('renders without crashing', () => {
render(<JsonFormatter
it('renders without crashing and snapshot', () => {
const { asFragment } = render(<JsonFormatter
key={1}
queryKey={'[posts-one]'}
jsonData={{val: 'test', arr: [1,2,3]}}
/>);

expect(asFragment()).toMatchSnapshot();
});
});
Loading