Skip to content

Commit

Permalink
Merge pull request #48 from twilio-labs/support-go-rooms
Browse files Browse the repository at this point in the history
Implement Go Room Type Support
  • Loading branch information
timmydoza authored Sep 30, 2020
2 parents 8037937 + 5c36244 commit 12eb578
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.5.0

### Enhancements

- Updated the `--room-type` flag to add new 'go' room type.

## 0.4.0

### Maintenence
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ OPTIONS
--app-directory=app-directory Name of app directory to use
--authentication=(passcode) (required) Type of authentication to use
--override Override an existing App deployment
--room-type=(group|group-small|peer-to-peer) [default: group] Set room type
--room-type=(group|group-small|peer-to-peer|go) [default: group] Set room type
DESCRIPTION
This command publishes two components as a Twilio Function: an application token
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@twilio-labs/plugin-rtc",
"version": "0.4.1",
"version": "0.5.0",
"description": "A Twilio-CLI plugin for real-time communication apps",
"main": "index.js",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/rtc/apps/video/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ DeployCommand.flags = Object.assign(
description: 'Override an existing App deployment',
}),
'room-type': flags.enum({
options: ['group', 'group-small', 'peer-to-peer'],
options: ['group', 'group-small', 'peer-to-peer', 'go'],
description: 'Type of room to use',
required: false,
default: 'group',
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ describe('the RTC Twilio-CLI Plugin', () => {
});
});

describe('after deploying a token server (with peer-to-peer rooms)', () => {
describe('after deploying a token server (with go rooms)', () => {
let URL;
let passcode;
let webAppURL;

beforeAll(async done => {
stdout.start();
await DeployCommand.run(['--authentication', 'passcode', '--room-type', 'peer-to-peer']);
await DeployCommand.run(['--authentication', 'passcode', '--room-type', 'go']);
stdout.stop();
passcode = getPasscode(stdout.output);
URL = getURL(stdout.output);
Expand All @@ -248,22 +248,22 @@ describe('the RTC Twilio-CLI Plugin', () => {
stdout.start();
await ViewCommand.run([]);
stdout.stop();
expect(stdout.output).toMatch(/Passcode: \d{3} \d{3} \d{4} \d{4}\nExpires: .+\nRoom Type: peer-to-peer/);
expect(stdout.output).toMatch(/Passcode: \d{3} \d{3} \d{4} \d{4}\nExpires: .+\nRoom Type: go/);
expect(stdout.output).not.toMatch(/Web App URL:/);
});
});

describe('the serverless deployment', () => {
it('should create a peer-to-peer room and return a video token when the correct passcode is provided', async () => {
it('should create a go room and return a video token when the correct passcode is provided', async () => {
const ROOM_NAME = nanoid();
const { body } = await superagent
.post(`${URL}/token`)
.send({ passcode, room_name: ROOM_NAME, user_identity: 'test user' });
expect(jwt.decode(body.token).grants).toEqual({ identity: 'test user', video: { room: ROOM_NAME } });
expect(body.room_type).toEqual('peer-to-peer');
expect(body.room_type).toEqual('go');

const room = await twilioClient.video.rooms(ROOM_NAME).fetch();
expect(room.type).toEqual('peer-to-peer');
expect(room.type).toEqual('go');
});

it('should return a 401 error when an incorrect passcode is provided', () => {
Expand Down

0 comments on commit 12eb578

Please sign in to comment.