Skip to content

Commit

Permalink
Automate system test for entering and switching between rooms (#92)
Browse files Browse the repository at this point in the history
See: #59

Room slugs are also unique by workspace, not globally.

System Test and System Test Branded Domain workspaces have the same slug
for their room names; however this would fail without scoping the slug to the room.

Further, giving rooms a slug unique-to-workspace meant that we must tell Jitsi which
particular room we want someone to enter.
  • Loading branch information
user512 authored Aug 17, 2020
1 parent 387a406 commit 608658e
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 15 deletions.
4 changes: 4 additions & 0 deletions convene-web/app/helpers/rooms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ def video_room_path(workspace, room)
workspace_room_path(room.workspace, room)
end
end

def video_room_name(workspace, room)
"#{workspace.slug}--#{room.slug}"
end
end
2 changes: 1 addition & 1 deletion convene-web/app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Room < ApplicationRecord

# FriendlyId's does the legwork to make the slug uri-friendly
extend FriendlyId
friendly_id :name, use: :slugged
friendly_id :name, use: :scoped, scope: :workspace

# A Room's Access Level indicates what a participant must know in order to gain access to the room.
# `unlocked` indicates that the participant does not need to know anything to gain access.
Expand Down
2 changes: 1 addition & 1 deletion convene-web/app/views/rooms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
data-controller="video-room"
data-target="video-room.wrapper"
data-video-room-video-host="<%= current_workspace.jitsi_meet_domain %>"
data-video-room-name="<%= @current_room.slug %>"
data-video-room-name="<%= video_room_name(current_workspace, @current_room) %>"
data-video-room-workspace-path="<%= end_call_path(current_workspace) %>"
class="bg-gray-800"
>
Expand Down
13 changes: 13 additions & 0 deletions convene-web/spec/models/room_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
require "rails_helper"

RSpec.describe Room, type: :model do
describe ".slug" do
it "creates unique slugs by workspace scope" do
client = Client.create(name: "test")
workspace_1 = client.workspaces.create(name: "workspace1")
workspace_2 = client.workspaces.create(name: "workspace2")
workspace_1_room = workspace_1.rooms.create(name: 'room1', publicity_level: :listed)
workspace_2_room = workspace_2.rooms.create(name: 'room1', publicity_level: :listed)

expect(workspace_1_room.slug).to eq 'room1'
expect(workspace_2_room.slug).to eq 'room1'
end
end

describe ".listed" do
it "does not include rooms whose publicity level is unlisted" do
client = Client.create(name: "test")
Expand Down
14 changes: 7 additions & 7 deletions features/entering-rooms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ Feature: Entering Rooms
When the Workspace Member taps the "Listed Room 1" Room in the Room Picker
Then the Workspace Member is placed in the "Listed Room 1" Room

@built @unimplemented-steps
@built
Scenario: Entering Room via Room Picker from another Room
Given I am in a Room
When I tap a different Room in the Room Picker
Then I am in the Room
Given the Workspace Member is in the "System Test" Workspace and in the "Listed Room 1" Room
When the Workspace Member taps the "Listed Room 2" Room in the Room Picker
Then the Workspace Member is placed in the "Listed Room 2" Room

@built @unimplemented-steps
Scenario: Entering Room via Slug on a Branded Domain
Given a Workspace with a Branded Domain
When I visit a Room's using a slug on their Branded Domain
Then I am in the Room

@built @unimplemented-steps
@built
Scenario: Entering Room via Room full URL
When I visit a Room's full URL
Then I am in the Room
When the Workspace Member visit the "System Test" Workspace, "Listed Room 1" Room full URL
Then the Workspace Member is placed in the "Listed Room 1" Room
17 changes: 11 additions & 6 deletions features/page-objects/WorkspacePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ class WorkspacePage extends Page {
this.driver.get(`${this.baseUrl}/workspaces/${workspace.slug}`);
}

enterRoom(room) {
const roomCard = this.findRoomCard(room);
enterRoomThruUrl(workspace, room) {
this.driver.get(`${this.baseUrl}/workspaces/${workspace.slug}/rooms/${room.slug}`);
}

async enterRoom(room) {
const roomCard = await this.findRoomCard(room);
roomCard.findElement(By.linkText("Enter Room")).click();
}

findRoomCard(room) {
return this.driver.findElement(By.id(room.name))
async findRoomCard(room) {
await this.driver.wait(until.elementLocated(By.id(room.name)));
return await this.driver.findElement(By.id(room.name));
}

async videoPanel() {
await this.driver.wait(until.elementLocated(By.css("[name='jitsiConferenceFrame0']")));
return await this.driver.findElement(By.css("[name='jitsiConferenceFrame0']"));
await this.driver.wait(until.elementLocated(By.css("[name*='jitsiConferenceFrame']")));
return await this.driver.findElement(By.css("[name*='jitsiConferenceFrame']"));
}
}

Expand Down
1 change: 1 addition & 0 deletions features/parameter-types/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defineParameterType({
class Room {
constructor(roomName) {
this.name = roomName;
this.slug = roomName.replace(/\s+/g, '-').toLowerCase();
}
}

Expand Down
11 changes: 11 additions & 0 deletions features/steps/workspace_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Given('the {actor} is on the {workspace} Dashboard', async function (actor, work
await this.workspace.enter(workspace);
});

Given('the {actor} is in the {workspace} and in the {room}', async function (actor, workspace, room) {
this.workspace = new WorkspacePage(this.driver);
await this.workspace.enter(workspace);
await this.workspace.enterRoom(room);
});

When('the {actor} visit the {workspace}, {room} full URL', async function (actor, workspace, room) {
this.workspace = new WorkspacePage(this.driver);
await this.workspace.enterRoomThruUrl(workspace, room);
});

Then('the {workspace} is available at the {string} domain', function (workspace, string) {
// Write code here that turns the phrase above into concrete actions
return 'pending';
Expand Down

0 comments on commit 608658e

Please sign in to comment.