Skip to content

Commit 25b83e2

Browse files
authored
Merge pull request #30 from oslabs-beta/dev
merging development changes into main branch
2 parents 187b55a + 0846883 commit 25b83e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+456
-1652
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"presets": ["airbnb", "@babel/preset-typescript"],
3-
"plugins": ["@emotion"]
2+
"presets": ["airbnb", "@babel/preset-typescript"]
43
}

demo-app-remix/server.js renamed to demo-app-remix/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ app.use(morgan("tiny"));
2828
app.all(
2929
"*",
3030
process.env.NODE_ENV === "development"
31-
? (req, res, next) => {
31+
? (req: any, res: any, next: any) => {
3232
purgeRequireCache();
3333

3434
return createRequestHandler({
@@ -41,7 +41,7 @@ app.all(
4141
mode: process.env.NODE_ENV,
4242
})
4343
);
44-
const port = process.env.PORT || 3003;
44+
const port: number | string = process.env.PORT || 3003;
4545

4646
app.listen(port, () => {
4747
console.log(`Express server listening on port ${port}`);

demo-app-remix/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
2+
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx", "server.ts"],
33
"compilerOptions": {
44
"lib": ["DOM", "DOM.Iterable", "ES2019"],
55
"isolatedModules": true,

demo-app/src/client/style.css

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
2+
3+
:root {
4+
--primary-red-color: #F00008;
5+
--background-color1: #f6f6f6;
6+
--secondary-blue-color: #62d6fb;
7+
--fire-rose-red: #FF6569;
8+
--secondary-color: #6288fb;
9+
--text-color: #330002;
10+
}
111

212
body {
313
margin: 0;
4-
font-family: Arial, Helvetica, sans-serif;
5-
background-color: #FFF4F4;
14+
font-family: 'Lato', sans-serif;
15+
background-color: var(--background-color1);
616
}
717

818
h1, h2, h4 {
@@ -12,7 +22,19 @@ h1, h2, h4 {
1222
/* Navbar */
1323

1424
.nav {
15-
background-color: #FF6569;
25+
background-image: linear-gradient(
26+
0deg,
27+
hsl(358deg 100% 47%) 5%,
28+
hsl(359deg 90% 51%) 24%,
29+
hsl(360deg 91% 54%) 33%,
30+
hsl(360deg 93% 57%) 41%,
31+
hsl(360deg 94% 59%) 48%,
32+
hsl(360deg 95% 60%) 54%,
33+
hsl(359deg 97% 62%) 61%,
34+
hsl(359deg 98% 64%) 69%,
35+
hsl(359deg 99% 65%) 79%,
36+
hsl(358deg 100% 67%) 100%
37+
);
1638

1739
display: flex;
1840
justify-content: space-evenly;
@@ -75,7 +97,7 @@ h1, h2, h4 {
7597
}
7698

7799
.box {
78-
background-color: #62d6fb;
100+
background-color: var(--secondary-blue-color);
79101
border-style: solid;
80102
border-color: #ffffff;
81103
border-radius: 5px;
@@ -87,7 +109,7 @@ h1, h2, h4 {
87109
}
88110

89111
#reset {
90-
color: #FF6569;
112+
color: var(--primary-red-color);
91113
font-size: 1.5em;
92114

93115
background-color: #ffffff;
@@ -105,7 +127,7 @@ h1, h2, h4 {
105127

106128
#reset:hover {
107129
color: #ffffff;
108-
background-color: #FF6569
130+
background-color: var(--primary-red-color)
109131
}
110132

111133
/* Counter */
@@ -131,7 +153,7 @@ h1, h2, h4 {
131153
color: #ffffff;
132154
font-size: 1.5em;
133155

134-
background-color: #FF6569;
156+
background-color: var(--primary-red-color);
135157
border-style: solid;
136158
border-color: #ffffff;
137159
border-radius: 5px;
@@ -145,11 +167,11 @@ h1, h2, h4 {
145167
}
146168

147169
.increment:hover {
148-
background-color: #62d6fb;
170+
background-color: var(--secondary-blue-color);
149171
}
150172

151173
.hook-data-section {
152-
border: 2px solid #FF6569;
174+
border: 2px solid --primary-red-color;
153175
border-radius: 5px;
154176
margin: 10px 0;
155177
padding: 8px;

high-contrast-colors.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## High Contrast Colors to Help with Color Blindness
2+
- Dark Blue (#000080)
3+
- Light Blue (#ADD8E6)
4+
- Dark Green (#006400)
5+
- Light Green (#90EE90)
6+
- Dark Red (#8B0000)
7+
- Light Red (#FFC0CB)
8+
- Dark Purple (#800080)
9+
- Light Purple (#BA55D3)
10+
- Dark Yellow (#FFD700)
11+
- Light Yellow (#FFFFE0)
12+
- Dark Orange (#FF8C00)
13+
- Light Orange (#FFA500)
14+
- Dark Brown (#8B4513)
15+
- Light Brown (#D2691E)
16+
- Dark Gray (#A9A9A9)
17+
- Light Gray (#D3D3D3)

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"Hien Nguyen",
5959
"Jack Crish",
6060
"Jackie Yuan",
61+
"James McCollough",
6162
"James Nghiem",
6263
"Jasmine Noor",
6364
"Joseph Park",
@@ -70,9 +71,11 @@
7071
"Lance Ziegler",
7172
"Lina Shin",
7273
"Mark Teets",
74+
"Mike Bednarz",
7375
"Minzo Kim",
7476
"Nathanael Wa Mwenze",
7577
"Ngoc Zwolinski",
78+
"Nick Huemmer",
7679
"Peter Lam",
7780
"Prasanna Malla",
7881
"Rajeeb Banstola",
@@ -81,6 +84,7 @@
8184
"Rocky Lin",
8285
"Ruth Anam",
8386
"Ryan Dang",
87+
"Sergei Liubchenko",
8488
"Sierra Swaby",
8589
"Tania Lind",
8690
"Viet Nguyen",
@@ -95,7 +99,6 @@
9599
"@babel/preset-env": "^7.12.7",
96100
"@babel/preset-react": "^7.12.7",
97101
"@babel/preset-typescript": "^7.21.5",
98-
"@emotion/babel-plugin": "^11.7.2",
99102
"@inrupt/jest-jsdom-polyfills": "^1.6.2",
100103
"@testing-library/jest-dom": "^4.2.4",
101104
"@testing-library/react": "^13.4.0",
@@ -152,8 +155,6 @@
152155
"webpack-cli": "^3.3.12"
153156
},
154157
"dependencies": {
155-
"@emotion/react": "^11.9.0",
156-
"@emotion/styled": "^11.8.1",
157158
"@fortawesome/fontawesome-free": "^5.15.1",
158159
"@fortawesome/fontawesome-svg-core": "^1.2.32",
159160
"@fortawesome/free-regular-svg-icons": "^5.15.1",

src/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,19 @@ Similar approach for Next.js and Remix demo apps
4747
## Linting
4848

4949
_Before_ beginning development, especially on teams, make sure to configure your linter and code formatting to conform to one unified setting (We recommend [the Airbnb style guide](https://github.com/airbnb/javascript)!) This will make reviewing PRs much more readable and less error-prone.  
50-
 
50+
 
51+
52+
# Possible Avenues for Future Iterators
5153

52-
# Possible Avenues for Future Iterators
5354
Here are some notes on the current state of Reactime and considerations for future development.
5455

5556
## Testing
5657

57-
For Reactime unit tests, pre-v.19 there were tests built out in two places. Backend tests were in backend >\_\_tests\_\_. Frontend tests were in src > app >\_\_tests\_\_. In v19, we specifically focused on rebuilding front tests to use React Testing Library (RTL) + Jest. Previously, front end testing existed but utilized Enzyme + Jest . Our decision to move to RTL stemmed on the fact that Enzyme did not support React V17 (third party Enzyme adaptor libraries were created to provide support to previous React versions, but were still very much out of date) and that Enzyme is no longer industry standard. We began the process of creating new frontend tests but they are not complete and this is a great place for future iterators to build out more. Since the new suite of RTL tests are not fully complete, we have kept the older Enzyme tests within the codebase to be referenced (src > app > __tests__enzyme). However, these will not be included in the tests run in the testing scripts.
58+
For Reactime unit tests, pre-v.19 there were tests built out in two places. Backend tests were in backend >\_\_tests\_\_. Frontend tests were in src > app >\_\_tests\_\_. In v19, we specifically focused on rebuilding front tests to use React Testing Library (RTL) + Jest. Previously, front end testing existed but utilized Enzyme + Jest . Our decision to move to RTL stemmed on the fact that Enzyme did not support React V17 (third party Enzyme adaptor libraries were created to provide support to previous React versions, but were still very much out of date) and that Enzyme is no longer industry standard. We began the process of creating new frontend tests but they are not complete and this is a great place for future iterators to build out more. Since the new suite of RTL tests are not fully complete, we have kept the older Enzyme tests within the codebase to be referenced (src > app > **tests**enzyme). However, these will not be included in the tests run in the testing scripts.
5859

5960
## Including Support for Hooks Beyond useState
60-
Reactime currently shows data stored via useState, but does not show data stored via other hooks such as useContext or useReducer. While showing this data would be simple, maintaining the time travel functionality of Reactime with these hooks would not. *Please see file demo-app/src/client/Components/ButtonsWithMoreHooks.jsx for more details.*
61+
62+
Reactime currently shows data stored via useState, but does not show data stored via other hooks such as useContext or useReducer. While showing this data would be simple, maintaining the time travel functionality of Reactime with these hooks would not. _Please see file demo-app/src/client/Components/ButtonsWithMoreHooks.jsx for more details._
6163

6264
To see how hook data is stored on the fiber tree:
6365

@@ -71,20 +73,19 @@ To see how hook data is stored on the fiber tree:
7173
Any changes to console.logs in Reactime can be seen by refreshing the browser the app is running in.
7274

7375
## Replace Functionality for Outdated Packages
74-
Packages emotion/core and material-ui/core haven't been updated to use React 18. This is the reason npm install --force is necessary when installing the dependencies of Reactime. Replacing the functionality these packages perform and removing them from Reactime would ensure compatibility moving forward.
7576

76-
React Developer Tools has deprecated \_\_REACT\_DEVTOOLS\_GLOBAL\_HOOK\_\_, which Reactime uses to extract a running application's fiber tree. At the time of the release of Reactime 19 (May 2023), this tool still works reliably to deliver said fiber tree. This will likely be the case until the React version (React version 18.2 at time of writing) undergoes updates that diverge beyond compatibility with \_\_REACT\_DEVTOOLS\_GLOBAL\_HOOK\_\_. At this time, Reactime will need to change how it extracts an application's fiber tree.
77+
Packages emotion/core and material-ui/core haven't been updated to use React 18. This is the reason npm install --force is necessary when installing the dependencies of Reactime. Replacing the functionality these packages perform and removing them from Reactime would ensure compatibility moving forward.
7778

78-
Changing how Reactime extracts the fiber tree before said React version update may yeild diminishing result, as whatever method will also need to be updated to match React's breaking updates.
79+
React Developer Tools has deprecated \_\_REACT_DEVTOOLS_GLOBAL_HOOK\_\_, which Reactime uses to extract a running application's fiber tree. At the time of the release of Reactime 19 (May 2023), this tool still works reliably to deliver said fiber tree. This will likely be the case until the React version (React version 18.2 at time of writing) undergoes updates that diverge beyond compatibility with \_\_REACT_DEVTOOLS_GLOBAL_HOOK\_\_. At this time, Reactime will need to change how it extracts an application's fiber tree.
7980

81+
Changing how Reactime extracts the fiber tree before said React version update may yeild diminishing result, as whatever method will also need to be updated to match React's breaking updates.
8082

8183
## Redux
8284

8385
Can Reactime be integrated with Redux compatibility so applications using Redux can track state in Reactime?
8486

8587
Yes, but it would be very time-consuming and not the most feasible option while Redux devtools exists already. With how Redux devtools is currently set up, a developer is unable to use Redux devtools as a third-party user and integrate its functionality into their own application, as Redux devtools is meant to be used directly on an application using Redux for state-tracking purposes. Since the devtools do not appear to have a public API for integrated use in an application or it simply does not exist, Redux devtools would need to be rebuilt from the ground up and then integrated into Reactime, or built into Reactime directly still from scratch.
8688

87-
8889
# File Structure
8990

9091
In the _src_ folder, there are three directories we care about: _app_, _backend_, and _extension_.
@@ -100,7 +101,7 @@ src/
100101
│   ├── containers/ # More React components
101102
│   ├── reducers/ # Redux mechanism for updating state
102103
│   ├── styles/ #
103-
│   ├── FrontendTypes.ts # Library of typescript interfaces
104+
│   ├── FrontendTypes.ts # Library of typescript interfaces
104105
│   ├── index.tsx # Starting point for root App component
105106
│   ├── module.d.ts #
106107
│   └── store.tsx #
@@ -127,7 +128,7 @@ src/
127128
│   ├── index.d.ts # Definitely Type file for Index
128129
│   ├── module.d.ts #
129130
│   ├── package.json #
130-
│   ├── puppeteerServer.js #
131+
│   ├── puppeteerServer.ts #
131132
132133
├── extension/ # Chrome Extension code
133134
│   ├── build/ # Destination for bundles and manifest.json (Chrome config file)
@@ -156,7 +157,6 @@ All the diagrams of data flows are available on [MIRO](https://miro.com/app/boar
156157
- Like regular web apps, Chrome Extensions are event-based. The background script is where one typically monitors for browser triggers (e.g. events like closing a tab, for example). The content script is what allows us to read or write to our target web application, usually as a result of [messages passed](https://developer.chrome.com/extensions/messaging) from the background script.
157158
- These two files help us handle requests both from the web browser and from the Reactime extension itself
158159

159-
160160
## Data Flow Architecture
161161

162162
The general flow of data is described in the following steps:
@@ -170,7 +170,6 @@ The general flow of data is described in the following steps:
170170
3. Likewise, when Reactime emits an action due to user interaction -- a "jump" request for example -- a message will be passed from Reactime via the background script to the content script. Then, the content script will pass a message to the target application containing a payload that represents the state the user wants the DOM to reflect or "jump" to.
171171
- One important thing to note here is that this jump action must be dispatched in the target application (i.e. _backend_ land), because only there do we have direct access to the DOM.
172172

173-
174173
# Reacti.me Website:
175174

176175
See [Reacti.me README](https://github.com/reactimetravel/reactime-website/blob/main/README.md) for instruction of how to update the website
@@ -239,6 +238,7 @@ Some relevant sections are reproduced below:
239238
- In other words, a background script works as a sort of middleman, directly maintaining connection with its parent extension, and acting as a proxy enabling communication between it and the content script.
240239

241240
# Past Medium Articles for Reference
241+
242242
- [Reactime 19: What time is it? It’s still Reactime!](https://medium.com/@minzo.kim/what-time-is-it-its-still-reactime-d496adfa908c)
243243
- [Reactime 18.0. Better than ever](https://medium.com/@zdf2424/reactime-18-0-better-than-ever-148b81606257)
244244
- [Reactime v17.0.0: Now with support for the Context API, and a modern UI](https://medium.com/@reactime/reactime-v17-0-0-now-with-support-for-the-context-api-and-a-modern-ui-f0edf9e54dae)

src/app/__tests__/ActionContainer.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { render, screen, fireEvent } from '@testing-library/react';
55
import '@testing-library/jest-dom/extend-expect';
66
import ActionContainer from '../containers/ActionContainer';
77
import { useStoreContext } from '../store';
8+
import TravelContainer from '../containers/TravelContainer';
89

910
const state = {
1011
tabs: {
@@ -143,8 +144,22 @@ describe('unit testing for ActionContainer', () => {
143144
expect(screen.getByText('MockSwitchApp')).toBeInTheDocument();
144145
});
145146

146-
test('Click works on clear button', async () => {
147+
test('Click works on clear button', () => {
147148
fireEvent.click(screen.getAllByRole('button')[0]);
148-
await expect(dispatch).toHaveBeenCalledTimes(1);
149+
expect(dispatch).toHaveBeenCalledTimes(1);
149150
});
150151
});
152+
153+
describe('integration testing for ActionContainer', () => {
154+
beforeEach(() => {
155+
mockeduseStoreContext.mockClear();
156+
dispatch.mockClear();
157+
render(<ActionContainer actionView={true} />);
158+
render(<TravelContainer snapshotsLength={0} />);
159+
});
160+
161+
test('Slider resets on clear button', () => {
162+
fireEvent.click(screen.getAllByRole('button')[0]);
163+
expect(screen.getByRole('slider')).toHaveStyle('left: 0');
164+
});
165+
});

src/app/__tests__/ButtonContainer.test.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { TextEncoder } from 'util';
55
global.TextEncoder = TextEncoder;
66
import ButtonsContainer from '../containers/ButtonsContainer';
77
import { useStoreContext } from '../store';
8+
import userEvent from '@testing-library/user-event';
9+
import { toggleMode } from '../actions/actions';
810

911
// const { Steps } = require('intro.js-react');
1012
jest.mock('../store');
@@ -24,9 +26,8 @@ describe('Unit testing for ButtonContainer', () => {
2426
sliderIndex: 0,
2527
viewIndex: -1,
2628
mode: {
27-
paused: false,
29+
paused: true,
2830
locked: false,
29-
persist: false,
3031
},
3132
},
3233
},
@@ -46,16 +47,15 @@ describe('Unit testing for ButtonContainer', () => {
4647
dispatch.mockClear();
4748
mockedUsedStoreContext.mockClear();
4849
currentTab.mode = {
49-
paused: false,
50-
persist: false,
50+
paused: true,
5151
};
5252
});
5353

5454
describe('When button container is loaded', () => {
55-
test('should have 4 buttons ', () => {
55+
test('it should have 4 buttons', () => {
5656
render(<ButtonsContainer />);
5757
expect(screen.getAllByRole('button')).toHaveLength(4);
58-
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Unlocked');
58+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Locked');
5959
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Download');
6060
expect(screen.getAllByRole('button')[2]).toHaveTextContent('Upload');
6161
expect(screen.getAllByRole('button')[3]).toHaveTextContent('Tutorial');
@@ -64,12 +64,30 @@ describe('Unit testing for ButtonContainer', () => {
6464

6565
describe('When view is unlock', () => {
6666
test('Button should show as unlocked', () => {
67+
state.tabs['87'].mode.paused = false;
68+
render(<ButtonsContainer />);
69+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Unlocked');
70+
});
71+
});
72+
73+
describe('When view is lock', () => {
74+
test('Button should show as locked', () => {
6775
state.tabs['87'].mode.paused = true;
6876
render(<ButtonsContainer />);
6977
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Locked');
7078
});
7179
});
7280

81+
describe('Clicking pause-button toggles locked/unlocked', () => {
82+
test('When button is unlocked and it is clicked', async () => {
83+
render(<ButtonsContainer />);
84+
const button = screen.getAllByRole('button')[0];
85+
await userEvent.click(button);
86+
expect(dispatch).toHaveBeenCalledWith(toggleMode('paused'));
87+
});
88+
});
89+
90+
7391
describe('Upload/Download', () => {
7492
test('Clicking upload and download buttons', async () => {
7593
render(<ButtonsContainer />);

0 commit comments

Comments
 (0)