Skip to content

Commit c793c04

Browse files
committed
implemented testing for VideoCall & added ngrok instructions
1 parent 42061b8 commit c793c04

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

README.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ That is where RTConnect comes in - we take care of signaling and implementing We
4040
RTConnect is available as an [npm package](https://www.npmjs.com/package/rtconnect).
4141

4242
**npm:**
43-
4443
```
4544
npm install rtconnect
4645
```
@@ -62,13 +61,14 @@ npm install rtconnect
6261
6362
const path = require('path');
6463
const express = require('express');
65-
const app = express();
64+
app.use(bodyParser.urlencoded({ extended: true }));
6665
const PORT = 3000;
67-
66+
const app = express();
6867
const { SignalingChannel } = require('rtconnect'); // import the RTConnect Signaling Channel class
6968
69+
7070
app.use(express.json());
71-
app.use(express.urlencoded({extended : true}));
71+
app.use(bodyParser.urlencoded({extended : true}));
7272
app.use('/build', express.static(path.join(__dirname, '../build')));
7373
7474
app.get('/', (req, res) => {
@@ -88,7 +88,7 @@ SignalChannel.initializeConnection(); // invoke initializeConnection() method
8888

8989
6. Finally use the RTConnect VideoCall component as you would any other React component by passing in `‘ws://localhost:PORT’` as the URL prop as well as the optional mediaOptions prop
9090

91-
- `URL={ ‘ws://localhost:PORT’}` (Note: the PORT whatever you specified when you set up your server)
91+
- `URL={ ‘ws://localhost:PORT’}` (Note: the PORT whatever you specified when you set up your server so based on the server above, the port is 3000)
9292
- `mediaOptions={{ controls: true, style: { width: ‘640px’, height: ‘480px’ }}`
9393

9494
(Note: If you are using an https server, then pass in `‘wss://localhost:PORT’` as the URL prop).
@@ -112,30 +112,27 @@ const App = () => {
112112
export default App;
113113
```
114114

115-
## Setting Up a Secure Public Endpoint/URL
115+
## Setting Up Public Endpoint/URL Using a Secure Tunnel Service
116116
In order to create a publicly accessible URL that will allow you to share access to your localhost server, you have a number of different options but a simple option is to use a secure tunnel service. One such free, secure tunnel service that you can use to create a secure, encrypted, publicly accessible endpoint/URL that other users can access over the Internet is ngrok.
117117

118118
ngrok Secure Tunnels operate by using a locally installed ngrok agent to establish a private connection to the ngrok service. Your localhost development server is mapped to an ngrok.io sub-domain, which a remote user can then access. Once the connection is established, you get a public endpoint that you or others can use to access your local port. When a user hits the public ngrok endpoint, the ngrok edge figures out where to route the request and forwards the request over an encrypted connection to the locally running ngrok agent.
119119

120120
Thus, you do not need to expose ports, set up forwarding, or make any other network changes. You can simply install [ngrok npm package](https://www.npmjs.com/package/ngrok) and run it.
121121

122-
You have 2 options - you can install ngrok globally or you can install ngrok locally and then implement the ngrok.connect() method in your `server.js` file to open a tunnel.
123-
124-
1. Sign up for a free ngrok account, verify your email address, and get your authorization token.
122+
### Instructions for Using ngrok With RTConnect
123+
1. Sign up for a free ngrok account, verify your email address, and copy your authorization token.
125124

126125
2. Run the following command and replace with add your own authorization token:
127126
```
128127
config authtoken <your authorization token>
129128
```
130129

131-
### Install ngrok Globally
132-
133-
1. Install the ngrok npm package globally:
130+
3. Install the ngrok npm package globally:
134131
```
135132
npm install ngrok -g
136133
```
137134

138-
2. Start your app - make sure your server is running before you initiate the ngrok tunnel.
135+
4. Start your app - make sure your server is running before you initiate the ngrok tunnel.
139136

140137
* The following is a a basic example of what your App.jsx and server.js files might look like at this point if you used `npx create-react-app`. If you're using a proxy server, then the default port when you run `npm start` is 3000 so set your server port to something else such as 8080.
141138

@@ -164,14 +161,14 @@ export default App;
164161
165162
const path = require('path');
166163
const express = require('express');
164+
const bodyParser = require('body-parser');
167165
const ngrok = require('ngrok');
168-
const app = express();
169166
const PORT = 8080;
170167
const { SignalingChannel } = require('rtconnect'); // import the RTConnect Signaling Channel class
168+
const app = express();
171169
172170
app.use(express.json());
173-
app.use(express.urlencoded({extended : true}));
174-
app.use('/build', express.static(path.join(__dirname, '../build')));
171+
app.use(bodyParser.urlencoded({ extended: true }));
175172
176173
app.get('/', (req, res) => {
177174
res.status(200).sendFile(path.resolve(__dirname, '../index.html'));
@@ -186,7 +183,7 @@ const SignalChannel = new SignalingChannel(server); // instantiate the RTConnect
186183
SignalChannel.initializeConnection(); // invoke initializeConnection() method
187184
```
188185

189-
3. To start your ngrok Secure Tunnel, run the following command in your terminal:
186+
5. To start your ngrok Secure Tunnel, run the following command in your terminal:
190187
```
191188
ngrok http 3000 --host-header="localhost:3000"
192189
```
@@ -196,7 +193,7 @@ ngrok http 3000 --host-header="localhost:3000"
196193
ngrok http 3000 --host-header="localhost:3000" --auth='<username>:<a password>`
197194
```
198195

199-
4. Copy the https forwarding URL from the terminal and paste it into a new browser tab or send the link to a remote user.
196+
6. Copy the https forwarding URL from the terminal and paste it into a new browser tab or send the link to a remote user.
200197

201198

202199
## <a name="errors" /> Polyfill Errors
@@ -281,7 +278,6 @@ Yoojin Chang | [GitHub](https://github.com/ychang49265) | [LinkedIn](https://www
281278
Louis Disen | [GitHub](https://github.com/LouisDisen) | [LinkedIn](https://www.linkedin.com/in/louis-disen/)
282279
<br>
283280

284-
---
285281

286-
## <a name="support"/> ## A big shoutout to all of RTConnect's stargazers! Thank you!
287-
[![Thanks to all stargazers](https://git-lister.onrender.com/api/stars/oslabs-beta/RTConnect)](https://github.com/oslabs-beta/RTConnect/stargazers)
282+
## <a name="support"/>A big shoutout to all of RTConnect's stargazers! Thank you!
283+
[![Thank you to all of RTConnect's stargazers](https://git-lister.onrender.com/api/stars/oslabs-beta/RTConnect)](https://github.com/oslabs-beta/RTConnect/stargazers)

lib/__tests__/react-test/VideoCall.unit.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ describe('VideoCall', () => {
1414
}
1515
};
1616

17-
it('Check Submit Username button - click event fired', () => {
17+
const { container } = render(<VideoCall URL={Url} mediaOptions={options}/>);
18+
19+
it('Check Submit Username button', () => {
1820

19-
const { container } = render(<VideoCall URL={Url} mediaOptions={options}/>);
2021
const submitBtn = screen.getByTestId('submit-username-btn');
2122
expect(submitBtn.innerHTML).toBe('Submit Username');
2223
// fireEvent.click(submitBtn);

0 commit comments

Comments
 (0)