From cd96a3d31f736d32d0501d584b60bb40316e8eb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sabrina=20W=C3=BCst?=
<119059706+Sabr1n4W@users.noreply.github.com>
Date: Wed, 17 Jun 2026 08:20:33 +0200
Subject: [PATCH 01/35] Move guest name to access code overlay
---
lang/en/app.php | 1 +
lang/en/auth.php | 1 +
lang/en/rooms.php | 1 +
.../js/components/RoomAccessCodeOverlay.vue | 206 ++++++++++++++++++
.../js/components/RoomGuestWelcomeCard.vue | 98 +++++++++
resources/js/components/RoomJoinButton.vue | 34 +--
resources/js/views/RoomsView.vue | 112 +++-------
7 files changed, 342 insertions(+), 111 deletions(-)
create mode 100644 resources/js/components/RoomAccessCodeOverlay.vue
create mode 100644 resources/js/components/RoomGuestWelcomeCard.vue
diff --git a/lang/en/app.php b/lang/en/app.php
index 721d9b0a6a..055427f402 100644
--- a/lang/en/app.php
+++ b/lang/en/app.php
@@ -118,6 +118,7 @@
'next_page' => 'Next page',
'no' => 'No',
'not_found' => '404 | The requested address was not found',
+ 'or' => 'or',
'overwrite' => 'Overwrite',
'previous_page' => 'Previous page',
'profile' => 'Profile',
diff --git a/lang/en/auth.php b/lang/en/auth.php
index 9ba62f17a8..9e64df11a6 100644
--- a/lang/en/auth.php
+++ b/lang/en/auth.php
@@ -42,6 +42,7 @@
'logout_success' => 'Successfully logged out',
'new_password' => 'New password',
'new_password_confirmation' => 'New password confirmation',
+ 'offer_login' => "Login with your user account",
'oidc' => [
'logout_incomplete' => 'You are still logged in at the OpenID Connect provider.',
'redirect' => 'Log in',
diff --git a/lang/en/rooms.php b/lang/en/rooms.php
index e7cb23dd65..88763c7607 100644
--- a/lang/en/rooms.php
+++ b/lang/en/rooms.php
@@ -24,6 +24,7 @@
'detached' => 'Connection to ongoing video conference lost, recovery failed.',
'reconnecting' => 'Connection to ongoing video conference lost, trying to reconnect.',
],
+ 'continue_as_guest' => 'Continue as guest',
'create' => [
'ok' => 'Create',
'title' => 'Create room',
diff --git a/resources/js/components/RoomAccessCodeOverlay.vue b/resources/js/components/RoomAccessCodeOverlay.vue
new file mode 100644
index 0000000000..7ad10f9f00
--- /dev/null
+++ b/resources/js/components/RoomAccessCodeOverlay.vue
@@ -0,0 +1,206 @@
+
+
Test
"; + room.data.access_code = null; + room.data.current_user = null; + + const reloadRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123", + { + statusCode: 200, + body: room, + }, + "roomRequest", + ); + + // Trigger reload + cy.get('[data-test="reload-room-button"]').click(); + cy.get('[data-test="reload-room-button"]') + .should("be.disabled") + .then(() => { + reloadRequest.sendResponse(); + }); + }); + + cy.title().should("eq", "Meeting Two - PILOS Test"); + + // Check that room Header is shown correctly + cy.contains("Meeting Two").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains( + 'rooms.index.room_component.running_since_{"date":"08/21/2023, 04:18"}', + ).should("be.visible"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Reload page + cy.reload(); + + // Check that access overlay is shown + cy.title().should("eq", "Meeting Two - PILOS Test"); + + // Check that access overlay is shown + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that header is shown + cy.contains("Meeting Two").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains( + 'rooms.index.room_component.running_since_{"date":"08/21/2023, 04:18"}', + ).should("be.visible"); + + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]') + .should("be.visible") + .and("have.text", "auth.offer_login") + .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); + + // Check that participant name input is shown + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name") + .should("be.visible") + .and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is not shown + cy.get('[data-test="access-code-field"]').should("not.exist"); + }); + + // Check that name is still not set in localStorage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + }); + + it("rooms view as guest with remember me enabled", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access overlay is shown + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that header is shown + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]') + .should("be.visible") + .and("have.text", "auth.offer_login") + .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); + + // Check that participant name input is shown + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name") + .should("be.visible") + .and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is not shown + cy.get('[data-test="access-code-field"]').should("not.exist"); + + // Enter guest name + cy.get("#participant-name").type("Laura Rivera"); + + // Check remember me + cy.get("#remember-participant-name").check(); + + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + }); + + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Check that name was set in the local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.eq( + "Laura Rivera", + ); + }); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload page + cy.reload(); + + // Check that room is still shown with the same guest name + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Check that name is still set in the local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.eq( + "Laura Rivera", + ); + }); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + }); + + it("room view with access code as logged in user", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access code overlay is shown correctly + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check header is shown + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that login button is hidden + cy.get('[data-test="room-login-as-user-button"]').should("not.exist"); + + // Check that participant name input is hidden + cy.get('[data-test="participant-name-field"]').should("not.exist"); + + // Check that access code input is shown + cy.get('[data-test="access-code-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.access_code").should("be.visible"); + cy.get("#access-code").should("be.visible").and("have.value", ""); + }); + + // Try to submit with correct access code + cy.get("#access-code").type("123456789"); + }); + + const roomAuthRequest = interceptIndefinitely( + "POST", + "api/v1/rooms/abc-def-123/auth", + { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }, + "roomAuthRequest", + ); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + // Check loading + cy.get("[data-test='reload-room-button']").should("be.disabled"); + cy.get('[data-test="room-login-button"]') + .should("be.disabled") + .then(() => { + roomAuthRequest.sendResponse(); + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that access code was set in sessionStorage + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is hidden + cy.contains("rooms.name_in_video_conference").should("not.exist"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("be.visible"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that the correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload with access code set in sessionStorage + cy.log("Reload with access code set in sessionStorage"); + cy.reload(); + + // Check that new auth request was sent with the stored access code + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + // Check that access overlay is not shown + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("be.visible"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that the correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload without access code set in sessionStorage but accessCode hash + cy.log( + "Reload without access code set in sessionStorage but accessCode hash", + ); + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + + cy.visit("/rooms/abc-def-123#accessCode=123456789"); + cy.reload(); + + // Check that new auth request was sent with the access code from the hash + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + // Check that sessionStorage is set + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + // Check that access code is removed from the hash + cy.url().should("not.contain", "#accessCode"); + + // Check that access overlay is not shown + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("be.visible"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that the correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload without access code set in sessionStorage and try with valid access code again + cy.log( + "Reload without access code set in sessionStorage and try with valid access code again", + ); + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.window().then((win) => { + win.sessionStorage.removeItem("roomAccessCode_abc-def-123"); + }); + + cy.reload(); + + cy.wait("@roomRequest"); + + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Try to submit with correct access code + cy.get("#access-code").type("123456789"); + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 200, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Reload with invalid access code + const errorReloadRoomRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123*", + { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }, + "roomRequest", + ); + + cy.get('[data-test="reload-room-button"]').click(); + + // Intercept second request (reload room) and send response of the first request + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }) + .as("roomRequest") + .then(() => { + errorReloadRoomRequest.sendResponse(); + }); + }); + + // Check that access code header is set for the first request + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + // Check that access code header is reset for the second request (reload room) + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.not.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + // Check if error message is shown + cy.checkToastMessage("rooms.flash.access_code_invalid"); + + cy.contains("rooms.flash.access_code_invalid").should("be.visible"); + + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + // Retry with valid access code but no access code needed anymore + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Try to submit with correct access code + cy.get("#access-code").type("123456789"); + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 204, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; + room.data.allow_membership = true; + room.data.is_member = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query.room_auth_token).to.be.undefined; + expect(interception.request.query.room_auth_token_type).to.be.undefined; + }); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + }); + + it("room view with access code as guest", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + room.data.authenticated = false; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access overlay is shown + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that header is shown + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]') + .should("be.visible") + .and("have.text", "auth.offer_login") + .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); + + // Check that participant name input is shown + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name") + .should("be.visible") + .and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is shown + cy.get('[data-test="access-code-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.access_code").should("be.visible"); + cy.get("#access-code").should("be.visible").and("have.value", ""); + }); + + // Enter guest name + cy.get("#participant-name").type("Laura Rivera"); + + // Enter access code + cy.get("#access-code").type("123456789"); + }); + + const roomAuthRequest = interceptIndefinitely( + "POST", + "api/v1/rooms/abc-def-123/auth", + { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }, + "roomAuthRequest", + ); + + cy.fixture("room.json").then((room) => { + room.data.description = "Test
"; + room.data.current_user = null; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + // Check loading + cy.get("[data-test='reload-room-button']").should("be.disabled"); + cy.get('[data-test="room-login-button"]') + .should("be.disabled") + .then(() => { + roomAuthRequest.sendResponse(); + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that access code was set in sessionStorage + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Check that name was not set in local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that the correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload with access code provided through hash params + cy.log("Reload with access code provided through hash params"); + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + + cy.fixture("room.json").then((room) => { + room.data.authenticated = false; + room.data.current_user = null; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123#accessCode=123-456-789"); + cy.reload(); + + cy.wait("@roomRequest"); + + // Check that access overlay is shown and access code is prefilled + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that header is shown + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]') + .should("be.visible") + .and("have.text", "auth.offer_login") + .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); + + // Check that participant name input is shown + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name") + .should("be.visible") + .and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is shown + cy.get('[data-test="access-code-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.access_code").should("be.visible"); + cy.get("#access-code") + .should("be.visible") + .and("have.value", "123-456-789"); + }); + }); + + // Reload with access code set in sessionStorage + cy.log("Reload with access code set in sessionStorage"); + cy.fixture("room.json").then((room) => { + room.data.authenticated = false; + room.data.current_user = null; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.reload(); + + cy.wait("@roomRequest"); + + // Check that access overlay is shown and access code is prefilled + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that header is shown + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]') + .should("be.visible") + .and("have.text", "auth.offer_login") + .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); + + // Check that participant name input is shown + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name") + .should("be.visible") + .and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is shown + cy.get('[data-test="access-code-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.access_code").should("be.visible"); + cy.get("#access-code") + .should("be.visible") + .and("have.value", "123-456-789"); + }); + }); + + // Reload without access code set in sessionStorage but saved guestName + cy.log( + "Reload without access code set in sessionStorage but saved guestName", + ); + cy.fixture("room.json").then((room) => { + room.data.authenticated = false; + room.data.current_user = null; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.window().then((win) => { + win.sessionStorage.clear(); + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.reload(); + + cy.wait("@roomRequest"); + + // Check that access overlay is shown and guest name is prefilled + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that header is shown + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]') + .should("be.visible") + .and("have.text", "auth.offer_login") + .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); + + // Check that participant name input is shown + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("be.checked"); + }); + + // Check that access code input is shown + cy.get('[data-test="access-code-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.access_code").should("be.visible"); + cy.get("#access-code").should("be.visible").and("have.value", ""); + }); + }); + + // Reload with access code set in sessionStorage and saved guestName + cy.log("Reload with access code set in sessionStorage and saved guestName"); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.description = "Test
"; + room.data.current_user = null; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.window().then((win) => { + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "123456789"); + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.reload(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that the correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + }); + + it("room view with legacy access code", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.legacy_code = true; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access code input is shown correctly + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Submit valid access code + cy.get("#access-code").type("012abc"); + }); + + // Intercept room auth request + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "012abc", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("be.visible"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that the correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + }); + + it("room auth with access code errors", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access overlay is shown correctly + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + // Try to submit without access code + }); + + // Check with 422 error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 422, + body: { + message: "The Access code field is required.", + errors: { + access_code: ["The Access code field is required."], + }, + }, + }).as("roomAuthRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + }); + + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.contains("The Access code field is required.").should("be.visible"); + + // Try to submit with invalid access code + cy.get("#access-code").type("987654321"); + }); + + // Check with invalid_code error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_code", + }, + }).as("roomAuthRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + // Intercept room request (reload room) + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + // Wait for room auth request and check if access code is set + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "987654321", + type: 0, + }); + }); + + // Wait for room request + cy.wait("@roomRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + }); + + // Check if error message is shown + cy.checkToastMessage("rooms.flash.access_code_invalid"); + + cy.contains("rooms.flash.access_code_invalid").should("be.visible"); + + // Intercept room auth request and respond with rate limit error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 429, + body: { + limit: "room_auth", + retry_after: 5, + }, + }).as("roomAuthRequest"); + + cy.clock(); + + cy.get('[data-test="room-login-button"]').click(); + + // Wait for room auth request + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "987654321", + type: 0, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + }); + + // Check if input and buttons are disabled + cy.get("#access-code").should("be.disabled"); + cy.get('[data-test="room-login-button"]').should("be.disabled"); + cy.get('[data-test="reload-room-button"]').should("be.disabled"); + + // Check countdown + for (let i = 5; i > 0; i--) { + // Check if countdown message is updated + cy.contains('rooms.auth_throttled_{"try_again":' + i + "}").should( + "be.visible", + ); + + // Tick clock 1 sec forward + cy.tick(1000); + } + + // restore the clock + cy.clock().then((clock) => { + clock.restore(); + }); + + // Check toast message + cy.checkToastMessage("app.flash.too_many_requests"); + + // Check if input and buttons are enabled again + cy.get("#access-code").should("not.be.disabled"); + cy.get('[data-test="room-login-button"]').should("not.be.disabled"); + cy.get('[data-test="reload-room-button"]').should("not.be.disabled"); + + // Check with 500 error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("roomAuthRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + }); + + // Check that error message is shown + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + // Check that access overlay is still shown and not disabled + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#access-code").should("not.be.disabled"); + cy.get('[data-test="room-login-button"]').should("not.be.disabled"); + + // Check with guests not allowed + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 403, + body: { + message: "guests_not_allowed", + }, + }).as("roomAuthRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + }); + + // Check if error message is shown + // Check that the error message is shown + cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); + + // Check that access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check with 404 error (room not found) as authenticated user + cy.interceptRoomIndexRequests(); + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 404, + body: { + message: "model_not_found", + model: "room", + ids: ["abc-def-123"], + }, + }).as("roomAuthRequest"); + + cy.reload(); + + cy.wait("@roomRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + // Check that redirect to room index page worked + cy.url() + .should("include", "/rooms") + .and("not.include", "/rooms/abc-def-123"); + + // Check that error message is shown + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); + + // Check with 404 error (room not found) as guest + cy.intercept("GET", "api/v1/currentUser", {}); + cy.fixture("room.json").then((room) => { + room.data.current_user = null; + room.data.authenticated = false; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.get("#participant-name").type("Max Doe"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Check that redirect to 404 page worked + cy.url().should("include", "/404").and("not.include", "/rooms/abc-def-123"); + + // Check that error message is shown + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); + }); + + it("room view with access code errors", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access code input is shown correctly + cy.get("#access-code").type("123456789"); + + // Check with invalid token error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + const roomRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123*", + { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }, + "roomRequest", + ); + + cy.get('[data-test="room-login-button"]').click(); + + // Wait for room auth request and check if access code is set + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + cy.fixture("room.json") + .then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }) + .then(() => { + roomRequest.sendResponse(); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query.room_auth_token).to.be.undefined; + expect(interception.request.query.room_auth_token_type).to.be.undefined; + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.access_code_invalid"); + + cy.contains("rooms.flash.access_code_invalid").should("be.visible"); + + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + // Check with 500 error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("roomRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + // Check that error message is shown + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + // Check that access code overlay is still shown and not disabled + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#access-code").should("not.be.disabled"); + cy.get('[data-test="room-login-button"]').should("not.be.disabled"); + }); + + it("room view with personalized link (participant)", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + // Intercept room auth request + const roomAuthRequest = interceptIndefinitely( + "POST", + "api/v1/rooms/abc-def-123/auth", + { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }, + "roomAuthRequest", + ); + + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.get("[data-test='room-loading-spinner']") + .should("be.visible") + .then(() => { + roomAuthRequest.sendResponse(); + }); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + // Check that room auth token is set + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + // Check that sessionStorage was set + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that personalized link was removed from url + cy.url().should("not.include", "#personalizedLink"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload page with personalizedLink set in sessionStorage + cy.log("Reload page with personalizedLink set in sessionStorage"); + cy.reload(); + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + // Check that room auth token is set + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + // Check that sessionStorage is still set + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + + // Reload with invalid token + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_personalized_link", + }, + }).as("roomAuthRequest"); + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }).as("roomRequest"); + + cy.get('[data-test="reload-room-button"]').click(); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.personalized_link_invalid"); + cy.contains("rooms.invalid_personalized_link").should("be.visible"); + }); + + it("room view with personalized link (moderator)", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + // Intercept room auth request + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.is_moderator = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + // Check that header for token is set + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + // Check that sessionStorage was set + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that personalized link was removed from url + cy.url().should("not.include", "#personalizedLink"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + }); + + it("room view with personalized link legacy route", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + // Intercept room auth request + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.is_moderator = false; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + // Visit room with personalized link (legacy personalized link route) + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + // Check that header for token is set + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + // Check that sessionStorage was set + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that personalized link is not visible in the url + cy.url().should("not.include", "#personalizedLink"); + cy.url().should( + "not.include", + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("not.exist"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); + + // Check if share button is hidden + cy.get('[data-test="room-share-button"]').should("not.exist"); + }); + + it("room auth with personalized link errors", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + // 401 invalid personalize link + // Intercept room auth request + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_personalized_link", + }, + }).as("roomAuthRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123")).to + .be.null; + }); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.personalized_link_invalid"); + cy.contains("rooms.invalid_personalized_link").should("be.visible"); + + // Reload and check with 422 error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 422, + body: { + message: "The Access token field is required.", + errors: { + personalized_link_token: ["The Access token field is required."], + }, + }, + }).as("roomAuthRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123")).to + .be.null; + }); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.personalized_link_invalid"); + cy.contains("rooms.invalid_personalized_link").should("be.visible"); + + // Check with guests only error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 420, + body: { + message: "guests_only", + }, + }).as("roomAuthRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123")).to + .be.null; + }); + + cy.checkToastMessage("app.flash.guests_only"); + cy.url() + .should("not.include", "/rooms") + .and("not.include", "rooms/abc-def-123"); + + // Check with 500 error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("roomAuthRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123")).to + .be.null; + }); + + // Check that error message is shown + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + // Check that reload button is shown + cy.get('[data-test="reload-button"]').should("be.visible"); + + // Click reload button and make sure auth request is sent again + // Reload with valid auth request and room request + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="reload-button"]').click(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that room is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check with 404 error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 404, + body: { + message: "model_not_found", + model: "room", + ids: ["abc-def-123"], + }, + }).as("roomAuthRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + // Check that redirect to 404 page worked and error message is shown + cy.url().should("include", "/404").and("not.include", "rooms/abc-def-123"); + + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); + }); + + it("room view with personalized link errors", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + // Check with 401 invalid token error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + const roomRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123*", + { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }, + "roomRequest", + ); + + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_personalized_link", + }, + }).as("roomAuthRequest"); + + roomRequest.sendResponse(); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.personalized_link_invalid"); + cy.contains("rooms.invalid_personalized_link").should("be.visible"); + + // Check with guests only error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 420, + body: { + message: "guests_only", + }, + }).as("roomRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + cy.checkToastMessage("app.flash.guests_only"); + cy.url() + .should("not.include", "/rooms") + .and("not.include", "rooms/abc-def-123"); + + // Check with 500 error + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("roomRequest"); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that error message is shown + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + // Check that reload button is shown + cy.get('[data-test="reload-button"]').should("be.visible"); + + // Intercept room auth request with different token + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "differentToken", + type: 1, + }, + }, + }).as("differentRoomAuthRequest"); + + // Click reload button and make sure room request is sent again with same auth token + // Reload with valid room request + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="reload-button"]').click(); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that room is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that room auth request was not sent again + cy.get("@differentRoomAuthRequest").should("be.null"); + }); + + it("visit with personalized link as authenticated user", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.is_member = true; + room.data.is_moderator = true; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + // Visit room with personalized link + cy.visit( + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + // Check that error message is shown and user is redirected to the home page + cy.checkToastMessage("app.flash.guests_only"); + cy.url().should( + "not.include", + "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + it("reload with access code errors", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access code input is shown correctly + cy.get("#access-code").type("123456789"); + + // Check with invalid token error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = true; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + // Test reload with invalid token error + const roomRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123*", + { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }, + "roomRequest", + ); + + cy.get('[data-test="reload-room-button"]').click(); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }) + .as("roomRequest") + .then(() => { + roomRequest.sendResponse(); + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query.room_auth_token).to.be.undefined; + expect(interception.request.query.room_auth_token_type).to.be.undefined; + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.access_code_invalid"); + + cy.contains("rooms.flash.access_code_invalid").should("be.visible"); + + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + // Revisit as a member with a saved access code and check that a later reload requiring the code resets saved access parameters + cy.log( + "Revisit as a member with a saved access code and check that a later reload requiring the code resets saved access parameters", + ); + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = true; + room.data.description = "Test
"; + room.data.allow_membership = true; + room.data.is_member = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "123456789", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + }); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("be.visible"); + + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.authenticated = false; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="reload-room-button"]').click(); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + }); + + cy.checkToastMessage("rooms.require_access_code"); + + cy.contains("rooms.flash.access_code_invalid").should("not.exist"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#access-code").should("have.value", ""); + }); + + it("reload with personalized link errors", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + // Check with 401 invalid token error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit( + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest"); + cy.wait("@roomRequest"); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check with invalid token error + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }).as("roomRequest"); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_personalized_link", + }, + }).as("roomAuthRequest"); + + cy.get('[data-test="reload-room-button"]').click(); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + cy.wait("@roomAuthRequest"); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Check that error message is shown + cy.checkToastMessage("rooms.flash.personalized_link_invalid"); + cy.contains("rooms.invalid_personalized_link").should("be.visible"); + + // Check with guests only error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.fixture("room.json").then((room) => { + room.data.username = "Laura Rivera"; + room.data.allow_membership = true; + room.data.is_member = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.reload(); + + cy.wait("@roomAuthRequest"); + cy.wait("@roomRequest"); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 420, + body: { + message: "guests_only", + }, + }).as("roomRequest"); + + cy.get('[data-test="reload-room-button"]').click(); + + cy.wait("@roomRequest"); + + // Check that error message is shown + cy.checkToastMessage("app.flash.guests_only"); + cy.url() + .should("not.include", "/rooms") + .and("not.include", "rooms/abc-def-123"); + }); + + it("logged in status change", function () { + cy.interceptRoomFilesRequest(); + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("be.visible"); + cy.get("#tab-tokens").should("be.visible"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("be.visible"); + cy.get("#tab-settings").should("be.visible"); + + // Change current user to guest + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="reload-room-button"]').click(); + + // Check that access overlay is shown + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + // Check that login button is shown + cy.get('[data-test="room-login-as-user-button"]').should("be.visible"); + + // Check that guest name input is shown and enter name + cy.get("#participant-name").should("be.visible").type("Max Doe"); + + // Check that access code input is hidden + cy.get('[data-test="access-code-field"]').should("not.exist"); + + // Login + cy.get('[data-test="room-login-button"]').click(); + }); + + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("not.exist"); + cy.get("#tab-members").should("not.exist"); + cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("not.exist"); + cy.get("#tab-settings").should("not.exist"); + + // Change current user to co_owner + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.is_member = true; + room.data.is_co_owner = true; + room.data.current_user = { + id: 2, + firstname: "Max", + lastname: "Doe", + user_locale: "en", + permissions: ["rooms.create"], + model_name: "User", + room_limit: -1, + }; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="reload-room-button"]').click(); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("be.visible"); + cy.get("#tab-tokens").should("be.visible"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("be.visible"); + cy.get("#tab-settings").should("be.visible"); + }); + + it("rooms view with participant name errors", function () { + // Check as guest user (room does not require an access code) + cy.intercept("GET", "api/v1/currentUser", {}); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access overlay is shown + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name").should("be.visible").and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is not shown + cy.get('[data-test="access-code-field"]').should("not.exist"); + + // Check that required error is not visible before an input was made + cy.get('[data-test="participant-name-field"]') + .contains('validation.required_{"attribute":"rooms.first_and_lastname"}') + .should("not.exist"); + + // Enter guest name that is too short + cy.get("#participant-name").type("L"); + + cy.get('[data-test="participant-name-field"]').contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ); + + // Click login button + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + // Check that access code overlay is still shown and error message is still there + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ) + .should("be.visible"); + + // Enter characters to reach the required min length + cy.get("#participant-name").type("a"); + + // Check that error message is gone + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ) + .should("not.exist"); + + // Enter invalid character + cy.get("#participant-name").type("<"); + + // Check that error message is shown again + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.validname_{"attribute":"rooms.first_and_lastname","chars":"<"}', + ) + .should("be.visible"); + + // Enter another invalid character + cy.get("#participant-name").type(">"); + + // Check that error message is updated + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.validname_{"attribute":"rooms.first_and_lastname","chars":"<>"}', + ) + .should("be.visible"); + + // Clear input + cy.get("#participant-name").clear(); + + // Check that error message is updated + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.validname_{"attribute":"rooms.first_and_lastname","chars":"<>"}', + ) + .should("not.exist"); + + cy.get('[data-test="participant-name-field"]') + .contains('validation.required_{"attribute":"rooms.first_and_lastname"}') + .should("be.visible"); + + // Enter name that is valid and has the max length + cy.get("#participant-name").type("A".repeat(50)); + + cy.get('[data-test="participant-name-field"]') + .contains('validation.required_{"attribute":"rooms.first_and_lastname"}') + .should("not.exist"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.max.string_{"attribute":"rooms.first_and_lastname","max":50}', + ) + .should("not.exist"); + + // Enter one mor character to exceed allowed max length + cy.get("#participant-name").type("A"); + + // Check that error message is updated + cy.get('[data-test="participant-name-field"]') + .contains('validation.required_{"attribute":"rooms.first_and_lastname"}') + .should("not.exist"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.max.string_{"attribute":"rooms.first_and_lastname","max":50}', + ) + .should("be.visible"); + + // Check as guest user (room requires an access code) + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + room.data.authenticated = false; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.reload(); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + // Check that access overlay is shown + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + cy.get("#participant-name").should("be.visible").and("have.value", ""); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check that access code input is shown + cy.get('[data-test="access-code-field"]').should("be.visible"); + + // Check that required error is not visible before an input was made + cy.get('[data-test="participant-name-field"]') + .contains('validation.required_{"attribute":"rooms.first_and_lastname"}') + .should("not.exist"); + + // Enter guest name that is too short + cy.get("#participant-name").type("L"); + + cy.get('[data-test="participant-name-field"]').contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 422, + body: { + message: "The Access code field is required.", + errors: { + access_code: ["The Access code field is required."], + }, + }, + }).as("roomAuthRequest"); + + // Click login button + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + // Check that access code overlay is still shown and error message is still there + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ) + .should("be.visible"); + + // Check that room auth request was not sent and access code error is not shown + cy.get("@roomAuthRequest").should("be.null"); + + cy.get('[data-test="access-code-field"]') + .contains("The Access code field is required.") + .should("not.exist"); + }); + + it("change participant name as guest", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + // Enter guest name + cy.get("#participant-name").type("Laura Rivera"); + + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Check that name was not set in local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Open change name dialog + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .and("have.text", "rooms.change_participant_name") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .and("contain.text", "rooms.change_participant_name") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Check buttons + cy.get('[data-test="dialog-cancel-button"]') + .should("be.visible") + .and("have.text", "app.cancel"); + cy.get('[data-test="dialog-save-button"]') + .should("be.visible") + .and("have.text", "app.save"); + + // Change participant name + cy.get("#participant-name").clear(); + cy.get("#participant-name").type("Max Doe"); + + // Cancel + cy.get('[data-test="dialog-cancel-button"]').click(); + }); + + // Check that dialog was closed + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + // Check that participant name is still the same + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + + // Check that name was not set in local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Open dialog again and change name + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .and("contain.text", "rooms.change_participant_name") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Change participant name + cy.get("#participant-name").clear(); + cy.get("#participant-name").type("Max Doe"); + + // Save + cy.get('[data-test="dialog-save-button"]').click(); + }); + + // Check that dialog was closed + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + // Check that name was not set in local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Check that participant name is updated + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + + // Open dialog again and check that input is prefilled with the current name + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Max Doe"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Reload room with guest name set in localStorage + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.reload(); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Open change name dialog and change name + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("be.checked"); + }); + + // Change participant name + cy.get("#participant-name").clear(); + cy.get("#participant-name").type("Max Doe"); + + // Save + cy.get('[data-test="dialog-save-button"]').click(); + }); + + // Check that dialog was closed + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + // Check that name saved in localStorage was updated + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.eq("Max Doe"); + }); + + // Check that participant name is updated + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + + // Open dialog again and check that input is prefilled with the current name + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Max Doe"); + cy.get("#remember-participant-name").and("be.checked"); + }); + }); + + it("change remember participant name as guest", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.title().should("eq", "Meeting One - PILOS Test"); + + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + // Enter guest name + cy.get("#participant-name").type("Laura Rivera"); + + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Check that name was not set in local storage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Open change name dialog + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .and("have.text", "rooms.change_participant_name") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]').within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Change remember participant name checkbox + cy.get("#remember-participant-name").check(); + + // Save + cy.get('[data-test="dialog-save-button"]').click(); + }); + + // Check that dialog was closed + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + // Check that participant name is still the same + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + + // Check that name was set in localStorage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.equal( + "Laura Rivera", + ); + }); + + // Open dialog again and change remember participant name again + cy.get('[data-test="change-participant-name-button"]').click(); + + cy.get('[data-test="room-change-participant-name-dialog"]').within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.first_and_lastname").should("be.visible"); + + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("be.checked"); + }); + + // Change remember participant name checkbox + cy.get("#remember-participant-name").uncheck(); + + cy.get('[data-test="dialog-save-button"]').click(); + }); + + // Check that dialog was closed + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + // Check that name was removed from localStorage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Check that participant name is the same + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + + // Open dialog again and check that input is prefilled with the current name and remember state is correct + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + + // Reload room with guest name set in localStorage + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.reload(); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Open change name dialog and change remember participant name + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + cy.get('[data-test="change-participant-name-button"]').click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("be.checked"); + }); + + // Change remember participant name checkbox + cy.get("#remember-participant-name").uncheck(); + + // Save + cy.get('[data-test="dialog-save-button"]').click(); + }); + + // Check that dialog was closed + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + // Check that name was removed from localStorage + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + // Check that participant name stays the same + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + + // Open dialog again and check that input is prefilled with the current name + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.get("#remember-participant-name").and("not.be.checked"); + }); + }); + + it("change participant name with errors", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123"); + + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Open change name dialog + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "not.exist", + ); + + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.contains("rooms.remember_participant_name").should("be.visible"); + cy.get("#remember-participant-name").and("be.checked"); + }); + + // Change name to a name too short + cy.get("#participant-name").clear(); + cy.get("#participant-name").type("M"); + + cy.get('[data-test="participant-name-field"]').contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ); + + // Enter characters to reach the required min length + cy.get("#participant-name").type("a"); + + // Check that error message is gone + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.min.string_{"attribute":"rooms.first_and_lastname","min":2}', + ) + .should("not.exist"); + + // Enter invalid character + cy.get("#participant-name").type("<"); + + // Check that error message is shown again + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.validname_{"attribute":"rooms.first_and_lastname","chars":"<"}', + ) + .should("be.visible"); + + // Enter another invalid character + cy.get("#participant-name").type(">"); + + // Check that error message is updated + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.validname_{"attribute":"rooms.first_and_lastname","chars":"<>"}', + ) + .should("be.visible"); + + // Clear input + cy.get("#participant-name").clear(); + + // Check that error message is updated + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.validname_{"attribute":"rooms.first_and_lastname","chars":"<>"}', + ) + .should("not.exist"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.required_{"attribute":"rooms.first_and_lastname"}', + ) + .should("be.visible"); + + // Enter name that is valid and has the max length + cy.get("#participant-name").type("A".repeat(50)); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.required_{"attribute":"rooms.first_and_lastname"}', + ) + .should("not.exist"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.max.string_{"attribute":"rooms.first_and_lastname","max":50}', + ) + .should("not.exist"); + + // Enter one mor character to exceed allowed max length + cy.get("#participant-name").type("A"); + + // Check that error message is updated + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.required_{"attribute":"rooms.first_and_lastname"}', + ) + .should("not.exist"); + + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.max.string_{"attribute":"rooms.first_and_lastname","max":50}', + ) + .should("be.visible"); + + // Try to save invalid name + cy.get('[data-test="dialog-save-button"]').click(); + }); + + // Check that dialog stays open and error message is still shown + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .contains( + 'validation.max.string_{"attribute":"rooms.first_and_lastname","max":50}', + ) + .should("be.visible"); + + // Cancel + cy.get('[data-test="dialog-cancel-button"]').click(); + }); + + // Check that participant name is still the same + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + + // Check that name in localStorage is still the same + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.eq( + "Laura Rivera", + ); + }); + + // Open dialog again and check that the current participant name is shown again + cy.get('[data-test="change-participant-name-button"]') + .should("be.visible") + .click(); + + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + cy.get("#remember-participant-name").and("be.checked"); + }); + }); + + it("saved access parameter priority", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + room.data.is_member = true; + room.data.username = "Max Doe"; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 200, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "123456789"); + win.sessionStorage.setItem( + "roomPersonalizedLink_abc-def-123", + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Visit with all possible saved access parameters set + cy.visit( + "/rooms/abc-def-123#accessCode=987654321&personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + + // Check that room access overlay is hidden + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + + // Check that auth was called with personalized link from hash + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + type: 1, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + // Check that correct participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + cy.contains("Laura Rivera").should("not.exist"); + + //Check that sessionStorage value for personalized link was updated to the value from hash + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "123456789", + ); + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + + // Reset to previous value + win.sessionStorage.setItem( + "roomPersonalizedLink_abc-def-123", + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Reload without personalized link in hash + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 200, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.visit("/rooms/abc-def-123#accessCode=987654321"); + cy.reload(); + + // Check that auth was called with access code from hash + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "987654321", + type: 0, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "0", + }); + }); + + // Check that correct participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + cy.contains("Max Doe").should("not.exist"); + + // Check that sessionStorage value for access code was updated to the value from hash + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "987654321", + ); + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + // Reset access code to previous value + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "123456789"); + }); + + // Reload without access code in hash + cy.fixture("room.json").then((room) => { + room.data.allow_membership = true; + room.data.current_user = null; + room.data.is_member = true; + room.data.username = "Max Doe"; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 200, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.visit("/rooms/abc-def-123"); + cy.reload(); + + // Check that auth was called with personalized link from sessionStorage + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.wait("@roomRequest").then((interception) => { + expect(interception.request.query).to.contain({ + room_auth_token: "roomAuthToken", + room_auth_token_type: "1", + }); + }); + + // Check that correct participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + cy.contains("Laura Rivera").should("not.exist"); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewGeneral.cy.js b/tests/Frontend/e2e/RoomsViewGeneral.cy.js index 814268cc75..dd5ec1a1ef 100644 --- a/tests/Frontend/e2e/RoomsViewGeneral.cy.js +++ b/tests/Frontend/e2e/RoomsViewGeneral.cy.js @@ -6,15 +6,21 @@ describe("Room View general", function () { cy.interceptRoomViewRequests(); }); - it("room view as guest", function () { - cy.intercept("GET", "api/v1/currentUser", {}); + it("room view as member", function () { cy.interceptRoomFilesRequest(); - cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.last_meeting = { + start: "2023-08-21T08:18:28.000000Z", + end: "2023-08-21T08:20:28.000000Z", + }; room.data.allow_membership = true; - room.data.current_user = null; + room.data.is_member = true; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); @@ -24,63 +30,23 @@ describe("Room View general", function () { cy.title().should("eq", "Meeting One - PILOS Test"); - // Check that access overlay is shown - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - // Check that header is shown - cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that login button is shown - cy.get('[data-test="room-login-as-user-button"]') - .should("be.visible") - .and("have.text", "auth.offer_login") - .and("have.attr", "href", "/login?redirect=/rooms/abc-def-123"); - - // Check that participant name input is shown - cy.get('[data-test="participant-name-field"]') - .should("be.visible") - .within(() => { - cy.contains("rooms.first_and_lastname").should("be.visible"); - cy.get("#participant-name") - .should("be.visible") - .and("have.value", ""); - cy.contains("rooms.remember_participant_name").should("be.visible"); - cy.get("#remember-participant-name").and("not.be.checked"); - }); - - // Check that access code input is not shown - cy.get('[data-test="access-code-field"]').should("not.exist"); - - // Enter guest name - cy.get("#participant-name").type("Max Doe"); - - cy.get('[data-test="room-login-button"]') - .should("have.text", "rooms.continue_as_guest") - .click(); - }); - - // Check that room access overlay is hidden - cy.get('[data-test="room-access-overlay"]').should("not.exist"); - // Check that room Header is shown correctly cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); + cy.contains("Max Doe").should("be.visible"); + cy.contains( + 'rooms.index.room_component.last_ran_till_{"date":"08/21/2023, 10:20"}', + ).should("be.visible"); - // ToDo check that welcome message is shown + // Check that participant name input is hidden + cy.get('[data-test="participant-name-field"]').should("not.exist"); + cy.contains("rooms.name_in_video_conference").should("not.exist"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); // Check that buttons are shown correctly cy.get('[data-test="reload-room-button"]').should("be.visible"); cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); - cy.get('[data-test="room-favorites-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("be.visible"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); // Check that tabs are shown correctly cy.get("#tab-description").should("not.exist"); @@ -96,67 +62,19 @@ describe("Room View general", function () { // Check if share button is hidden cy.get('[data-test="room-share-button"]').should("not.exist"); - - // Test reloading the room - cy.fixture("room.json").then((room) => { - room.data.name = "Meeting Two"; - room.data.owner.id = 2; - room.data.owner.name = "Max Doe"; - room.data.last_meeting = { - start: "2023-08-21T08:18:28.000000Z", - end: null, - }; - room.data.description = "Test
"; - room.data.access_code = null; - room.data.current_user = null; - - const reloadRequest = interceptIndefinitely( - "GET", - "api/v1/rooms/abc-def-123", - { - statusCode: 200, - body: room, - }, - "roomRequest", - ); - - // Trigger reload - cy.get('[data-test="reload-room-button"]').click(); - cy.get('[data-test="reload-room-button"]') - .should("be.disabled") - .then(() => { - reloadRequest.sendResponse(); - }); - }); - - cy.title().should("eq", "Meeting Two - PILOS Test"); - - // Check that room Header is shown correctly - cy.contains("Meeting Two").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains( - 'rooms.index.room_component.running_since_{"date":"08/21/2023, 04:18"}', - ).should("be.visible"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); }); - it("room view with access code", function () { + it("room view as moderator", function () { + cy.interceptRoomFilesRequest(); + cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, name: "Max Doe", }; - room.data.authenticated = false; - room.data.description = "Test
"; room.data.allow_membership = true; + room.data.is_member = true; + room.data.is_moderator = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -166,94 +84,8 @@ describe("Room View general", function () { cy.visit("/rooms/abc-def-123"); - cy.wait("@roomRequest"); - cy.title().should("eq", "Meeting One - PILOS Test"); - // Check that access code overlay is shown correctly - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - // Check header is shown - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that login button is hidden - cy.get('[data-test="room-login-as-user-button"]').should("not.exist"); - - // Check that participant name input is hidden - cy.get('[data-test="participant-name-field"]').should("not.exist"); - - // Check that access code input is shown - cy.get('[data-test="access-code-field"]') - .should("be.visible") - .within(() => { - cy.contains("rooms.access_code").should("be.visible"); - cy.get("#access-code").should("be.visible").and("have.value", ""); - }); - - // Try to submit with correct access code - cy.get("#access-code").type("123456789"); - }); - - const roomAuthRequest = interceptIndefinitely( - "POST", - "api/v1/rooms/abc-def-123/auth", - { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 0, - }, - }, - }, - "roomAuthRequest", - ); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="room-login-button"]').click(); - - // Check loading - cy.get("[data-test='reload-room-button']").should("be.disabled"); - cy.get('[data-test="room-login-button"]') - .should("be.disabled") - .then(() => { - roomAuthRequest.sendResponse(); - }); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "123456789", - type: 0, - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", - }); - }); - - cy.get('[data-test="room-access-overlay"]').should("not.exist"); - // Check that room Header is shown correctly cy.contains("Meeting One").should("be.visible"); cy.contains("Max Doe").should("be.visible"); @@ -261,14 +93,19 @@ describe("Room View general", function () { "be.visible", ); + // Check that participant name input is hidden + cy.get('[data-test="participant-name-field"]').should("not.exist"); + cy.contains("rooms.name_in_video_conference").should("not.exist"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + // Check that buttons are shown correctly cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("be.visible"); - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("be.visible"); cy.get('[data-test="room-favorites-button"]').should("be.visible"); // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); + cy.get("#tab-description").should("not.exist"); cy.get("#tab-members").should("not.exist"); cy.get("#tab-tokens").should("not.exist"); cy.get("#tab-files").should("be.visible"); @@ -276,21 +113,21 @@ describe("Room View general", function () { cy.get("#tab-history").should("not.exist"); cy.get("#tab-settings").should("not.exist"); - // Check that the correct tab is shown - cy.contains("rooms.description.title").should("be.visible"); + // Check that correct tab is shown + cy.contains("rooms.files.title").should("be.visible"); - // Check if share button is hidden - cy.get('[data-test="room-share-button"]').should("not.exist"); + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').should("exist"); + }); + + it("share room", function () { + cy.interceptRoomFilesRequest(); - // Reload and try with valid access code again cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = false; - room.data.description = "Test
"; + room.data.short_description = "Room short description"; room.data.allow_membership = true; + room.data.legacy_code = false; + room.data.access_code = "508307005"; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -298,174 +135,213 @@ describe("Room View general", function () { }).as("roomRequest"); }); - cy.window().then((win) => { - win.sessionStorage.removeItem("roomAccessCode_abc-def-123"); - }); + cy.visit("/rooms/abc-def-123"); - cy.reload(); + cy.title().should("eq", "Meeting One - PILOS Test"); - cy.wait("@roomRequest"); + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').click(); + cy.get("#invitationLink").should( + "have.value", + Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=508307005", + ); + cy.get("#invitationCode").should("have.value", "508-307-005"); - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - // Try to submit with correct access code - cy.get("#access-code").type("123456789"); + // Copy invitation message + cy.get('[data-test="room-copy-invitation-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_message"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq( + 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + + Cypress.config("baseUrl") + + "/rooms/abc-def-123#accessCode=508307005\nrooms.invitation.code: 508-307-005", + ); }); + }); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 200, - body: { - data: { - id: "roomAuthToken", - type: 0, - }, - }, - }).as("roomAuthRequest"); + // Copy room link + cy.get('[data-test="room-share-button"]').click(); + cy.get('[data-test="room-invitation-copy-link-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_url"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq( + Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=508307005", + ); + }); + }); + + // Copy room access code + cy.get('[data-test="room-share-button"]').click(); + cy.get('[data-test="room-invitation-copy-code-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_code"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq("508-307-005"); + }); + }); + // Reload with legacy numeric access code cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; + room.data.short_description = "Room short description"; room.data.allow_membership = true; + room.data.legacy_code = true; + room.data.access_code = "012345"; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); }); + cy.get('[data-test="reload-room-button"]').click(); - cy.get('[data-test="room-login-button"]').click(); + cy.wait("@roomRequest"); + + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').click(); + cy.get("#invitationLink").should( + "have.value", + Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=012345", + ); + cy.get("#invitationCode").should("have.value", "012345"); - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "123456789", - type: 0, + // Copy invitation message + cy.get('[data-test="room-copy-invitation-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_message"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq( + 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + + Cypress.config("baseUrl") + + "/rooms/abc-def-123#accessCode=012345\nrooms.invitation.code: 012345", + ); }); }); - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", + // Copy room access code + cy.get('[data-test="room-share-button"]').click(); + cy.get('[data-test="room-invitation-copy-code-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_code"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq("012345"); }); }); - cy.get('[data-test="room-access-overlay"]').should("not.exist"); - - // Reload with invalid access code - const errorReloadRoomRequest = interceptIndefinitely( - "GET", - "api/v1/rooms/abc-def-123*", - { - statusCode: 401, - body: { - message: "invalid_auth_token", - }, - }, - "roomRequest", - ); + // Reload with legacy alphanumeric access code + cy.fixture("room.json").then((room) => { + room.data.short_description = "Room short description"; + room.data.allow_membership = true; + room.data.legacy_code = true; + room.data.access_code = "012abc"; + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); cy.get('[data-test="reload-room-button"]').click(); - // Intercept second request (reload room) and send response of the first request - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = false; - room.data.description = "Test
"; - room.data.allow_membership = true; + cy.wait("@roomRequest"); - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }) - .as("roomRequest") - .then(() => { - errorReloadRoomRequest.sendResponse(); - }); - }); + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').click(); + cy.get("#invitationLink").should( + "have.value", + Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=012abc", + ); + cy.get("#invitationCode").should("have.value", "012abc"); - // Check that access code header is set for the first request - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", - }); - }); - // Check that access code header is reset for the second request (reload room) - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.not.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", + // Copy invitation message + cy.get('[data-test="room-copy-invitation-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_message"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq( + 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + + Cypress.config("baseUrl") + + "/rooms/abc-def-123#accessCode=012abc\nrooms.invitation.code: 012abc", + ); }); }); - // Check if error message is shown - cy.checkToastMessage("rooms.flash.access_code_invalid"); - - cy.contains("rooms.flash.access_code_invalid").should("be.visible"); - - cy.get('[data-test="room-access-overlay"]').should("be.visible"); - - // Retry with valid access code but no access code needed anymore - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - // Try to submit with correct access code - cy.get("#access-code").type("123456789"); + // Copy room access code + cy.get('[data-test="room-share-button"]').click(); + cy.get('[data-test="room-invitation-copy-code-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_code"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq("012abc"); }); + }); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 204, - }).as("roomAuthRequest"); - + // Reload without access code cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; + room.data.short_description = "Room short description"; room.data.allow_membership = true; - room.data.is_member = true; + room.data.legacy_code = false; + room.data.access_code = null; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); }); + cy.get('[data-test="reload-room-button"]').click(); - cy.get('[data-test="room-login-button"]').click(); + cy.wait("@roomRequest"); + + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').click(); + cy.get("#invitationLink").should( + "have.value", + Cypress.config("baseUrl") + "/rooms/abc-def-123", + ); + cy.get("#invitationCode").should("not.exist"); - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "123456789", - type: 0, + // Copy invitation message + cy.get('[data-test="room-copy-invitation-button"]').click(); + cy.checkToastMessage("rooms.invitation.copied_message"); + cy.window().then((win) => { + win.navigator.clipboard.readText().then((text) => { + expect(text).to.eq( + 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + + Cypress.config("baseUrl") + + "/rooms/abc-def-123", + ); }); }); - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query.room_auth_token).to.be.undefined; - expect(interception.request.query.room_auth_token_type).to.be.undefined; - }); + // Copy room access code should be missing + cy.get('[data-test="room-share-button"]').click(); + cy.get('[data-test="room-invitation-copy-code-button"]').should( + "not.exist", + ); + + // Focus on close button + cy.press(Cypress.Keyboard.Keys.TAB); + cy.get('[data-test="popover-close-button"]').should("have.focus"); + cy.get('[data-test="popover-close-button"]').click(); + cy.get("#invitationLink").should("not.exist"); - cy.get('[data-test="room-access-overlay"]').should("not.exist"); + // Focus should be back on the share button + cy.get('[data-test="room-share-button"]').should("have.focus"); }); - it("room view with legacy access code", function () { + it("room view as co-owner", function () { cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, name: "Max Doe", }; - room.data.legacy_code = true; - room.data.authenticated = false; - room.data.description = "Test
"; + room.data.last_meeting = { + start: "2023-08-21T08:18:28.000000Z", + end: null, + }; room.data.allow_membership = true; + room.data.is_member = true; + room.data.is_co_owner = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -475,103 +351,108 @@ describe("Room View general", function () { cy.visit("/rooms/abc-def-123"); - cy.wait("@roomRequest"); - cy.title().should("eq", "Meeting One - PILOS Test"); - // Check that access code input is shown correctly - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains( + 'rooms.index.room_component.running_since_{"date":"08/21/2023, 10:18"}', + ).should("be.visible"); - // Submit valid access code - cy.get("#access-code").type("012abc"); - }); + // Check that participant name is hidden + cy.contains("rooms.name_in_video_conference").should("not.exist"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); - // Intercept room auth request - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 0, - }, - }, - }).as("roomAuthRequest"); + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("be.visible"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); + + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("be.visible"); + cy.get("#tab-tokens").should("be.visible"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("be.visible"); + cy.get("#tab-settings").should("be.visible"); + // Check that correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').should("exist"); + }); + + it("room view as owner", function () { cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; + room.data.short_description = "Room short description"; room.data.allow_membership = true; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); }); - cy.get('[data-test="room-login-button"]').click(); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "012abc", - type: 0, - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", - }); - }); + cy.visit("/rooms/abc-def-123"); - cy.get('[data-test="room-access-overlay"]').should("not.exist"); + cy.title().should("eq", "Meeting One - PILOS Test"); // Check that room Header is shown correctly cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); + cy.contains("John Doe").should("be.visible"); + cy.contains("Room short description").should("be.visible"); cy.contains("rooms.index.room_component.never_started").should( "be.visible", ); + // Check that participant name is hidden + cy.contains("rooms.name_in_video_conference").should("not.exist"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + // Check that buttons are shown correctly cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); cy.get('[data-test="room-end-membership-button"]').should("not.exist"); cy.get('[data-test="room-favorites-button"]').should("be.visible"); // Check that tabs are shown correctly cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); + cy.get("#tab-members").should("be.visible"); + cy.get("#tab-tokens").should("be.visible"); cy.get("#tab-files").should("be.visible"); cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); + cy.get("#tab-history").should("be.visible"); + cy.get("#tab-settings").should("be.visible"); - // Check that the correct tab is shown + // Check that correct tab is shown cy.contains("rooms.description.title").should("be.visible"); + + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').should("exist"); }); - it("room auth with access code errors", function () { + it("room view with rooms.viewAll permission", function () { + cy.fixture("currentUser.json").then((currentUser) => { + currentUser.data.permissions = ["rooms.viewAll"]; + cy.intercept("GET", "api/v1/currentUser", { + statusCode: 200, + body: currentUser, + }); + }); + cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, name: "Max Doe", }; - room.data.authenticated = false; - room.data.description = "Test
"; room.data.allow_membership = true; + room.data.current_user.permissions = ["rooms.viewAll"]; + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, @@ -580,65 +461,65 @@ describe("Room View general", function () { cy.visit("/rooms/abc-def-123"); - cy.wait("@roomRequest"); - cy.title().should("eq", "Meeting One - PILOS Test"); - // Check that access overlay is shown correctly - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - // Try to submit without access code - }); + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + cy.contains("Max Doe").should("be.visible"); + cy.contains("rooms.index.room_component.never_started").should( + "be.visible", + ); - // Check with 422 error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 422, - body: { - message: "The Access code field is required.", - errors: { - access_code: ["The Access code field is required."], - }, - }, - }).as("roomAuthRequest"); + // Check that buttons are shown correctly + cy.get('[data-test="reload-room-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("be.visible"); + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-favorites-button"]').should("be.visible"); - cy.get('[data-test="room-login-button"]').click(); + // Check that tabs are shown correctly + cy.get("#tab-description").should("be.visible"); + cy.get("#tab-members").should("be.visible"); + cy.get("#tab-tokens").should("be.visible"); + cy.get("#tab-files").should("be.visible"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-history").should("be.visible"); + cy.get("#tab-settings").should("be.visible"); - cy.wait("@roomAuthRequest"); + // Check that correct tab is shown + cy.contains("rooms.description.title").should("be.visible"); - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - cy.contains("The Access code field is required.").should("be.visible"); + // Check if share button is shown correctly + cy.get('[data-test="room-share-button"]').should("exist"); + }); - // Try to submit with invalid access code - cy.get("#access-code").type("987654321"); - }); + it("room view streaming enabled", function () { + // Enable streaming + cy.fixture("config.json").then((config) => { + config.data.general.hide_disabled_features = true; + config.data.streaming.enabled = true; - // Check with invalid_code error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 401, - body: { - message: "invalid_code", - }, - }).as("roomAuthRequest"); + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); - cy.get('[data-test="room-login-button"]').click(); + cy.fixture("currentUser.json").then((currentUser) => { + currentUser.data.permissions = ["rooms.viewAll"]; + cy.intercept("GET", "api/v1/currentUser", { + statusCode: 200, + body: currentUser, + }); + }); - // Intercept room request (reload room) cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, name: "Max Doe", }; - room.data.authenticated = false; - room.data.description = "Test
"; + room.data.type.features.streaming.enabled = true; room.data.allow_membership = true; + room.data.current_user.permissions = ["rooms.viewAll"]; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -646,177 +527,117 @@ describe("Room View general", function () { }).as("roomRequest"); }); - // Wait for room auth request and check if access code is set - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "987654321", - type: 0, - }); - }); - - // Wait for room request - cy.wait("@roomRequest"); - - // Check if error message is shown - cy.checkToastMessage("rooms.flash.access_code_invalid"); - - cy.contains("rooms.flash.access_code_invalid").should("be.visible"); + cy.visit("/rooms/abc-def-123"); - // Intercept room auth request and respond with rate limit error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 429, - body: { - limit: "room_auth", - retry_after: 5, - }, - }).as("roomAuthRequest"); + cy.title().should("eq", "Meeting One - PILOS Test"); - cy.clock(); + // Check that tabs are shown correctly + cy.get("#tab-streaming") + .should("be.visible") + .should("have.attr", "data-feature-disabled", "false"); + }); - cy.get('[data-test="room-login-button"]').click(); + it("room view streaming disabled", function () { + // Enable streaming + cy.fixture("config.json").then((config) => { + config.data.general.hide_disabled_features = true; + config.data.streaming.enabled = true; - // Wait for room auth request - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "987654321", - type: 0, + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, }); }); - // Check if input and buttons are disabled - cy.get("#access-code").should("be.disabled"); - cy.get('[data-test="room-login-button"]').should("be.disabled"); - cy.get('[data-test="reload-room-button"]').should("be.disabled"); - - // Check countdown - for (let i = 5; i > 0; i--) { - // Check if countdown message is updated - cy.contains('rooms.auth_throttled_{"try_again":' + i + "}").should( - "be.visible", - ); - - // Tick clock 1 sec forward - cy.tick(1000); - } - - // restore the clock - cy.clock().then((clock) => { - clock.restore(); + cy.fixture("currentUser.json").then((currentUser) => { + currentUser.data.permissions = ["rooms.viewAll"]; + cy.intercept("GET", "api/v1/currentUser", { + statusCode: 200, + body: currentUser, + }); }); - // Check toast message - cy.checkToastMessage("app.flash.too_many_requests"); - - // Check if input and buttons are enabled again - cy.get("#access-code").should("not.be.disabled"); - cy.get('[data-test="room-login-button"]').should("not.be.disabled"); - cy.get('[data-test="reload-room-button"]').should("not.be.disabled"); - - // Check with 500 error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 500, - body: { - message: "Test", - }, - }).as("roomAuthRequest"); - - cy.get('[data-test="room-login-button"]').click(); - - cy.wait("@roomAuthRequest"); - - // Check that error message is shown - cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test"}', - 'app.flash.server_error.error_code_{"statusCode":500}', - ]); - - // Check that access overlay is still shown and not disabled - cy.get('[data-test="room-access-overlay"]').should("be.visible"); - cy.get("#access-code").should("not.be.disabled"); - cy.get('[data-test="room-login-button"]').should("not.be.disabled"); - - // Check with guests not allowed - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 403, - body: { - message: "guests_not_allowed", - }, - }).as("roomAuthRequest"); + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.type.features.streaming.enabled = false; + room.data.allow_membership = true; + room.data.current_user.permissions = ["rooms.viewAll"]; - cy.get('[data-test="room-login-button"]').click(); + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); - cy.wait("@roomAuthRequest"); + cy.visit("/rooms/abc-def-123"); - // Check if error message is shown - // Check that the error message is shown - cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); + cy.title().should("eq", "Meeting One - PILOS Test"); - // Check that access overlay is hidden - cy.get('[data-test="room-access-overlay"]').should("not.exist"); + // Check that tabs are shown correctly + cy.get("#tab-streaming").should("not.exist"); - // Check with 404 error (room not found) as authenticated user - cy.interceptRoomIndexRequests(); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 404, - body: { - message: "model_not_found", - model: "room", - ids: ["abc-def-123"], - }, - }).as("roomAuthRequest"); + // Show disabled features + cy.fixture("config.json").then((config) => { + config.data.general.hide_disabled_features = false; + config.data.streaming.enabled = true; + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); cy.reload(); - cy.wait("@roomRequest"); - - cy.get('[data-test="room-login-button"]').click(); + // Check that tabs are shown correctly + cy.get("#tab-streaming") + .should("exist") + .should("have.attr", "data-feature-disabled", "true"); - cy.wait("@roomAuthRequest"); + cy.get('[data-test="room-feature-disabled-dialog"]').should("not.exist"); - // Check that redirect to room index page worked - cy.url() - .should("include", "/rooms") - .and("not.include", "/rooms/abc-def-123"); + cy.get("#tab-streaming").click(); - // Check that error message is shown - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); + cy.get('[data-test="room-feature-disabled-dialog"]') + .should("be.visible") + .and( + "include.text", + 'rooms.feature_disabled_roomtype_{"name":"rooms.streaming.title"}', + ); + cy.get('[data-test="dialog-close-button"]').click(); - // Check with 404 error (room not found) as guest - cy.intercept("GET", "api/v1/currentUser", {}); - cy.fixture("room.json").then((room) => { - room.data.current_user = null; - room.data.authenticated = false; + // Disable system wide + cy.fixture("config.json").then((config) => { + config.data.general.hide_disabled_features = false; + config.data.streaming.enabled = false; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/config", { statusCode: 200, - body: room, - }).as("roomRequest"); + body: config, + }); }); + cy.reload(); + // Check that tabs are shown correctly + cy.get("#tab-streaming") + .should("exist") + .should("have.attr", "data-feature-disabled", "true"); - cy.visit("/rooms/abc-def-123"); - - cy.wait("@roomRequest"); - - cy.get("#participant-name").type("Max Doe"); - - cy.get('[data-test="room-login-button"]').click(); - - cy.wait("@roomAuthRequest"); + cy.get('[data-test="room-feature-disabled-dialog"]').should("not.exist"); - // Check that redirect to 404 page worked - cy.url().should("include", "/404").and("not.include", "/rooms/abc-def-123"); + cy.get("#tab-streaming").click(); - // Check that error message is shown - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); + cy.get('[data-test="room-feature-disabled-dialog"]') + .should("be.visible") + .and( + "include.text", + 'rooms.feature_disabled_system_{"name":"rooms.streaming.title"}', + ); + cy.get('[data-test="dialog-close-button"]').click(); }); - it("room view with access code errors", function () { + it("membership button", function () { cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, @@ -826,7 +647,7 @@ describe("Room View general", function () { room.data.description = "Test
"; room.data.allow_membership = true; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { statusCode: 200, body: room, }).as("roomRequest"); @@ -836,12 +657,9 @@ describe("Room View general", function () { cy.wait("@roomRequest"); - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that access code input is shown correctly + cy.get('[data-test="room-access-overlay"]').should("be.visible"); cy.get("#access-code").type("123456789"); - // Check with invalid token error cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -852,48 +670,60 @@ describe("Room View general", function () { }, }).as("roomAuthRequest"); - const roomRequest = interceptIndefinitely( - "GET", - "api/v1/rooms/abc-def-123*", + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; + room.data.allow_membership = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@roomAuthRequest"); + + cy.wait("@roomRequest"); + + // Test join membership + const joinMembershipRequest = interceptIndefinitely( + "POST", + "api/v1/rooms/abc-def-123/membership*", { - statusCode: 401, - body: { - message: "invalid_auth_token", - }, + statusCode: 204, }, - "roomRequest", + "joinMembershipRequest", ); - cy.get('[data-test="room-login-button"]').click(); + cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; + room.data.allow_membership = true; + room.data.is_member = true; - // Wait for room auth request and check if access code is set - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "123456789", - type: 0, - }); + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); }); - cy.fixture("room.json") - .then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = false; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }) + cy.get('[data-test="room-end-membership-button"]').should("not.exist"); + cy.get('[data-test="room-join-membership-button"]').click(); + cy.get('[data-test="room-join-membership-button"]') + .should("be.disabled") .then(() => { - roomRequest.sendResponse(); + joinMembershipRequest.sendResponse(); }); - cy.wait("@roomRequest").then((interception) => { + cy.wait("@joinMembershipRequest").then((interception) => { expect(interception.request.query).to.contain({ room_auth_token: "roomAuthToken", room_auth_token_type: "0", @@ -905,1350 +735,8 @@ describe("Room View general", function () { expect(interception.request.query.room_auth_token_type).to.be.undefined; }); - // Check that error message is shown - cy.checkToastMessage("rooms.flash.access_code_invalid"); - - cy.contains("rooms.flash.access_code_invalid").should("be.visible"); - - cy.get('[data-test="room-access-overlay"]').should("be.visible"); - - // Check with 500 error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 0, - }, - }, - }).as("roomAuthRequest"); - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 500, - body: { - message: "Test", - }, - }).as("roomRequest"); - - cy.get('[data-test="room-login-button"]').click(); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - access_code: "123456789", - type: 0, - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", - }); - }); - - // Check that error message is shown - cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test"}', - 'app.flash.server_error.error_code_{"statusCode":500}', - ]); - - // Check that access code overlay is still shown and not disabled - cy.get('[data-test="room-access-overlay"]').should("be.visible"); - cy.get("#access-code").should("not.be.disabled"); - cy.get('[data-test="room-login-button"]').should("not.be.disabled"); - }); - - it("room view as member", function () { - cy.interceptRoomFilesRequest(); - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.last_meeting = { - start: "2023-08-21T08:18:28.000000Z", - end: "2023-08-21T08:20:28.000000Z", - }; - room.data.allow_membership = true; - room.data.is_member = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains( - 'rooms.index.room_component.last_ran_till_{"date":"08/21/2023, 10:20"}', - ).should("be.visible"); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("be.visible"); - cy.get('[data-test="room-favorites-button"]').should("be.visible"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("not.exist"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); - - // Check that correct tab is shown - cy.contains("rooms.files.title").should("be.visible"); - - // Check if share button is hidden - cy.get('[data-test="room-share-button"]').should("not.exist"); - }); - - it("room view as moderator", function () { - cy.interceptRoomFilesRequest(); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.allow_membership = true; - room.data.is_member = true; - room.data.is_moderator = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("be.visible"); - cy.get('[data-test="room-favorites-button"]').should("be.visible"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("not.exist"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); - - // Check that correct tab is shown - cy.contains("rooms.files.title").should("be.visible"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').should("exist"); - }); - - it("share room", function () { - cy.interceptRoomFilesRequest(); - - cy.fixture("room.json").then((room) => { - room.data.short_description = "Room short description"; - room.data.allow_membership = true; - room.data.legacy_code = false; - room.data.access_code = "508307005"; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').click(); - cy.get("#invitationLink").should( - "have.value", - Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=508307005", - ); - cy.get("#invitationCode").should("have.value", "508-307-005"); - - // Copy invitation message - cy.get('[data-test="room-copy-invitation-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_message"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq( - 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + - Cypress.config("baseUrl") + - "/rooms/abc-def-123#accessCode=508307005\nrooms.invitation.code: 508-307-005", - ); - }); - }); - - // Copy room link - cy.get('[data-test="room-share-button"]').click(); - cy.get('[data-test="room-invitation-copy-link-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_url"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq( - Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=508307005", - ); - }); - }); - - // Copy room access code - cy.get('[data-test="room-share-button"]').click(); - cy.get('[data-test="room-invitation-copy-code-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_code"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq("508-307-005"); - }); - }); - - // Reload with legacy numeric access code - cy.fixture("room.json").then((room) => { - room.data.short_description = "Room short description"; - room.data.allow_membership = true; - room.data.legacy_code = true; - room.data.access_code = "012345"; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - cy.get('[data-test="reload-room-button"]').click(); - - cy.wait("@roomRequest"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').click(); - cy.get("#invitationLink").should( - "have.value", - Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=012345", - ); - cy.get("#invitationCode").should("have.value", "012345"); - - // Copy invitation message - cy.get('[data-test="room-copy-invitation-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_message"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq( - 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + - Cypress.config("baseUrl") + - "/rooms/abc-def-123#accessCode=012345\nrooms.invitation.code: 012345", - ); - }); - }); - - // Copy room access code - cy.get('[data-test="room-share-button"]').click(); - cy.get('[data-test="room-invitation-copy-code-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_code"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq("012345"); - }); - }); - - // Reload with legacy alphanumeric access code - cy.fixture("room.json").then((room) => { - room.data.short_description = "Room short description"; - room.data.allow_membership = true; - room.data.legacy_code = true; - room.data.access_code = "012abc"; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - cy.get('[data-test="reload-room-button"]').click(); - - cy.wait("@roomRequest"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').click(); - cy.get("#invitationLink").should( - "have.value", - Cypress.config("baseUrl") + "/rooms/abc-def-123#accessCode=012abc", - ); - cy.get("#invitationCode").should("have.value", "012abc"); - - // Copy invitation message - cy.get('[data-test="room-copy-invitation-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_message"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq( - 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + - Cypress.config("baseUrl") + - "/rooms/abc-def-123#accessCode=012abc\nrooms.invitation.code: 012abc", - ); - }); - }); - - // Copy room access code - cy.get('[data-test="room-share-button"]').click(); - cy.get('[data-test="room-invitation-copy-code-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_code"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq("012abc"); - }); - }); - - // Reload without access code - cy.fixture("room.json").then((room) => { - room.data.short_description = "Room short description"; - room.data.allow_membership = true; - room.data.legacy_code = false; - room.data.access_code = null; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - cy.get('[data-test="reload-room-button"]').click(); - - cy.wait("@roomRequest"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').click(); - cy.get("#invitationLink").should( - "have.value", - Cypress.config("baseUrl") + "/rooms/abc-def-123", - ); - cy.get("#invitationCode").should("not.exist"); - - // Copy invitation message - cy.get('[data-test="room-copy-invitation-button"]').click(); - cy.checkToastMessage("rooms.invitation.copied_message"); - cy.window().then((win) => { - win.navigator.clipboard.readText().then((text) => { - expect(text).to.eq( - 'rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}\nrooms.invitation.link: ' + - Cypress.config("baseUrl") + - "/rooms/abc-def-123", - ); - }); - }); - - // Copy room access code should be missing - cy.get('[data-test="room-share-button"]').click(); - cy.get('[data-test="room-invitation-copy-code-button"]').should( - "not.exist", - ); - - // Focus on close button - cy.press(Cypress.Keyboard.Keys.TAB); - cy.get('[data-test="popover-close-button"]').should("have.focus"); - cy.get('[data-test="popover-close-button"]').click(); - cy.get("#invitationLink").should("not.exist"); - - // Focus should be back on the share button - cy.get('[data-test="room-share-button"]').should("have.focus"); - }); - - it("room view as co-owner", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.last_meeting = { - start: "2023-08-21T08:18:28.000000Z", - end: null, - }; - room.data.allow_membership = true; - room.data.is_member = true; - room.data.is_co_owner = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains( - 'rooms.index.room_component.running_since_{"date":"08/21/2023, 10:18"}', - ).should("be.visible"); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("be.visible"); - cy.get('[data-test="room-favorites-button"]').should("be.visible"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("be.visible"); - cy.get("#tab-tokens").should("be.visible"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("be.visible"); - cy.get("#tab-settings").should("be.visible"); - - // Check that correct tab is shown - cy.contains("rooms.description.title").should("be.visible"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').should("exist"); - }); - - it("room view as owner", function () { - cy.fixture("room.json").then((room) => { - room.data.short_description = "Room short description"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("Room short description").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); - cy.get('[data-test="room-favorites-button"]').should("be.visible"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("be.visible"); - cy.get("#tab-tokens").should("be.visible"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("be.visible"); - cy.get("#tab-settings").should("be.visible"); - - // Check that correct tab is shown - cy.contains("rooms.description.title").should("be.visible"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').should("exist"); - }); - - it("room view with personalized link (participant)", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.interceptRoomFilesRequest(); - - // Intercept room auth request - const roomAuthRequest = interceptIndefinitely( - "POST", - "api/v1/rooms/abc-def-123/auth", - { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 1, - }, - }, - }, - "roomAuthRequest", - ); - - cy.fixture("room.json").then((room) => { - room.data.username = "Max Doe"; - room.data.allow_membership = true; - room.data.is_member = true; - room.data.current_user = null; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.get("[data-test='room-loading-spinner']") - .should("be.visible") - .then(() => { - roomAuthRequest.sendResponse(); - }); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that header for token is set - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); - cy.get('[data-test="room-favorites-button"]').should("not.exist"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("not.exist"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); - - // Check that correct tab is shown - cy.contains("rooms.files.title").should("be.visible"); - - // Check if share button is hidden - cy.get('[data-test="room-share-button"]').should("not.exist"); - - // Reload with invalid token - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 401, - body: { - message: "invalid_personalized_link", - }, - }).as("roomAuthRequest"); - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 401, - body: { - message: "invalid_auth_token", - }, - }).as("roomRequest"); - - cy.get('[data-test="reload-room-button"]').click(); - - // Check that error message is shown - cy.checkToastMessage("rooms.flash.personalized_link_invalid"); - cy.contains("rooms.invalid_personalized_link").should("be.visible"); - }); - - it("room view with personalized link (moderator)", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.interceptRoomFilesRequest(); - - // Intercept room auth request - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 1, - }, - }, - }).as("roomAuthRequest"); - - cy.fixture("room.json").then((room) => { - room.data.username = "Max Doe"; - room.data.allow_membership = true; - room.data.is_member = true; - room.data.is_moderator = true; - room.data.current_user = null; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that header for token is set - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); - cy.get('[data-test="room-favorites-button"]').should("not.exist"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("not.exist"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); - - // Check that correct tab is shown - cy.contains("rooms.files.title").should("be.visible"); - - // Check if share button is hidden - cy.get('[data-test="room-share-button"]').should("not.exist"); - }); - - it("room auth with personalized link errors", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.interceptRoomFilesRequest(); - - // 401 invalid personalize link - // Intercept room auth request - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 401, - body: { - message: "invalid_personalized_link", - }, - }).as("roomAuthRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that error message is shown - cy.checkToastMessage("rooms.flash.personalized_link_invalid"); - cy.contains("rooms.invalid_personalized_link").should("be.visible"); - - // Reload and check with 422 error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 422, - body: { - message: "The Access token field is required.", - errors: { - personalized_link_token: ["The Access token field is required."], - }, - }, - }).as("roomAuthRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that error message is shown - cy.checkToastMessage("rooms.flash.personalized_link_invalid"); - cy.contains("rooms.invalid_personalized_link").should("be.visible"); - - // Check with guests only error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 420, - body: { - message: "guests_only", - }, - }).as("roomAuthRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - cy.checkToastMessage("app.flash.guests_only"); - cy.url() - .should("not.include", "/rooms") - .and("not.include", "rooms/abc-def-123"); - - // Check with 500 error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 500, - body: { - message: "Test", - }, - }).as("roomAuthRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that error message is shown - cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test"}', - 'app.flash.server_error.error_code_{"statusCode":500}', - ]); - - // Check that reload button is shown - cy.get('[data-test="reload-button"]').should("be.visible"); - - // Click reload button and make sure auth request is sent again - // Reload with valid auth request and room request - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 1, - }, - }, - }).as("roomAuthRequest"); - - cy.fixture("room.json").then((room) => { - room.data.username = "Max Doe"; - room.data.allow_membership = true; - room.data.is_member = true; - room.data.current_user = null; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="reload-button"]').click(); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - // Check that room is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check with 404 error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 404, - body: { - message: "model_not_found", - model: "room", - ids: ["abc-def-123"], - }, - }).as("roomAuthRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that redirect to 404 page worked and error message is shown - cy.url().should("include", "/404").and("not.include", "rooms/abc-def-123"); - - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); - }); - - it("room view with personalized link errors", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.interceptRoomFilesRequest(); - - // Check with 401 invalid token error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 1, - }, - }, - }).as("roomAuthRequest"); - - const roomRequest = interceptIndefinitely( - "GET", - "api/v1/rooms/abc-def-123*", - { - statusCode: 401, - body: { - message: "invalid_auth_token", - }, - }, - "roomRequest", - ); - - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 401, - body: { - message: "invalid_personalized_link", - }, - }).as("roomAuthRequest"); - - roomRequest.sendResponse(); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - // Check that error message is shown - cy.checkToastMessage("rooms.flash.personalized_link_invalid"); - cy.contains("rooms.invalid_personalized_link").should("be.visible"); - - // Check with guests only error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 1, - }, - }, - }).as("roomAuthRequest"); - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 420, - body: { - message: "guests_only", - }, - }).as("roomRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - cy.checkToastMessage("app.flash.guests_only"); - cy.url() - .should("not.include", "/rooms") - .and("not.include", "rooms/abc-def-123"); - - // Check with 500 error - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 500, - body: { - message: "Test", - }, - }).as("roomRequest"); - - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest").then((interception) => { - expect(interception.request.body).to.eql({ - personalized_link_token: - "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - type: 1, - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - // Check that error message is shown - cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test"}', - 'app.flash.server_error.error_code_{"statusCode":500}', - ]); - - // Check that reload button is shown - cy.get('[data-test="reload-button"]').should("be.visible"); - - // Intercept room auth request with different token - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "differentToken", - type: 1, - }, - }, - }).as("differentRoomAuthRequest"); - - // Click reload button and make sure room request is sent again with same auth token - // Reload with valid room request - cy.fixture("room.json").then((room) => { - room.data.username = "Max Doe"; - room.data.allow_membership = true; - room.data.is_member = true; - room.data.current_user = null; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="reload-button"]').click(); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - // Check that room is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("John Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that room auth request was not sent again - cy.get("@differentRoomAuthRequest").should("be.null"); - }); - - it("room view with rooms.viewAll permission", function () { - cy.fixture("currentUser.json").then((currentUser) => { - currentUser.data.permissions = ["rooms.viewAll"]; - cy.intercept("GET", "api/v1/currentUser", { - statusCode: 200, - body: currentUser, - }); - }); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.allow_membership = true; - - room.data.current_user.permissions = ["rooms.viewAll"]; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that room Header is shown correctly - cy.contains("Meeting One").should("be.visible"); - cy.contains("Max Doe").should("be.visible"); - cy.contains("rooms.index.room_component.never_started").should( - "be.visible", - ); - - // Check that buttons are shown correctly - cy.get('[data-test="reload-room-button"]').should("be.visible"); - cy.get('[data-test="room-join-membership-button"]').should("be.visible"); - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); - cy.get('[data-test="room-favorites-button"]').should("be.visible"); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("be.visible"); - cy.get("#tab-tokens").should("be.visible"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("be.visible"); - cy.get("#tab-settings").should("be.visible"); - - // Check that correct tab is shown - cy.contains("rooms.description.title").should("be.visible"); - - // Check if share button is shown correctly - cy.get('[data-test="room-share-button"]').should("exist"); - }); - - it("room view streaming enabled", function () { - // Enable streaming - cy.fixture("config.json").then((config) => { - config.data.general.hide_disabled_features = true; - config.data.streaming.enabled = true; - - cy.intercept("GET", "api/v1/config", { - statusCode: 200, - body: config, - }); - }); - - cy.fixture("currentUser.json").then((currentUser) => { - currentUser.data.permissions = ["rooms.viewAll"]; - cy.intercept("GET", "api/v1/currentUser", { - statusCode: 200, - body: currentUser, - }); - }); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.type.features.streaming.enabled = true; - room.data.allow_membership = true; - room.data.current_user.permissions = ["rooms.viewAll"]; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that tabs are shown correctly - cy.get("#tab-streaming") - .should("be.visible") - .should("have.attr", "data-feature-disabled", "false"); - }); - - it("room view streaming disabled", function () { - // Enable streaming - cy.fixture("config.json").then((config) => { - config.data.general.hide_disabled_features = true; - config.data.streaming.enabled = true; - - cy.intercept("GET", "api/v1/config", { - statusCode: 200, - body: config, - }); - }); - - cy.fixture("currentUser.json").then((currentUser) => { - currentUser.data.permissions = ["rooms.viewAll"]; - cy.intercept("GET", "api/v1/currentUser", { - statusCode: 200, - body: currentUser, - }); - }); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.type.features.streaming.enabled = false; - room.data.allow_membership = true; - room.data.current_user.permissions = ["rooms.viewAll"]; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.title().should("eq", "Meeting One - PILOS Test"); - - // Check that tabs are shown correctly - cy.get("#tab-streaming").should("not.exist"); - - // Show disabled features - cy.fixture("config.json").then((config) => { - config.data.general.hide_disabled_features = false; - config.data.streaming.enabled = true; - - cy.intercept("GET", "api/v1/config", { - statusCode: 200, - body: config, - }); - }); - cy.reload(); - - // Check that tabs are shown correctly - cy.get("#tab-streaming") - .should("exist") - .should("have.attr", "data-feature-disabled", "true"); - - cy.get('[data-test="room-feature-disabled-dialog"]').should("not.exist"); - - cy.get("#tab-streaming").click(); - - cy.get('[data-test="room-feature-disabled-dialog"]') - .should("be.visible") - .and( - "include.text", - 'rooms.feature_disabled_roomtype_{"name":"rooms.streaming.title"}', - ); - cy.get('[data-test="dialog-close-button"]').click(); - - // Disable system wide - cy.fixture("config.json").then((config) => { - config.data.general.hide_disabled_features = false; - config.data.streaming.enabled = false; - - cy.intercept("GET", "api/v1/config", { - statusCode: 200, - body: config, - }); - }); - cy.reload(); - // Check that tabs are shown correctly - cy.get("#tab-streaming") - .should("exist") - .should("have.attr", "data-feature-disabled", "true"); - - cy.get('[data-test="room-feature-disabled-dialog"]').should("not.exist"); - - cy.get("#tab-streaming").click(); - - cy.get('[data-test="room-feature-disabled-dialog"]') - .should("be.visible") - .and( - "include.text", - 'rooms.feature_disabled_system_{"name":"rooms.streaming.title"}', - ); - cy.get('[data-test="dialog-close-button"]').click(); - }); - - // ToDo debug this and check why access code does not stay if visited with access code - it("membership button", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = false; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.wait("@roomRequest"); - - cy.get('[data-test="room-access-overlay"]').should("be.visible"); - cy.get("#access-code").type("123456789"); - - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 0, - }, - }, - }).as("roomAuthRequest"); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="room-login-button"]').click(); - - cy.wait("@roomAuthRequest"); - - cy.wait("@roomRequest"); - - // Test join membership - const joinMembershipRequest = interceptIndefinitely( - "POST", - "api/v1/rooms/abc-def-123/membership*", - { - statusCode: 204, - }, - "joinMembershipRequest", - ); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - room.data.is_member = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="room-end-membership-button"]').should("not.exist"); - cy.get('[data-test="room-join-membership-button"]').click(); - cy.get('[data-test="room-join-membership-button"]') - .should("be.disabled") - .then(() => { - joinMembershipRequest.sendResponse(); - }); - - cy.wait("@joinMembershipRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", - }); - }); - - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query.room_auth_token).to.be.undefined; - expect(interception.request.query.room_auth_token_type).to.be.undefined; - }); - - cy.get('[data-test="room-join-membership-button"]').should("not.exist"); - cy.get('[data-test="room-end-membership-button"]').should("be.visible"); + cy.get('[data-test="room-join-membership-button"]').should("not.exist"); + cy.get('[data-test="room-end-membership-button"]').should("be.visible"); // Test end membership const endMembershipRequest = interceptIndefinitely( @@ -2729,268 +1217,24 @@ describe("Room View general", function () { cy.wait("@roomRequest"); - // Test add room to favorites - const addToFavoritesRequest = interceptIndefinitely( - "POST", - "api/v1/rooms/abc-def-123/favorites", - { - statusCode: 204, - }, - "addFavoritesRequest", - ); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - room.data.is_favorite = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="room-favorites-button"]') - .should( - "have.attr", - "aria-label", - 'rooms.favorites.add_for_{"room":"Meeting One"}', - ) - .click(); - cy.get('[data-test="room-favorites-button"]') - .should("be.disabled") - .then(() => { - addToFavoritesRequest.sendResponse(); - }); - - cy.wait("@addFavoritesRequest"); - cy.wait("@roomRequest"); - - // Check that button is changed to remove from favorites - cy.get('[data-test="room-favorites-button"]').should( - "have.attr", - "aria-label", - 'rooms.favorites.remove_for_{"room":"Meeting One"}', - ); - - // Test remove room from favorites - const deleteFromFavorites = interceptIndefinitely( - "DELETE", - "api/v1/rooms/abc-def-123/favorites", - { - statusCode: 204, - }, - "deleteFavoritesRequest", - ); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="room-favorites-button"]').click(); - cy.get('[data-test="room-favorites-button"]') - .should("be.disabled") - .then(() => { - deleteFromFavorites.sendResponse(); - }); - - cy.wait("@deleteFavoritesRequest"); - cy.wait("@roomRequest"); - - // Check that button is changed to add to favorites - cy.get('[data-test="room-favorites-button"]').should( - "have.attr", - "aria-label", - 'rooms.favorites.add_for_{"room":"Meeting One"}', - ); - }); - - it("trigger favorites button errors", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.wait("@roomRequest"); - - // Test add room to favorites with general error - cy.intercept("POST", "api/v1/rooms/abc-def-123/favorites", { - statusCode: 500, - body: { - message: "Test add favorite error", - }, - }).as("addFavoritesRequest"); - - cy.get('[data-test="room-favorites-button"]').click(); - - cy.wait("@addFavoritesRequest"); - cy.wait("@roomRequest"); - - // Check that error message is shown and button stayed the same - cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test add favorite error"}', - 'app.flash.server_error.error_code_{"statusCode":500}', - ]); - - // Test add to favorites with unauthenticated error - cy.intercept("POST", "api/v1/rooms/abc-def-123/favorites", { - statusCode: 401, - }).as("addFavoritesRequest"); - - cy.fixture("room.json").then((room) => { - room.data.current_user = null; - room.data.description = "Test
"; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="room-favorites-button"]') - .should( - "have.attr", - "aria-label", - 'rooms.favorites.add_for_{"room":"Meeting One"}', - ) - .click(); - - cy.wait("@addFavoritesRequest"); - cy.wait("@roomRequest"); - - cy.url().should("include", "/rooms/abc-def-123"); - cy.url().should("not.include", "/login"); - - cy.checkToastMessage("app.flash.unauthenticated"); - - cy.contains("auth.login").should("be.visible"); - - // Visit room page again - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.wait("@roomRequest"); - - // Test add to favorites with 404 error (room not found) - cy.interceptRoomIndexRequests(); - - cy.intercept("POST", "api/v1/rooms/abc-def-123/favorites", { - statusCode: 404, - body: { - message: "model_not_found", - model: "room", - ids: ["abc-def-123"], - }, - }).as("addFavoritesRequest"); - - cy.get('[data-test="room-favorites-button"]').click(); - - cy.wait("@addFavoritesRequest"); - - // Check that redirect worked and error message is shown - cy.url() - .should("include", "/rooms") - .and("not.include", "rooms/abc-def-123"); - - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); - - // Reload room but room is already in favorites - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; - room.data.is_favorite = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.visit("/rooms/abc-def-123"); - - cy.wait("@roomRequest"); - - // Test remove room from favorites with general error - cy.intercept("DELETE", "api/v1/rooms/abc-def-123/favorites", { - statusCode: 500, - body: { - message: "Test remove favorite error", - }, - }).as("deleteFavoritesRequest"); - - cy.get('[data-test="room-favorites-button"]') - .should( - "have.attr", - "aria-label", - 'rooms.favorites.remove_for_{"room":"Meeting One"}', - ) - .click(); - - cy.wait("@deleteFavoritesRequest"); - cy.wait("@roomRequest"); - - // Check that error message is shown and button stayed the same - cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test remove favorite error"}', - 'app.flash.server_error.error_code_{"statusCode":500}', - ]); - - // Test remove from favorites with unauthenticated error - cy.intercept("DELETE", "api/v1/rooms/abc-def-123/favorites", { - statusCode: 401, - }).as("deleteFavoritesRequest"); - - // Check with 401 errors but room has an access code + // Test add room to favorites + const addToFavoritesRequest = interceptIndefinitely( + "POST", + "api/v1/rooms/abc-def-123/favorites", + { + statusCode: 204, + }, + "addFavoritesRequest", + ); + cy.fixture("room.json").then((room) => { - room.data.current_user = null; - room.data.authenticated = false; - room.data.allow_membership = true; + room.data.owner = { + id: 2, + name: "Max Doe", + }; room.data.description = "Test
"; + room.data.allow_membership = true; + room.data.is_favorite = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -3002,23 +1246,35 @@ describe("Room View general", function () { .should( "have.attr", "aria-label", - 'rooms.favorites.remove_for_{"room":"Meeting One"}', + 'rooms.favorites.add_for_{"room":"Meeting One"}', ) .click(); + cy.get('[data-test="room-favorites-button"]') + .should("be.disabled") + .then(() => { + addToFavoritesRequest.sendResponse(); + }); - cy.wait("@deleteFavoritesRequest"); + cy.wait("@addFavoritesRequest"); cy.wait("@roomRequest"); - cy.url().should("include", "/rooms/abc-def-123"); - cy.url().should("not.include", "/login"); - - cy.checkToastMessage("app.flash.unauthenticated"); - cy.contains("auth.login").should("be.visible"); + // Check that button is changed to remove from favorites + cy.get('[data-test="room-favorites-button"]').should( + "have.attr", + "aria-label", + 'rooms.favorites.remove_for_{"room":"Meeting One"}', + ); - // Check that access code overlay is shown - cy.get('[data-test="room-access-overlay"]').should("be.visible"); + // Test remove room from favorites + const deleteFromFavorites = interceptIndefinitely( + "DELETE", + "api/v1/rooms/abc-def-123/favorites", + { + statusCode: 204, + }, + "deleteFavoritesRequest", + ); - // Reload room but room is already not in favorites cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, @@ -3026,7 +1282,6 @@ describe("Room View general", function () { }; room.data.description = "Test
"; room.data.allow_membership = true; - room.data.is_favorite = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -3034,73 +1289,31 @@ describe("Room View general", function () { }).as("roomRequest"); }); - cy.reload(); - - cy.wait("@roomRequest"); - - // Test remove from favorites with 404 error (room not found) - cy.interceptRoomIndexRequests(); - - cy.intercept("DELETE", "api/v1/rooms/abc-def-123/favorites", { - statusCode: 404, - body: { - message: "model_not_found", - model: "room", - ids: ["abc-def-123"], - }, - }).as("deleteFavoritesRequest"); - + cy.get('[data-test="room-favorites-button"]').click(); cy.get('[data-test="room-favorites-button"]') - .should( - "have.attr", - "aria-label", - 'rooms.favorites.remove_for_{"room":"Meeting One"}', - ) - .click(); + .should("be.disabled") + .then(() => { + deleteFromFavorites.sendResponse(); + }); cy.wait("@deleteFavoritesRequest"); - - // Check that redirect worked and error message is shown - cy.url() - .should("include", "/rooms") - .and("not.include", "rooms/abc-def-123"); - - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); - }); - - it("visit with guest forbidden", function () { - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 403, - body: { - message: "guests_not_allowed", - }, - }).as("roomRequest"); - - cy.visit("/rooms/abc-def-123"); - cy.wait("@roomRequest"); - // Check that the error message is shown - cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); - // Get login button and check if redirect is correctly set - cy.get('a[data-test="login-room-button"]').should( + // Check that button is changed to add to favorites + cy.get('[data-test="room-favorites-button"]').should( "have.attr", - "href", - "/login?redirect=/rooms/abc-def-123", + "aria-label", + 'rooms.favorites.add_for_{"room":"Meeting One"}', ); }); - it("visit with personalized link as authenticated user", function () { + it("trigger favorites button errors", function () { cy.fixture("room.json").then((room) => { room.data.owner = { id: 2, name: "Max Doe", }; - room.data.is_member = true; - room.data.is_moderator = true; + room.data.description = "Test
"; room.data.allow_membership = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { @@ -3109,156 +1322,116 @@ describe("Room View general", function () { }).as("roomRequest"); }); - // Visit room with personalized link - cy.visit( - "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); + cy.visit("/rooms/abc-def-123"); - // Check that error message is shown and user is redirected to the home page - cy.checkToastMessage("app.flash.guests_only"); - cy.url().should( - "not.include", - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - }); + cy.wait("@roomRequest"); - it("visit with general error", function () { - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + // Test add room to favorites with general error + cy.intercept("POST", "api/v1/rooms/abc-def-123/favorites", { statusCode: 500, body: { - message: "Test", + message: "Test add favorite error", }, - }); + }).as("addFavoritesRequest"); - cy.visit("/rooms/abc-def-123"); + cy.get('[data-test="room-favorites-button"]').click(); + + cy.wait("@addFavoritesRequest"); + cy.wait("@roomRequest"); + + // Check that error message is shown and button stayed the same cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.message_{"message":"Test add favorite error"}', 'app.flash.server_error.error_code_{"statusCode":500}', ]); - // Check that overlay is shown - cy.get('[data-test="no-room-overlay"]').should("be.visible"); - - // Get reload button and reload without error - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - fixture: "room.json", - }).as("roomRequest"); - cy.get('[data-test="reload-button"]') - .eq(0) - .should("have.text", "app.reload") - .click(); - - cy.wait("@roomRequest"); - cy.contains("Meeting One").should("be.visible"); - - // Check that overlay is hidden - cy.get('[data-test="no-room-overlay"]').should("not.exist"); - }); + // Test add to favorites with unauthenticated error + cy.intercept("POST", "api/v1/rooms/abc-def-123/favorites", { + statusCode: 401, + }).as("addFavoritesRequest"); - it("visit with room not found", function () { - // Try with logged in user - cy.interceptRoomIndexRequests(); + cy.fixture("room.json").then((room) => { + room.data.current_user = null; + room.data.description = "Test
"; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 404, - body: { - message: "model_not_found", - model: "room", - ids: ["abc-def-123"], - }, + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); }); - cy.visit("/rooms/abc-def-123"); - - // Check redirect to room index page - cy.url() - .should("include", "/rooms") - .should("not.include", "/rooms/abc-def-123"); - - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); + cy.get('[data-test="room-favorites-button"]') + .should( + "have.attr", + "aria-label", + 'rooms.favorites.add_for_{"room":"Meeting One"}', + ) + .click(); - // Try with guest - cy.intercept("GET", "api/v1/currentUser", {}); + cy.wait("@addFavoritesRequest"); + cy.wait("@roomRequest"); - cy.visit("/rooms/abc-def-123"); + cy.url().should("include", "/rooms/abc-def-123"); + cy.url().should("not.include", "/login"); - // Check redirect to 404 page - cy.url() - .should("include", "/404") - .should("not.include", "/rooms/abc-def-123"); + cy.checkToastMessage("app.flash.unauthenticated"); - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); - }); + cy.contains("auth.login").should("be.visible"); - it("auto-reload", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.fixture("config.json").then((config) => { - config.data.room.refresh_rate = 60; - cy.intercept("GET", "api/v1/config", { - statusCode: 200, - body: config, - }); - }); - cy.interceptRoomFilesRequest(); + // Visit room page again cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; room.data.allow_membership = true; - room.data.current_user = null; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); - }); - cy.clock(); - cy.visit("/rooms/abc-def-123"); - cy.wait("@roomRequest"); - cy.contains("Meeting One").should("be.visible"); - - // Wait more than 60 seconds (due to reload randomness) for a auto-reload - cy.tick(100000); - cy.get("@roomRequest.all").should("have.length", 2); - }); - - it("auto-reload disabled on error", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.fixture("config.json").then((config) => { - config.data.room.refresh_rate = 60; - cy.intercept("GET", "api/v1/config", { - statusCode: 200, - body: config, - }); - }); - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 403, - body: { - message: "guests_not_allowed", - }, - }).as("roomRequest"); + }); - cy.clock(); cy.visit("/rooms/abc-def-123"); + cy.wait("@roomRequest"); - // Check that the error message is shown - cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); + // Test add to favorites with 404 error (room not found) + cy.interceptRoomIndexRequests(); - // Wait more than 60 seconds (due to reload randomness) for no auto-reload - cy.tick(100000); - cy.get("@roomRequest.all").should("have.length", 1); - }); + cy.intercept("POST", "api/v1/rooms/abc-def-123/favorites", { + statusCode: 404, + body: { + message: "model_not_found", + model: "room", + ids: ["abc-def-123"], + }, + }).as("addFavoritesRequest"); - it("reload with errors", function () { - cy.intercept("GET", "api/v1/currentUser", {}); - cy.interceptRoomFilesRequest(); + cy.get('[data-test="room-favorites-button"]').click(); + + cy.wait("@addFavoritesRequest"); + + // Check that redirect worked and error message is shown + cy.url() + .should("include", "/rooms") + .and("not.include", "rooms/abc-def-123"); + + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); + + // Reload room but room is already in favorites cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; room.data.allow_membership = true; - room.data.current_user = null; + room.data.is_favorite = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -3267,83 +1440,81 @@ describe("Room View general", function () { }); cy.visit("/rooms/abc-def-123"); + cy.wait("@roomRequest"); - cy.contains("Meeting One").should("be.visible"); - // Test reload with general error - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + // Test remove room from favorites with general error + cy.intercept("DELETE", "api/v1/rooms/abc-def-123/favorites", { statusCode: 500, body: { - message: "Test", + message: "Test remove favorite error", }, - }).as("roomRequest"); + }).as("deleteFavoritesRequest"); - cy.get('[data-test="reload-room-button"]').click(); + cy.get('[data-test="room-favorites-button"]') + .should( + "have.attr", + "aria-label", + 'rooms.favorites.remove_for_{"room":"Meeting One"}', + ) + .click(); + + cy.wait("@deleteFavoritesRequest"); cy.wait("@roomRequest"); + // Check that error message is shown and button stayed the same cy.checkToastMessage([ - 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.message_{"message":"Test remove favorite error"}', 'app.flash.server_error.error_code_{"statusCode":500}', ]); - // Test reload with guests forbidden - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 403, - body: { - message: "guests_not_allowed", - }, - }).as("roomRequest"); - - cy.get('[data-test="reload-room-button"]').click(); - - cy.wait("@roomRequest"); - // Check that the error message is shown - cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); + // Test remove from favorites with unauthenticated error + cy.intercept("DELETE", "api/v1/rooms/abc-def-123/favorites", { + statusCode: 401, + }).as("deleteFavoritesRequest"); - // Reload page successfully + // Check with 401 errors but room has an access code cy.fixture("room.json").then((room) => { - room.data.allow_membership = true; room.data.current_user = null; + room.data.authenticated = false; + room.data.allow_membership = true; + room.data.description = "Test
"; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); - - cy.reload(); }); - cy.wait("@roomRequest"); - - // Test reload with room not found and guest user - cy.interceptRoomIndexRequests(); - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 404, - body: { - message: "model_not_found", - model: "room", - ids: ["abc-def-123"], - }, - }).as("roomRequest"); + cy.get('[data-test="room-favorites-button"]') + .should( + "have.attr", + "aria-label", + 'rooms.favorites.remove_for_{"room":"Meeting One"}', + ) + .click(); - cy.get('[data-test="reload-room-button"]').click(); + cy.wait("@deleteFavoritesRequest"); cy.wait("@roomRequest"); - // Check redirect to 404 page worked - cy.url() - .should("include", "/404") - .should("not.include", "/rooms/abc-def-123"); + cy.url().should("include", "/rooms/abc-def-123"); + cy.url().should("not.include", "/login"); - cy.checkToastMessage([ - 'app.flash.model_not_found.title_{"model":"app.model.room"}', - 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', - ]); + cy.checkToastMessage("app.flash.unauthenticated"); + cy.contains("auth.login").should("be.visible"); - // Test reload with room not found and authenticated user - cy.intercept("GET", "api/v1/currentUser", { fixture: "currentUser.json" }); + // Check that access code overlay is shown + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + // Reload room but room is already not in favorites cy.fixture("room.json").then((room) => { + room.data.owner = { + id: 2, + name: "Max Doe", + }; + room.data.description = "Test
"; room.data.allow_membership = true; + room.data.is_favorite = true; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, @@ -3351,26 +1522,36 @@ describe("Room View general", function () { }).as("roomRequest"); }); - cy.visit("/rooms/abc-def-123"); + cy.reload(); + cy.wait("@roomRequest"); - cy.contains("Meeting One").should("be.visible"); - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + // Test remove from favorites with 404 error (room not found) + cy.interceptRoomIndexRequests(); + + cy.intercept("DELETE", "api/v1/rooms/abc-def-123/favorites", { statusCode: 404, body: { message: "model_not_found", model: "room", ids: ["abc-def-123"], }, - }).as("roomRequest"); + }).as("deleteFavoritesRequest"); - cy.get('[data-test="reload-room-button"]').click(); - cy.wait("@roomRequest"); + cy.get('[data-test="room-favorites-button"]') + .should( + "have.attr", + "aria-label", + 'rooms.favorites.remove_for_{"room":"Meeting One"}', + ) + .click(); - // Check redirect to room index page worked + cy.wait("@deleteFavoritesRequest"); + + // Check that redirect worked and error message is shown cy.url() .should("include", "/rooms") - .should("not.include", "/rooms/abc-def-123"); + .and("not.include", "rooms/abc-def-123"); cy.checkToastMessage([ 'app.flash.model_not_found.title_{"model":"app.model.room"}', @@ -3378,230 +1559,248 @@ describe("Room View general", function () { ]); }); - it("reload with access code errors", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = false; - room.data.description = "Test
"; - room.data.allow_membership = true; + it("visit with guest forbidden", function () { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 403, + body: { + message: "guests_not_allowed", + }, + }).as("roomRequest"); - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + // Check that the error message is shown + cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); + + // Get login button and check if redirect is correctly set + cy.get('a[data-test="login-room-button"]').should( + "have.attr", + "href", + "/login?redirect=/rooms/abc-def-123", + ); + }); + + it("visit with general error", function () { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 500, + body: { + message: "Test", + }, }); cy.visit("/rooms/abc-def-123"); + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + // Check that overlay is shown + cy.get('[data-test="no-room-overlay"]').should("be.visible"); + + // Get reload button and reload without error + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + fixture: "room.json", + }).as("roomRequest"); + cy.get('[data-test="reload-button"]') + .eq(0) + .should("have.text", "app.reload") + .click(); cy.wait("@roomRequest"); + cy.contains("Meeting One").should("be.visible"); - cy.title().should("eq", "Meeting One - PILOS Test"); + // Check that overlay is hidden + cy.get('[data-test="no-room-overlay"]').should("not.exist"); + }); - // Check that access code input is shown correctly - cy.get("#access-code").type("123456789"); + it("visit with room not found", function () { + // Try with logged in user + cy.interceptRoomIndexRequests(); - // Check with invalid token error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 404, body: { - data: { - id: "roomAuthToken", - type: 0, - }, + message: "model_not_found", + model: "room", + ids: ["abc-def-123"], }, - }).as("roomAuthRequest"); - - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = true; - room.data.description = "Test
"; - room.data.allow_membership = true; - - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); }); - cy.get('[data-test="room-login-button"]').click(); + cy.visit("/rooms/abc-def-123"); + + // Check redirect to room index page + cy.url() + .should("include", "/rooms") + .should("not.include", "/rooms/abc-def-123"); - cy.wait("@roomAuthRequest"); + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); - cy.wait("@roomRequest"); + // Try with guest + cy.intercept("GET", "api/v1/currentUser", {}); - // Test reload with invalid token error + cy.visit("/rooms/abc-def-123"); - const roomRequest = interceptIndefinitely( - "GET", - "api/v1/rooms/abc-def-123*", - { - statusCode: 401, - body: { - message: "invalid_auth_token", - }, - }, - "roomRequest", - ); + // Check redirect to 404 page + cy.url() + .should("include", "/404") + .should("not.include", "/rooms/abc-def-123"); - cy.get('[data-test="reload-room-button"]').click(); + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); + }); + it("auto-reload", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.fixture("config.json").then((config) => { + config.data.room.refresh_rate = 60; + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + cy.interceptRoomFilesRequest(); cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.authenticated = false; - room.data.description = "Test
"; room.data.allow_membership = true; + room.data.current_user = null; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, - }) - .as("roomRequest") - .then(() => { - roomRequest.sendResponse(); - }); + }).as("roomRequest"); }); + cy.clock(); + cy.visit("/rooms/abc-def-123"); + cy.wait("@roomRequest"); + cy.contains("Meeting One").should("be.visible"); - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "0", - }); - }); + // Wait more than 60 seconds (due to reload randomness) for a auto-reload + cy.tick(100000); + cy.get("@roomRequest.all").should("have.length", 2); + }); - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query.room_auth_token).to.be.undefined; - expect(interception.request.query.room_auth_token_type).to.be.undefined; + it("auto-reload disabled on error", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.fixture("config.json").then((config) => { + config.data.room.refresh_rate = 60; + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); }); + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 403, + body: { + message: "guests_not_allowed", + }, + }).as("roomRequest"); - // Check that error message is shown - cy.checkToastMessage("rooms.flash.access_code_invalid"); + cy.clock(); + cy.visit("/rooms/abc-def-123"); + cy.wait("@roomRequest"); - cy.contains("rooms.flash.access_code_invalid").should("be.visible"); + // Check that the error message is shown + cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); - cy.get('[data-test="room-access-overlay"]').should("be.visible"); + // Wait more than 60 seconds (due to reload randomness) for no auto-reload + cy.tick(100000); + cy.get("@roomRequest.all").should("have.length", 1); }); - it("reload with personalized link errors", function () { + it("reload with errors", function () { cy.intercept("GET", "api/v1/currentUser", {}); cy.interceptRoomFilesRequest(); - - // Check with 401 invalid token error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, - body: { - data: { - id: "roomAuthToken", - type: 1, - }, - }, - }).as("roomAuthRequest"); - cy.fixture("room.json").then((room) => { - room.data.username = "Max Doe"; room.data.allow_membership = true; - room.data.is_member = true; room.data.current_user = null; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); }); - cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest"); + cy.visit("/rooms/abc-def-123"); cy.wait("@roomRequest"); + cy.contains("Meeting One").should("be.visible"); - // Check with invalid token error - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 401, + // Test reload with general error + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 500, body: { - message: "invalid_auth_token", + message: "Test", }, }).as("roomRequest"); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 401, - body: { - message: "invalid_personalized_link", - }, - }).as("roomAuthRequest"); - cy.get('[data-test="reload-room-button"]').click(); + cy.wait("@roomRequest"); - cy.wait("@roomRequest").then((interception) => { - expect(interception.request.query).to.contain({ - room_auth_token: "roomAuthToken", - room_auth_token_type: "1", - }); - }); - - cy.wait("@roomAuthRequest"); - - // Check that error message is shown - cy.checkToastMessage("rooms.flash.personalized_link_invalid"); - cy.contains("rooms.invalid_personalized_link").should("be.visible"); + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); - // Check with guests only error - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 201, + // Test reload with guests forbidden + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 403, body: { - data: { - id: "roomAuthToken", - type: 1, - }, + message: "guests_not_allowed", }, - }).as("roomAuthRequest"); + }).as("roomRequest"); + cy.get('[data-test="reload-room-button"]').click(); + + cy.wait("@roomRequest"); + // Check that the error message is shown + cy.contains("rooms.only_used_by_authenticated_users").should("be.visible"); + + // Reload page successfully cy.fixture("room.json").then((room) => { - room.data.username = "Max Doe"; room.data.allow_membership = true; - room.data.is_member = true; room.data.current_user = null; - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); - }); - cy.reload(); + cy.reload(); + }); - cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); - cy.intercept("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 420, + // Test reload with room not found and guest user + cy.interceptRoomIndexRequests(); + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 404, body: { - message: "guests_only", + message: "model_not_found", + model: "room", + ids: ["abc-def-123"], }, }).as("roomRequest"); cy.get('[data-test="reload-room-button"]').click(); - cy.wait("@roomRequest"); - // Check that error message is shown - cy.checkToastMessage("app.flash.guests_only"); + // Check redirect to 404 page worked cy.url() - .should("not.include", "/rooms") - .and("not.include", "rooms/abc-def-123"); - }); + .should("include", "/404") + .should("not.include", "/rooms/abc-def-123"); - it("logged in status change", function () { - cy.interceptRoomFilesRequest(); + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); + + // Test reload with room not found and authenticated user + cy.intercept("GET", "api/v1/currentUser", { fixture: "currentUser.json" }); cy.fixture("room.json").then((room) => { room.data.allow_membership = true; @@ -3612,86 +1811,30 @@ describe("Room View general", function () { }); cy.visit("/rooms/abc-def-123"); + cy.wait("@roomRequest"); + cy.contains("Meeting One").should("be.visible"); - // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("be.visible"); - cy.get("#tab-tokens").should("be.visible"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("be.visible"); - cy.get("#tab-settings").should("be.visible"); - - // Change current user to guest - cy.fixture("room.json").then((room) => { - room.data.allow_membership = true; - room.data.current_user = null; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 404, + body: { + message: "model_not_found", + model: "room", + ids: ["abc-def-123"], + }, + }).as("roomRequest"); cy.get('[data-test="reload-room-button"]').click(); + cy.wait("@roomRequest"); - // Check that access overlay is shown - cy.get('[data-test="room-access-overlay"]') - .should("be.visible") - .within(() => { - // Check that login button is shown - cy.get('[data-test="room-login-as-user-button"]').should("be.visible"); - - // Check that guest name input is shown and enter name - cy.get("#participant-name").should("be.visible").type("Max Doe"); - - // Check that access code input is hidden - cy.get('[data-test="access-code-field"]').should("not.exist"); - - // Login - cy.get('[data-test="room-login-button"]').click(); - }); - - // Check that tabs are shown correctly - cy.get("#tab-description").should("not.exist"); - cy.get("#tab-members").should("not.exist"); - cy.get("#tab-tokens").should("not.exist"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("not.exist"); - cy.get("#tab-settings").should("not.exist"); - - // Change current user to co_owner - cy.fixture("room.json").then((room) => { - room.data.allow_membership = true; - room.data.is_member = true; - room.data.is_co_owner = true; - room.data.current_user = { - id: 2, - firstname: "Max", - lastname: "Doe", - user_locale: "en", - permissions: ["rooms.create"], - model_name: "User", - room_limit: -1, - }; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.get('[data-test="reload-room-button"]').click(); + // Check redirect to room index page worked + cy.url() + .should("include", "/rooms") + .should("not.include", "/rooms/abc-def-123"); - // Check that tabs are shown correctly - cy.get("#tab-description").should("be.visible"); - cy.get("#tab-members").should("be.visible"); - cy.get("#tab-tokens").should("be.visible"); - cy.get("#tab-files").should("be.visible"); - cy.get("#tab-recordings").should("be.visible"); - cy.get("#tab-history").should("be.visible"); - cy.get("#tab-settings").should("be.visible"); + cy.checkToastMessage([ + 'app.flash.model_not_found.title_{"model":"app.model.room"}', + 'app.flash.model_not_found.details_{"ids":"abc-def-123"}', + ]); }); it("displays meeting ended reason", function () { From 89905aa83d8334631b36372d055af15e0fb83332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sabrina=20W=C3=BCst?= <119059706+Sabr1n4W@users.noreply.github.com> Date: Wed, 1 Jul 2026 12:40:35 +0200 Subject: [PATCH 15/35] Adjust system tests --- tests/System/e2e/RoomsJoinWithLobby.cy.js | 15 +++++---- tests/System/e2e/RoomsViewGeneral.cy.js | 37 ++++++++++++----------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/tests/System/e2e/RoomsJoinWithLobby.cy.js b/tests/System/e2e/RoomsJoinWithLobby.cy.js index 0b1c059b58..b3958de505 100644 --- a/tests/System/e2e/RoomsJoinWithLobby.cy.js +++ b/tests/System/e2e/RoomsJoinWithLobby.cy.js @@ -63,12 +63,13 @@ describe("Room Join with lobby settings", function () { cy.get('[data-test="navbar-user"]').click(); cy.get('[data-test="navbar-user-logout"]').click(); + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "John Doe"); + }); cy.visit("/rooms/abc-def-123"); // Find join button and click it, join as guest cy.get('[data-test="room-join-button"]').click(); - cy.get("#participant-name").type("John Doe"); - cy.get('[data-test="dialog-continue-button"]').click(); cy.origin(`${Cypress.expose("BBB_TEST_SERVER_HOST")}`, () => { cy.get('[data-test="audioModal"]', { timeout: 30000 }).should( @@ -137,12 +138,13 @@ describe("Room Join with lobby settings", function () { cy.get('[data-test="navbar-user"]').click(); cy.get('[data-test="navbar-user-logout"]').click(); + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "John Doe"); + }); cy.visit("/rooms/abc-def-123"); // Find join button and click it, join as guest cy.get('[data-test="room-join-button"]').click(); - cy.get("#participant-name").type("John Doe"); - cy.get('[data-test="dialog-continue-button"]').click(); cy.origin(`${Cypress.expose("BBB_TEST_SERVER_HOST")}`, () => { cy.get('[data-test="guestMessage"]', { timeout: 30000 }).should( @@ -211,12 +213,13 @@ describe("Room Join with lobby settings", function () { cy.get('[data-test="navbar-user"]').click(); cy.get('[data-test="navbar-user-logout"]').click(); + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "John Doe"); + }); cy.visit("/rooms/abc-def-123"); // Find join button and click it, join as guest cy.get('[data-test="room-join-button"]').click(); - cy.get("#participant-name").type("John Doe"); - cy.get('[data-test="dialog-continue-button"]').click(); cy.origin(`${Cypress.expose("BBB_TEST_SERVER_HOST")}`, () => { cy.get('[data-test="guestMessage"]', { timeout: 30000 }).should( diff --git a/tests/System/e2e/RoomsViewGeneral.cy.js b/tests/System/e2e/RoomsViewGeneral.cy.js index a9ae791fa5..ab20128887 100644 --- a/tests/System/e2e/RoomsViewGeneral.cy.js +++ b/tests/System/e2e/RoomsViewGeneral.cy.js @@ -17,16 +17,16 @@ describe("Room View general", function () { cy.visit("/rooms/abc-def-123"); cy.contains("Anatomy").should("be.visible"); - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); - cy.get('[data-test="room-access-code"] input').type("111111111"); - cy.get('[data-test="room-access-code"] button').click(); - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); - cy.get('[data-test="room-access-code"] input').clear(); + cy.get('[data-test="access-code-field"] input').type("111111111"); + cy.get('[data-test="room-login-button"]').click(); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get('[data-test="access-code-field"] input').clear(); - cy.get('[data-test="room-access-code"] input').type("123456789"); - cy.get('[data-test="room-access-code"] button').click(); - cy.get('[data-test="room-access-code-overlay"]').should("not.exist"); + cy.get('[data-test="access-code-field"] input').type("123456789"); + cy.get('[data-test="room-login-button"]').click(); + cy.get('[data-test="room-access-overlay"]').should("not.exist"); }); it("guest forbidden", function () { @@ -41,16 +41,19 @@ describe("Room View general", function () { cy.visit("/rooms/abc-def-234"); cy.contains("Math").should("be.visible"); - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); - cy.get('[data-test="room-access-code"] input').type("111111111"); - cy.get('[data-test="room-access-code"] button').click(); - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); - cy.get('[data-test="room-access-code"] input').clear(); - - cy.get('[data-test="room-access-code"] input').type("123456789"); - cy.get('[data-test="room-access-code"] button').click(); - cy.get('[data-test="room-access-code-overlay"]').should("not.exist"); + cy.get('[data-test="participant-name-field"] > #participant-name').type( + "John Doe", + ); + cy.get('[data-test="access-code-field"] input').type("111111111"); + cy.get('[data-test="room-login-button"]').click(); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get('[data-test="access-code-field"] input').clear(); + + cy.get('[data-test="access-code-field"] input').type("123456789"); + cy.get('[data-test="room-login-button"]').click(); + cy.get('[data-test="room-access-overlay"]').should("not.exist"); }); it("room not found", function () { From 152a86f1940edf1660e090cc32dde335f119a457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sabrina=20W=C3=BCst?= <119059706+Sabr1n4W@users.noreply.github.com> Date: Sun, 5 Jul 2026 21:07:28 +0200 Subject: [PATCH 16/35] Reset tab hash when falling back to default tab in tab sections --- resources/js/components/RoomTabSection.vue | 7 +++++-- resources/js/components/UserTabSection.vue | 8 ++++++-- tests/Frontend/e2e/AdminUsersEdit.cy.js | 4 ++-- tests/Frontend/e2e/AdminUsersView.cy.js | 4 ++-- tests/Frontend/e2e/RoomsViewHistory.cy.js | 4 +--- tests/Frontend/e2e/RoomsViewMembers.cy.js | 4 +--- tests/Frontend/e2e/RoomsViewPersonalizedLinks.cy.js | 4 +--- tests/Frontend/e2e/UserProfile.cy.js | 4 ++-- tests/Frontend/support/commands/roomCommands.js | 9 ++------- 9 files changed, 22 insertions(+), 26 deletions(-) diff --git a/resources/js/components/RoomTabSection.vue b/resources/js/components/RoomTabSection.vue index 956f812e1a..8b9238476d 100644 --- a/resources/js/components/RoomTabSection.vue +++ b/resources/js/components/RoomTabSection.vue @@ -134,7 +134,7 @@ diff --git a/resources/js/components/RoomParticipantNameChangeButton.vue b/resources/js/components/RoomParticipantNameChangeButton.vue index f65f6ab5ca..2d3e108a4e 100644 --- a/resources/js/components/RoomParticipantNameChangeButton.vue +++ b/resources/js/components/RoomParticipantNameChangeButton.vue @@ -26,11 +26,13 @@