diff --git a/CHANGELOG.md b/CHANGELOG.md
index 37d2154902..2286afd0ff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Accessibility: Landmark role to all search fields ([#3264])
- Accessibility: Skip links ([#3264])
- Accessibility: Announce page change to screen readers ([#3264])
+- Guests can now choose to remember their name for future video conferences ([#2450], [#3275])
+- Room access is now preserved across page reloads after entering via an access code or personalized link ([#3275])
+- Login button inside room access overlay to allow users to log in instead of accessing the room as a guest ([#2450], [#3275])
### Changed
@@ -24,6 +27,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Accessibility: Move keyboard focus to page start on page change ([#3264])
- Accessibility: Reduced flipping words animation on loading page for browsers with reduced-motion set ([#3277])
- Room share dialog now copies the room link and invitation message to the clipboard in both plain text and HTML format ([#3296])
+- Guest name input was moved from join dialog to room access overlay ([#2450], [#3275])
+- Room share link now includes the access code, so users no longer need to enter it manually when opening the link ([#3275])
+- Improved fallback behavior for invalid room and user tab links ([#3275])
## [v4.16.0] - 2026-06-12
@@ -767,6 +773,7 @@ You can find the changelog for older versions there [here](https://github.com/TH
[#2383]: https://github.com/THM-Health/PILOS/issues/2383
[#2433]: https://github.com/THM-Health/PILOS/pull/2433
[#2449]: https://github.com/THM-Health/PILOS/pull/2449
+[#2450]: https://github.com/THM-Health/PILOS/issues/2450
[#2476]: https://github.com/THM-Health/PILOS/issues/2476
[#2477]: https://github.com/THM-Health/PILOS/pull/2477
[#2478]: https://github.com/THM-Health/PILOS/issues/2478
@@ -855,6 +862,7 @@ You can find the changelog for older versions there [here](https://github.com/TH
[#3198]: https://github.com/THM-Health/PILOS/pull/3198
[#3215]: https://github.com/THM-Health/PILOS/pull/3215
[#3264]: https://github.com/THM-Health/PILOS/pull/3264
+[#3275]: https://github.com/THM-Health/PILOS/pull/3275
[#3277]: https://github.com/THM-Health/PILOS/pull/3277
[#3296]: https://github.com/THM-Health/PILOS/pull/3296
[unreleased]: https://github.com/THM-Health/PILOS/compare/v4.16.0...develop
diff --git a/app/Http/Requests/JoinMeetingRequest.php b/app/Http/Requests/JoinMeetingRequest.php
index c76a40795b..44f053cc3a 100644
--- a/app/Http/Requests/JoinMeetingRequest.php
+++ b/app/Http/Requests/JoinMeetingRequest.php
@@ -4,7 +4,6 @@
namespace App\Http\Requests;
-use App\Rules\ValidName;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Context;
@@ -15,7 +14,7 @@ public function rules(): array
$personalizedLink = Context::getHidden("room.{$this->room->id}.personalized_link");
$rules = [
- 'name' => auth()->check() || $personalizedLink ? [] : ['bail', 'required', 'min:2', 'max:50', new ValidName],
+ 'name' => auth()->check() || $personalizedLink ? [] : ValidateParticipantNameRequest::participantNameValidationRules(),
'dark_mode' => ['sometimes', 'boolean'],
];
diff --git a/app/Http/Requests/StartMeetingRequest.php b/app/Http/Requests/StartMeetingRequest.php
index f0c91a05b1..8fa084fcab 100644
--- a/app/Http/Requests/StartMeetingRequest.php
+++ b/app/Http/Requests/StartMeetingRequest.php
@@ -4,7 +4,6 @@
namespace App\Http\Requests;
-use App\Rules\ValidName;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Context;
@@ -15,7 +14,7 @@ public function rules(): array
$personalizedLink = Context::getHidden("room.{$this->room->id}.personalized_link");
$rules = [
- 'name' => auth()->check() || $personalizedLink ? [] : ['bail', 'required', 'min:2', 'max:50', new ValidName],
+ 'name' => auth()->check() || $personalizedLink ? [] : ValidateParticipantNameRequest::participantNameValidationRules(),
'dark_mode' => ['sometimes', 'boolean'],
];
diff --git a/app/Http/Requests/ValidateParticipantNameRequest.php b/app/Http/Requests/ValidateParticipantNameRequest.php
new file mode 100644
index 0000000000..b12f672330
--- /dev/null
+++ b/app/Http/Requests/ValidateParticipantNameRequest.php
@@ -0,0 +1,23 @@
+ self::participantNameValidationRules(),
+ ];
+ }
+
+ public static function participantNameValidationRules(): array
+ {
+ return ['bail', 'required', 'min:2', 'max:50', new ValidName];
+ }
+}
diff --git a/lang/en/app.php b/lang/en/app.php
index 07e5cd083b..ffd365c85f 100644
--- a/lang/en/app.php
+++ b/lang/en/app.php
@@ -126,6 +126,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..1bb5416344 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 b529230002..86203594ec 100644
--- a/lang/en/rooms.php
+++ b/lang/en/rooms.php
@@ -11,6 +11,7 @@
'meetingForciblyEnded' => 'Failed to join meeting: The meeting is no longer running.',
],
'become_member' => 'Become member',
+ 'change_participant_name' => 'Change name',
'change_type' => [
'changing_settings' => 'The following changes will be made to the room settings',
'current_setting' => 'Current setting',
@@ -24,6 +25,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',
@@ -273,6 +275,7 @@
],
],
'name' => 'Room name',
+ 'name_in_video_conference' => 'Name in video conference: ',
'no_rooms_available' => 'No rooms available',
'no_rooms_found' => 'No rooms found',
'not_running' => 'This room is not started yet.',
@@ -367,6 +370,8 @@
'title' => 'Recordings',
'view_recording' => 'View recording',
],
+ 'remember_participant_name' => 'Remember name for next time',
+ 'request_participant_name_change' => 'Please change your name to join the room.',
'require_access_code' => 'An access code is required to join this room',
'role' => 'Role',
'roles' => [
diff --git a/resources/js/components/RoomAccessOverlay.vue b/resources/js/components/RoomAccessOverlay.vue
new file mode 100644
index 0000000000..d7e129a5ef
--- /dev/null
+++ b/resources/js/components/RoomAccessOverlay.vue
@@ -0,0 +1,237 @@
+
+
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.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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("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"); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + // 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.wait("@checkParticipantNameRequest"); + + 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"); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewAccessAccessCode.cy.js b/tests/Frontend/e2e/RoomsViewAccessAccessCode.cy.js new file mode 100644 index 0000000000..7a3f89f898 --- /dev/null +++ b/tests/Frontend/e2e/RoomsViewAccessAccessCode.cy.js @@ -0,0 +1,1735 @@ +import { interceptIndefinitely } from "../support/utils/interceptIndefinitely.js"; + +describe("Rooms View access access code", function () { + beforeEach(function () { + cy.init(); + cy.interceptRoomViewRequests(); + }); + + 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("#access-code").should("be.disabled"); + 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.reloadWithHash("accessCode=123456789"); + + // 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 participantNameRequest = interceptIndefinitely( + "POST", + "api/v1/participantName/check", + { + statusCode: 204, + }, + "checkParticipantNameRequest", + ); + + 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 while participant name is validated + cy.get("#participant-name").should("be.disabled"); + cy.get("#remember-participant-name").should("be.disabled"); + cy.get("#access-code").should("be.disabled"); + cy.get('[data-test="room-login-button"]') + .should("be.disabled") + .then(() => { + participantNameRequest.sendResponse(); + }); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: "Laura Rivera", + }); + }); + + // Check loading while room access code is validated + cy.get("#participant-name").should("be.disabled"); + cy.get("#remember-participant-name").should("be.disabled"); + cy.get("#access-code").should("be.disabled"); + 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.reloadWithHash("accessCode=123456789"); + + 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"); + }); + + const checkParticipantNameRequest = interceptIndefinitely( + "POST", + "api/v1/participantName/check", + { + statusCode: 204, + }, + "checkParticipantNameRequest", + ); + + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + win.sessionStorage.clear(); + }); + + cy.reload(); + + // Check loading + cy.get('[data-test="room-loading-spinner"]') + .should("be.visible") + .then(() => { + checkParticipantNameRequest.sendResponse(); + }); + + cy.wait("@checkParticipantNameRequest"); + + 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.setValidRememberedParticipantName("Laura Rivera"); + + cy.window().then((win) => { + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "123456789"); + }); + + cy.reload(); + + cy.wait("@checkParticipantNameRequest"); + + 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"); + }); + + // Check with invalid_code error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_code", + }, + }).as("roomAuthRequest"); + + // 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"); + }); + + // Try to submit with invalid access code + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.get("#access-code").type("987654321"); + }); + + 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: "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"); + + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.get("#access-code").should("have.value", "987-654-321"); + }); + + // Reload with invalid access code set in session storage + cy.window().then((win) => { + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "987654321"); + }); + + cy.reload(); + + // 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 that invalid access code in session storage was cleared + 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"); + + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.get("#access-code").should("have.value", "987-654-321"); + }); + + // 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.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@checkParticipantNameRequest"); + 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("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", ""); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewAccessParticipantName.cy.js b/tests/Frontend/e2e/RoomsViewAccessParticipantName.cy.js new file mode 100644 index 0000000000..9662e240b2 --- /dev/null +++ b/tests/Frontend/e2e/RoomsViewAccessParticipantName.cy.js @@ -0,0 +1,1058 @@ +import { interceptIndefinitely } from "../support/utils/interceptIndefinitely.js"; + +describe("Rooms View access participant name", function () { + beforeEach(function () { + cy.init(); + cy.interceptRoomViewRequests(); + }); + + 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 with 422 error + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 422, + body: { + errors: { + name: ['Name contains the following non-permitted characters: <>";'], + }, + }, + }).as("checkParticipantNameRequest"); + + cy.get("#participant-name").type(''); + + // Click login button + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: '', + }); + }); + + // Check that access overlay is still shown and error message is shown + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + cy.get('[data-test="participant-name-field"]') + .contains('Name contains the following non-permitted characters: <>";') + .should("be.visible"); + + // Check with 500 error + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("checkParticipantNameRequest"); + + cy.get("#participant-name").clear(); + cy.get("#participant-name").type("Laura Rivera"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: "Laura Rivera", + }); + }); + + // Check that access overlay stays open and error message is shown + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + // 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"); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 422, + body: { + errors: { + name: ['Name contains the following non-permitted characters: <>";'], + }, + }, + }).as("checkParticipantNameRequest"); + + 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("#participant-name").type(''); + + // Click login button + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: '', + }); + }); + + // 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('Name contains the following non-permitted characters: <>";') + .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("rooms view with invalid remembered participant name in localStorage", 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.window().then((win) => { + win.localStorage.setItem( + "pilos_guest_name", + '', + ); + }); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 422, + body: { + errors: { + name: ['Name contains the following non-permitted characters: <>";'], + }, + }, + }).as("checkParticipantNameRequest"); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: '', + }); + }); + cy.wait("@roomRequest"); + + // 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.get("#participant-name") + .should("be.visible") + .and("have.value", ''); + cy.contains( + 'Name contains the following non-permitted characters: <>";', + ).should("be.visible"); + }); + + // Check that localStorage was cleared + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.be.null; + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("unexpectedRoomAuthRequest"); + + // Reinitializing with an access code + cy.window().then((win) => { + win.location.hash = "accessCode=123456789"; + }); + + cy.wait("@roomRequest"); + + cy.get("@unexpectedRoomAuthRequest").should("be.null"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#participant-name").should("have.value", ""); + cy.get("#access-code").should("have.value", "123-456-789"); + + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("checkParticipantNameRequest"); + + cy.reload(); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: "Laura Rivera", + }); + }); + cy.wait("@roomRequest"); + + // 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.get("#participant-name") + .should("be.visible") + .and("have.value", "Laura Rivera"); + }); + + cy.window().then((win) => { + expect(win.localStorage.getItem("pilos_guest_name")).to.eq( + "Laura Rivera", + ); + }); + + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + 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.allow_membership = true; + room.data.current_user = null; + room.data.authenticated = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.window().then((win) => { + win.location.hash = "accessCode=123456789"; + }); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: "Laura Rivera", + }); + }); + + 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"); + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("be.visible"); + }); + + it("rooms view with remembered participant name after logout", function () { + cy.interceptRoomFilesRequest(); + + cy.window().then((win) => { + win.localStorage.setItem("pilos_guest_name", "Laura Rivera"); + }); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + const checkParticipantNameRequest = interceptIndefinitely( + "POST", + "api/v1/participantName/check", + { + statusCode: 204, + }, + "checkParticipantNameRequest", + ); + + 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.get('[data-test="reload-room-button"]').click(); + + cy.wait("@roomRequest"); + + cy.checkToastMessage("rooms.require_access_code"); + + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#participant-name") + .should("have.value", "") + .and("be.disabled") + .then(() => { + checkParticipantNameRequest.sendResponse(); + }); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: "Laura Rivera", + }); + }); + + cy.get("#participant-name") + .should("have.value", "Laura Rivera") + .and("not.be.disabled"); + cy.get("#remember-participant-name").should("be.checked"); + cy.get('[data-test="access-code-field"]').should("be.visible"); + }); + + 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"); + + const checkParticipantNameRequest = interceptIndefinitely( + "POST", + "api/v1/participantName/check", + { + statusCode: 204, + }, + "checkParticipantNameRequest", + ); + + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + // Check loading + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.get('[data-test="room-login-button"]') + .should("be.disabled") + .then(() => { + checkParticipantNameRequest.sendResponse(); + }); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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"); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + // Save + cy.get('[data-test="dialog-save-button"]').click(); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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.setValidRememberedParticipantName("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(); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="room-login-button"]') + .should("have.text", "rooms.continue_as_guest") + .click(); + + cy.wait("@checkParticipantNameRequest"); + + // 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(); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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(); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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.setValidRememberedParticipantName("Laura Rivera"); + + cy.reload(); + + cy.wait("@checkParticipantNameRequest"); + + // 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(); + }); + + cy.wait("@checkParticipantNameRequest"); + + // 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.setValidRememberedParticipantName("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"); + + cy.wait("@checkParticipantNameRequest"); + cy.wait("@roomRequest"); + + // 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", + ); + + // Change name with 422 error + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 422, + body: { + errors: { + name: ['Name contains the following non-permitted characters: <>";'], + }, + }, + }).as("checkParticipantNameRequest"); + + 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"); + }); + + cy.get("#participant-name").clear(); + cy.get("#participant-name").type(''); + + // Try to save invalid name + cy.get('[data-test="dialog-save-button"]').click(); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: '', + }); + }); + + // Check that dialog stays open and error message is shown + cy.get('[data-test="room-change-participant-name-dialog"]') + .should("be.visible") + .within(() => { + cy.get('[data-test="participant-name-field"]') + .contains( + 'Name contains the following non-permitted characters: <>";', + ) + .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"); + }); + + // Check with 500 error + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="dialog-save-button"]').click(); + + cy.wait("@checkParticipantNameRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: "Laura Rivera", + }); + }); + + // Check dialog stays open and error message is shown + cy.get('[data-test="room-change-participant-name-dialog"]').should( + "be.visible", + ); + + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewAccessPersonalizedLink.cy.js b/tests/Frontend/e2e/RoomsViewAccessPersonalizedLink.cy.js new file mode 100644 index 0000000000..8cc8a23d0e --- /dev/null +++ b/tests/Frontend/e2e/RoomsViewAccessPersonalizedLink.cy.js @@ -0,0 +1,1160 @@ +import { interceptIndefinitely } from "../support/utils/interceptIndefinitely.js"; + +describe("Rooms View access personalized link", function () { + beforeEach(function () { + cy.init(); + cy.interceptRoomViewRequests(); + }); + + 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 with personalized link from hash + // 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/E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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 that error stays even though personalized link now is loaded from the sessionStorage + cy.url().should("not.include", "#personalizedLink"); + cy.reload(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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 with personalized link from hash + 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/E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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 that error stays even though personalized link now is loaded from the sessionStorage + cy.url().should("not.include", "#personalizedLink"); + cy.reload(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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 with personalized link from hash + 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/E420evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E420evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E420evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + cy.checkToastMessage("app.flash.guests_only"); + cy.url() + .should("not.include", "/rooms") + .and("not.include", "rooms/abc-def-123"); + + // Check with 500 error with personalized link from hash + 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/E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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"); + + // Reload page and check that error stays even though personalized link now is loaded from the sessionStorage + cy.url().should("not.include", "#personalizedLink"); + cy.reload(); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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: + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + 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( + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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/E404evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E404evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + 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"); + + cy.get("@roomRequest").should("be.null"); + }); + + it("visit with personalized link in sessionStorage 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"); + }); + + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 1, + }, + }, + }).as("roomAuthRequest"); + + cy.interceptRoomFilesRequest(); + + cy.window().then((win) => { + win.sessionStorage.setItem( + "roomPersonalizedLink_abc-def-123", + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // Visit room with personalized link in session storage + cy.visit("/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; + }); + + // Check that room was loaded and no participant name is shown + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is not shown + cy.contains("rooms.name_in_video_conference").should("not.exist"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Check that sessionStorage was cleared + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123")).to + .be.null; + }); + + // Check that auth request was not sent + cy.get("@roomAuthRequest").should("be.null"); + }); + + 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"); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewAccessSavedAccessParameters.cy.js b/tests/Frontend/e2e/RoomsViewAccessSavedAccessParameters.cy.js new file mode 100644 index 0000000000..60d901f79c --- /dev/null +++ b/tests/Frontend/e2e/RoomsViewAccessSavedAccessParameters.cy.js @@ -0,0 +1,1625 @@ +import { interceptIndefinitely } from "../support/utils/interceptIndefinitely.js"; + +describe("Rooms View access saved access parameters", function () { + beforeEach(function () { + cy.init(); + cy.interceptRoomViewRequests(); + }); + + 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.setValidRememberedParticipantName("Laura Rivera"); + + cy.window().then((win) => { + 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", + ); + }); + + // Check that the competing access code hash was removed and cannot win on a later reload + cy.url().should("not.include", "accessCode"); + + // Reload without personalized link 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.reload(); + + // Check that the access code from the previous hash was discarded and the personalized link is still used + 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"); + + // Reload without personalized link in hash, but with an explicit access code 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.reloadWithHash("accessCode=987654321"); + + // 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 + .be.null; + }); + + // Reload without access code 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.reload(); + + // Check that auth was called with access code from sessionStorage + 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"); + }); + + it("hash change with no saved access parameters", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + cy.setValidRememberedParticipantName("Laura Rivera"); + + 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"); + + // Add access code to hash params + const accessCodeRoomAuthRequest = 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.window().then((win) => { + win.location.hash = "accessCode=987654321"; + }); + + // Check loading state + cy.get('[data-test="room-loading-spinner"]') + .should("be.visible") + .then(() => { + accessCodeRoomAuthRequest.sendResponse(); + }); + + // Check that auth was called with access code from hash and room was reloaded + 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 url was cleared and access code was saved to sessionStorage + cy.url().should("not.include", "accessCode"); + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "987654321", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").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"); + + // Clear sessionStorage and reload room + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + + 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.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"); + + // Add personalized link in hash params + const personalizedLinkRoomAuthRequest = 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"); + }); + + cy.window().then((win) => { + win.location.hash = + "personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx"; + }); + + // Check loading state + cy.get('[data-test="room-loading-spinner"]') + .should("be.visible") + .then(() => { + personalizedLinkRoomAuthRequest.sendResponse(); + }); + + // Check that auth was called with personalized link from hash and room was reloaded + 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 url was cleared and personalized link was saved to sessionStorage + cy.url().should("not.include", "personalizedLink"); + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + cy.contains("Max Doe").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Clear sessionStorage and reload room + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + + 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.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"); + + // Add personalized link and access code in hash params + 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.window().then((win) => { + win.location.hash = + "personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx&accessCode=987654321"; + }); + + // Check that auth was called with personalized link from hash and room was reloaded + 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 url was cleared and personalized link was saved to sessionStorage + cy.url().should("not.include", "personalizedLink"); + cy.url().should("not.include", "accessCode"); + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + cy.contains("Max Doe").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + }); + + it("hash change with saved access code", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + cy.setValidRememberedParticipantName("Laura Rivera"); + + 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", "987654321"); + }); + + cy.visit("/rooms/abc-def-123"); + + 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 room Header is shown correctly + cy.contains("Meeting One").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"); + + // Add different access code to hash params + cy.window().then((win) => { + win.location.hash = "accessCode=123456789"; + }); + + // Check that auth was called with access code from hash and room was reloaded + 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 url was cleared and access code was updated in sessionStorage + cy.url().should("not.include", "accessCode"); + 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"); + + // 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"); + + // Reset sessionStorage and reload room + cy.window().then((win) => { + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "987654321"); + }); + + cy.reload(); + + 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 room Header is shown correctly + cy.contains("Meeting One").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"); + + // Add personalized link in hash params + 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.window().then((win) => { + win.location.hash = + "personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx"; + }); + + // Check that auth was called with personalized link from hash and room was reloaded + 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 url was cleared and personalized link was saved to sessionStorage + cy.url().should("not.include", "personalizedLink"); + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + cy.contains("Max Doe").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Reset sessionStorage and reload room + cy.window().then((win) => { + win.sessionStorage.clear(); + win.sessionStorage.setItem("roomAccessCode_abc-def-123", "987654321"); + }); + + 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.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 201, + body: { + data: { + id: "roomAuthToken", + type: 0, + }, + }, + }).as("roomAuthRequest"); + + cy.reload(); + + 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 room Header is shown correctly + cy.contains("Meeting One").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"); + + // Add personalized link and access code in hash params + 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.window().then((win) => { + win.location.hash = + "personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx&accessCode=987654321"; + }); + + // Check that auth was called with personalized link from hash and room was reloaded + 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 url was cleared and personalized link was saved to sessionStorage + cy.url().should("not.include", "personalizedLink"); + cy.url().should("not.include", "accessCode"); + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + cy.contains("Max Doe").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + }); + + it("hash change with saved personalized link", function () { + cy.intercept("GET", "api/v1/currentUser", {}); + cy.interceptRoomFilesRequest(); + cy.setValidRememberedParticipantName("Laura Rivera"); + + 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.window().then((win) => { + win.sessionStorage.setItem( + "roomPersonalizedLink_abc-def-123", + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + cy.visit("/rooms/abc-def-123"); + + 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 Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that 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"); + + // Add access code to hash params + 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.location.hash = "accessCode=987654321"; + }); + + 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 url was cleared and sessionStorage was updated + cy.url().should("not.include", "accessCode"); + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "987654321", + ); + expect(win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123")).to + .be.null; + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Max Doe").should("not.exist"); + cy.contains("Laura Rivera").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("be.visible"); + + // Add different personalized link in hash params + 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 = "Angela Jones"; + 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.window().then((win) => { + win.location.hash = + "personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx"; + }); + + // Check that auth was called with personalized link from hash and room was reloaded + 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 url was cleared and personalized link was updated in sessionStorage + cy.url().should("not.include", "personalizedLink"); + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Max Doe").should("not.exist"); + cy.contains("Angela Jones").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + + // Reset sessionStorage and reload room + cy.window().then((win) => { + win.sessionStorage.clear(); + win.sessionStorage.setItem( + "roomPersonalizedLink_abc-def-123", + "xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + 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.reload(); + + 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 Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that 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"); + + // Add different personalized link and access code in hash params + 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 = "Angela Jones"; + 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.window().then((win) => { + win.location.hash = + "personalizedLink=RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx&accessCode=987654321"; + }); + + // Check that auth was called with personalized link from hash and room was reloaded + 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 url was cleared and personalized link was saved to sessionStorage + cy.url().should("not.include", "personalizedLink"); + cy.url().should("not.include", "accessCode"); + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.be + .null; + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "RQPyP56Fcg2gWNLSWEgEABAfENfEbJRPly2ZPWP56FcBghsHsHfBH4Atn1z22UFkSltkBEAgWFpof23fW65UgPFn3tzft1syMcTVveCDWx", + ); + }); + + // Check that room Header is shown correctly + cy.contains("Meeting One").should("be.visible"); + + // Check that participant name is shown + cy.contains("rooms.name_in_video_conference").should("be.visible"); + cy.contains("Laura Rivera").should("not.exist"); + cy.contains("Angela Jones").should("be.visible"); + cy.get('[data-test="change-participant-name-button"]').should("not.exist"); + }); + + it("hash change 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 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.window().then((win) => { + win.location.hash = "accessCode=123456789"; + }); + + cy.wait("@roomAuthRequest"); + cy.wait("@roomRequest"); + + 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"); + }); + + // Check with invalid_code error + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 401, + body: { + message: "invalid_code", + }, + }).as("roomAuthRequest"); + + 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.location.hash = "accessCode=987654321"; + }); + + 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"); + + cy.get('[data-test="room-access-overlay"]') + .should("be.visible") + .within(() => { + cy.get("#access-code").should("have.value", "987-654-321"); + }); + + // 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.window().then((win) => { + win.location.hash = "accessCode=987654321"; + }); + + // Wait for room auth request + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + access_code: "987654321", + type: 0, + }); + }); + cy.wait("@roomRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "987654321", + ); + }); + + // 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.window().then((win) => { + win.location.hash = "accessCode=987654321"; + }); + + cy.wait("@roomAuthRequest"); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "987654321", + ); + }); + + // 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"); + + // 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.window().then((win) => { + win.location.hash = "accessCode=987654321"; + }); + + cy.window().then((win) => { + expect(win.sessionStorage.getItem("roomAccessCode_abc-def-123")).to.eq( + "987654321", + ); + }); + + // 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.window().then((win) => { + win.location.hash = "accessCode=987654321"; + }); + + 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.window().then((win) => { + win.sessionStorage.clear(); + }); + cy.setValidRememberedParticipantName("Angela Jones"); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + win.location.hash = "accessCode=987654321"; + }); + + cy.wait("@checkParticipantNameRequest"); + cy.wait("@roomAuthRequest"); + + // 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("hash change with personalized link errors", function () { + 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.interceptRoomFilesRequest(); + + // 401 invalid personalize link with personalized link from hash + // 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"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + win.location.hash = + "personalizedLink=E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&accessCode=987654321"; + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E401evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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.window().then((win) => { + win.sessionStorage.clear(); + }); + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + win.location.hash = + "personalizedLink=E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&accessCode=987654321"; + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E422evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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 + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + win.location.hash = + "personalizedLink=E420evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&accessCode=987654321"; + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E420evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E420evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + cy.checkToastMessage("app.flash.guests_only"); + cy.url() + .should("not.include", "/rooms") + .and("not.include", "rooms/abc-def-123"); + + // Check with 500 error with personalized link + cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("roomAuthRequest"); + + // Visit room + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + win.location.hash = + "personalizedLink=E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&accessCode=987654321"; + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + type: 1, + }); + }); + + cy.window().then((win) => { + expect( + win.sessionStorage.getItem("roomPersonalizedLink_abc-def-123"), + ).to.eq( + "E500evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + ); + }); + + // 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"); + + // 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 + cy.window().then((win) => { + win.sessionStorage.clear(); + }); + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.window().then((win) => { + win.location.hash = + "personalizedLink=E404evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&accessCode=987654321"; + }); + + cy.wait("@roomAuthRequest").then((interception) => { + expect(interception.request.body).to.eql({ + personalized_link_token: + "E404evVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + 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"}', + ]); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewDescription.cy.js b/tests/Frontend/e2e/RoomsViewDescription.cy.js index cc252d3194..79a551623b 100644 --- a/tests/Frontend/e2e/RoomsViewDescription.cy.js +++ b/tests/Frontend/e2e/RoomsViewDescription.cy.js @@ -8,6 +8,8 @@ describe("Rooms view description", function () { beforeEach(function () { cy.init(); cy.interceptRoomViewRequests(); + + cy.setValidRememberedParticipantName("Laura Rivera"); }); it("view with different permissions", function () { diff --git a/tests/Frontend/e2e/RoomsViewFiles.cy.js b/tests/Frontend/e2e/RoomsViewFiles.cy.js index 3344588853..34cf6fd8de 100644 --- a/tests/Frontend/e2e/RoomsViewFiles.cy.js +++ b/tests/Frontend/e2e/RoomsViewFiles.cy.js @@ -5,6 +5,8 @@ describe("Rooms View Files", function () { cy.init(); cy.interceptRoomViewRequests(); cy.interceptRoomFilesRequest(true); + + cy.setValidRememberedParticipantName("Laura Rivera"); }); it("load files", function () { @@ -182,24 +184,6 @@ describe("Rooms View Files", function () { }); it("load files with access code", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { id: 2, name: "Max Doe" }; - room.data.authenticated = false; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.interceptRoomFilesRequest(); - - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - cy.get("#access-code").type("123456789"); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -219,7 +203,9 @@ describe("Rooms View Files", function () { }).as("roomRequest"); }); - cy.get('[data-test="room-login-button"]').click(); + cy.interceptRoomFilesRequest(); + + cy.visit("/rooms/abc-def-123#accessCode=123456789"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -288,29 +274,6 @@ describe("Rooms View Files", function () { }); it("load files with access code errors", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { id: 2, name: "Max Doe" }; - room.data.authenticated = false; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.intercept("GET", "api/v1/rooms/abc-def-123/files*", { - statusCode: 401, - body: { - message: "invalid_auth_token", - }, - }).as("roomFilesRequest"); - - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - cy.get("#access-code").type("123456789"); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -334,7 +297,8 @@ describe("Rooms View Files", function () { "roomRequest", ); - cy.get('[data-test="room-login-button"]').click(); + cy.visit("/rooms/abc-def-123#accessCode=123456789"); + cy.wait("@roomAuthRequest"); cy.fixture("room.json").then((room2) => { room2.data.owner = { id: 2, name: "Max Doe" }; @@ -351,7 +315,13 @@ describe("Rooms View Files", function () { }); }); - cy.wait("@roomAuthRequest"); + cy.intercept("GET", "api/v1/rooms/abc-def-123/files*", { + statusCode: 401, + body: { + message: "invalid_auth_token", + }, + }).as("roomFilesRequest"); + cy.wait("@roomRequest"); cy.wait("@roomFilesRequest").then((interception) => { @@ -459,7 +429,7 @@ describe("Rooms View Files", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", ); cy.wait("@roomAuthRequest"); @@ -563,7 +533,7 @@ describe("Rooms View Files", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", ); cy.wait("@roomAuthRequest").then(() => { @@ -919,6 +889,7 @@ describe("Rooms View Files", function () { cy.visit("/rooms/abc-def-123"); cy.wait("@roomRequest"); + cy.wait("@roomFilesRequest"); cy.get('[data-test="room-files-upload-button"]').should("not.exist"); @@ -1084,6 +1055,7 @@ describe("Rooms View Files", function () { cy.reload(); cy.wait("@roomRequest"); + cy.wait("@roomFilesRequest"); cy.get('[data-test="room-files-upload-button"]').should("not.exist"); diff --git a/tests/Frontend/e2e/RoomsViewFilesFileActions.cy.js b/tests/Frontend/e2e/RoomsViewFilesFileActions.cy.js index b5d08945be..b7f09af0cf 100644 --- a/tests/Frontend/e2e/RoomsViewFilesFileActions.cy.js +++ b/tests/Frontend/e2e/RoomsViewFilesFileActions.cy.js @@ -7,6 +7,8 @@ describe("Rooms view files file actions", function () { cy.init(); cy.interceptRoomViewRequests(); cy.interceptRoomFilesRequest(true); + + cy.setValidRememberedParticipantName("Laura Rivera"); }); it("upload file", function () { @@ -911,24 +913,6 @@ describe("Rooms view files file actions", function () { }); it("download file with access code errors", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { id: 2, name: "Max Doe" }; - room.data.authenticated = false; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - - cy.interceptRoomFilesRequest(); - - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - cy.get("#access-code").type("123456789"); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -948,7 +932,9 @@ describe("Rooms view files file actions", function () { }).as("roomRequest"); }); - cy.get('[data-test="room-login-button"]').click(); + cy.interceptRoomFilesRequest(); + + cy.visit("/rooms/abc-def-123#accessCode=123456789"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -1053,7 +1039,7 @@ describe("Rooms view files file actions", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", ); cy.wait("@roomAuthRequest"); @@ -1240,6 +1226,10 @@ describe("Rooms view files file actions", function () { // Check that room and files are reloaded (because of changes in the room (current_user)) cy.wait("@reloadRoomRequest"); + cy.wait("@checkParticipantNameRequest"); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + cy.wait("@roomFilesRequest"); // Check that file list was updated again diff --git a/tests/Frontend/e2e/RoomsViewGeneral.cy.js b/tests/Frontend/e2e/RoomsViewGeneral.cy.js index 774e9fa8ab..6bb07b13bb 100644 --- a/tests/Frontend/e2e/RoomsViewGeneral.cy.js +++ b/tests/Frontend/e2e/RoomsViewGeneral.cy.js @@ -6,13 +6,19 @@ 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", { statusCode: 200, @@ -26,16 +32,21 @@ describe("Room View general", function () { // 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"); + + // 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"); @@ -51,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, @@ -121,80 +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 input is shown correctly - cy.get('[data-test="room-access-code-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", - ); - cy.contains("rooms.require_access_code").should("be.visible"); - - // 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-code-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"); @@ -202,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"); @@ -217,21 +113,22 @@ 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.name = 'Meeting One '; + 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, @@ -239,1727 +136,383 @@ describe("Room View general", function () { }).as("roomRequest"); }); - cy.reload(); + cy.visit("/rooms/abc-def-123"); - cy.wait("@roomRequest"); + cy.title().should( + "eq", + 'Meeting One - PILOS Test', + ); - cy.get('[data-test="room-access-code-overlay"]') - .should("be.visible") - .within(() => { - // Try to submit with correct access code - cy.get("#access-code").type("123456789"); + // 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`, + ); }); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { - statusCode: 200, - body: { - data: { - id: "roomAuthToken", - type: 0, - }, - }, - }).as("roomAuthRequest"); + win.navigator.clipboard.read().then((clipboardItems) => { + const clipboardItem = clipboardItems[0]; + expect(clipboardItem.types).to.include("text/plain"); + expect(clipboardItem.types).to.include("text/html"); - cy.fixture("room.json").then((room) => { - room.data.owner = { - id: 2, - name: "Max Doe", - }; - room.data.description = "Test
"; - room.data.allow_membership = true; + // Check plaintext + clipboardItem + .getType("text/plain") + .then((b) => b.text()) + .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("GET", "api/v1/rooms/abc-def-123*", { - statusCode: 200, - body: room, - }).as("roomRequest"); + // Check html + clipboardItem + .getType("text/html") + .then((b) => b.text()) + .then((text) => { + expect(text).to.contain( + `rooms.invitation.room_{"roomname":"Meeting One <script>alert(\\"XSS\\")</script>","platform":"PILOS Test"}
rooms.invitation.link: ${Cypress.config("baseUrl")}/rooms/abc-def-123#accessCode=508307005
rooms.invitation.code: 508-307-005
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-code-overlay"]').should("be.visible"); - - // Retry with valid access code but no access code needed anymore - cy.get('[data-test="room-access-code-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-code-overlay"]').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 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"); - // Check that access code input is shown correctly - cy.get('[data-test="room-access-code-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", + // 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.contains("rooms.require_access_code").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", + // 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-code-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 () { + // Reload with legacy alphanumeric access code 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 = true; + room.data.access_code = "012abc"; cy.intercept("GET", "api/v1/rooms/abc-def-123", { statusCode: 200, body: room, }).as("roomRequest"); }); - - cy.visit("/rooms/abc-def-123"); + cy.get('[data-test="reload-room-button"]').click(); cy.wait("@roomRequest"); - 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=012abc", + ); + cy.get("#invitationCode").should("have.value", "012abc"); - // Check that access code input is shown correctly - cy.get('[data-test="room-access-code-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", + // 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", ); - cy.contains("rooms.require_access_code").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.get('[data-test="room-access-code-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"); - - // 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, }); }); - // 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"); - - // 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-code-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"); - - // 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 code overlay is hidden - cy.get('[data-test="room-access-code-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('[data-test="room-login-button"]').click(); - - cy.wait("@roomAuthRequest"); - - // 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.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; - }); - - // 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-code-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-code-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.name = 'Meeting One '; - 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", - ); - 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\nrooms.invitation.code: 508-307-005`, - ); - }); - - win.navigator.clipboard.read().then((clipboardItems) => { - const clipboardItem = clipboardItems[0]; - expect(clipboardItem.types).to.include("text/plain"); - expect(clipboardItem.types).to.include("text/html"); - - // Check plaintext - clipboardItem - .getType("text/plain") - .then((b) => b.text()) - .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\nrooms.invitation.code: 508-307-005`, - ); - }); - - // Check html - clipboardItem - .getType("text/html") - .then((b) => b.text()) - .then((text) => { - expect(text).to.contain( - `rooms.invitation.room_{"roomname":"Meeting One <script>alert(\\"XSS\\")</script>","platform":"PILOS Test"}
rooms.invitation.link: ${Cypress.config("baseUrl")}/rooms/abc-def-123
rooms.invitation.code: 508-307-005
rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}
rooms.invitation.link: ${Cypress.config("baseUrl")}/rooms/abc-def-123
rooms.invitation.room_{"roomname":"Meeting One","platform":"PILOS Test"}
rooms.invitation.link: ${Cypress.config("baseUrl")}/rooms/abc-def-123
Test
"; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { statusCode: 200, body: room, }).as("roomRequest"); @@ -2674,7 +1247,7 @@ describe("Room View general", function () { cy.contains("auth.login").should("be.visible"); // Check that access code overlay is shown - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); // Reload room with user being a member of the room cy.fixture("room.json").then((room) => { @@ -3031,7 +1604,7 @@ describe("Room View general", function () { cy.contains("auth.login").should("be.visible"); // Check that access code overlay is shown - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + 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) => { @@ -3100,40 +1673,11 @@ describe("Room View general", function () { // 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 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/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", + // 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", ); }); @@ -3393,305 +1937,6 @@ 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; - - 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"); - - // 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; - }); - - // 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-code-overlay"]').should("be.visible"); - }); - - 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 = "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.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", - ); - - cy.wait("@roomAuthRequest"); - cy.wait("@roomRequest"); - - // 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"); - - // 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 = "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.reload(); - - cy.wait("@roomAuthRequest"); - cy.wait("@roomRequest"); - - 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 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("displays meeting ended reason", function () { cy.fixture("room.json").then((room) => { room.data.allow_membership = true; diff --git a/tests/Frontend/e2e/RoomsViewHistory.cy.js b/tests/Frontend/e2e/RoomsViewHistory.cy.js index 1936dd9629..5a2e727eec 100644 --- a/tests/Frontend/e2e/RoomsViewHistory.cy.js +++ b/tests/Frontend/e2e/RoomsViewHistory.cy.js @@ -330,10 +330,23 @@ describe("Rooms view history", function () { // Check that room gets reloaded cy.wait("@roomRequest"); + // Enter guest name + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#participant-name").type("Max Doe"); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@checkParticipantNameRequest"); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + // Check that file tab is shown cy.wait("@roomFilesRequest"); cy.url().should("not.include", "#tab=history"); - cy.url().should("include", "/rooms/abc-def-123#tab=files"); // Check that error message is shown cy.checkToastMessage("app.flash.unauthenticated"); @@ -384,7 +397,7 @@ describe("Rooms view history", function () { cy.wait("@roomRequest"); // Check that access code overlay is shown - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); // Check that error message is shown cy.checkToastMessage("app.flash.unauthenticated"); diff --git a/tests/Frontend/e2e/RoomsViewMeetings.cy.js b/tests/Frontend/e2e/RoomsViewMeetings.cy.js index bfe785dc41..d31e5545ff 100644 --- a/tests/Frontend/e2e/RoomsViewMeetings.cy.js +++ b/tests/Frontend/e2e/RoomsViewMeetings.cy.js @@ -4,6 +4,8 @@ describe("Rooms view meetings", function () { beforeEach(function () { cy.init(); cy.interceptRoomViewRequests(); + + cy.setValidRememberedParticipantName("Laura Rivera"); }); it("join running meeting", function () { @@ -458,9 +460,7 @@ describe("Rooms view meetings", function () { // Test with valid name cy.get('[data-test="room-join-dialog"]') .should("be.visible") - .and("include.text", "rooms.first_and_lastname") .within(() => { - cy.get("#guest-name").type("John Doe"); cy.get("#record-attendance-agreement").should("not.be.checked").click(); cy.get("#record-agreement").should("not.be.checked").click(); cy.get("#record-video-agreement").should("not.be.checked").click(); @@ -478,7 +478,7 @@ describe("Rooms view meetings", function () { // Check that correct query is sent cy.wait("@joinRequest").then((interception) => { expect(interception.request.body).to.eql({ - name: "John Doe", + name: "Laura Rivera", consent_record_attendance: true, consent_record: true, consent_record_video: true, @@ -548,7 +548,6 @@ describe("Rooms view meetings", function () { cy.get('[data-test="room-join-dialog"]') .should("be.visible") .within(() => { - cy.get("#guest-name").type("John Doe 123!"); cy.get("#record-attendance-agreement").should("not.be.checked").click(); cy.get("#record-agreement").should("not.be.checked").click(); cy.get("#record-video-agreement").should("not.be.checked").click(); @@ -558,7 +557,7 @@ describe("Rooms view meetings", function () { // Check that correct query is sent cy.wait("@joinRequest").then((interception) => { expect(interception.request.body).to.eql({ - name: "John Doe 123!", + name: "Laura Rivera", consent_record_attendance: true, consent_record: true, consent_record_video: true, @@ -575,8 +574,6 @@ describe("Rooms view meetings", function () { "The name contains the following non-permitted characters: 123!", ); - cy.get("#guest-name").should("have.value", "John Doe 123!"); - // Test 500 error cy.intercept("POST", "/api/v1/rooms/abc-def-123/join*", { statusCode: 500, @@ -605,15 +602,24 @@ describe("Rooms view meetings", function () { }); it("join running meeting with access code", function () { + 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.last_meeting = { start: "2023-08-21T08:18:28.000000Z", end: null, }; - room.data.authenticated = false; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { statusCode: 200, body: room, }).as("roomRequest"); @@ -634,36 +640,7 @@ describe("Rooms view meetings", function () { cy.interceptRoomFilesRequest(); - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - 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.last_meeting = { - start: "2023-08-21T08:18:28.000000Z", - end: null, - }; - - 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#accessCode=123456789"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -749,12 +726,6 @@ describe("Rooms view meetings", function () { }, }).as("preJoinRequest"); - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - cy.get("#access-code").type("123456789"); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -778,7 +749,7 @@ describe("Rooms view meetings", function () { }).as("roomRequest"); }); - cy.get('[data-test="room-login-button"]').click(); + cy.visit("/rooms/abc-def-123#accessCode=123456789"); cy.wait("@roomAuthRequest"); @@ -944,7 +915,7 @@ describe("Rooms view meetings", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", ); cy.wait("@roomAuthRequest"); @@ -1078,6 +1049,8 @@ describe("Rooms view meetings", function () { }).as("roomRequest"); }); + cy.interceptRoomFilesRequest(); + cy.intercept("OPTIONS", "api/v1/rooms/abc-def-123/join", { statusCode: 200, body: { @@ -1411,6 +1384,8 @@ describe("Rooms view meetings", function () { }).as("roomRequest"); }); + cy.interceptRoomFilesRequest(); + // Test guests not allowed cy.intercept("OPTIONS", "api/v1/rooms/abc-def-123/join", { statusCode: 403, @@ -1578,6 +1553,7 @@ describe("Rooms view meetings", function () { ); cy.wait("@roomAuthRequest"); + cy.wait("@roomRequest"); // Test invalid_auth_token cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { @@ -1606,6 +1582,9 @@ describe("Rooms view meetings", function () { cy.get('[data-test="room-join-dialog"]').should("not.exist"); // Reload room + cy.window().then((win) => { + win.sessionStorage.clear(); + }); cy.fixture("room.json").then((room) => { room.data.last_meeting = { start: "2023-08-21T08:18:28.000000Z", @@ -2095,14 +2074,13 @@ describe("Rooms view meetings", function () { cy.visit("/rooms/abc-def-123"); - // Test with invalid name + // Test with valid name cy.get('[data-test="room-start-button"]').click(); // Test with valid name cy.get('[data-test="room-join-dialog"]') .should("be.visible") .within(() => { - cy.get("#guest-name").type("John Doe"); cy.get("#record-attendance-agreement").should("not.be.checked").click(); cy.get("#record-agreement").should("not.be.checked").click(); cy.get("#record-video-agreement").should("not.be.checked").click(); @@ -2120,7 +2098,7 @@ describe("Rooms view meetings", function () { // Check that correct query is sent cy.wait("@startRequest").then((interception) => { expect(interception.request.body).to.eql({ - name: "John Doe", + name: "Laura Rivera", consent_record_attendance: true, consent_record: true, consent_record_video: true, @@ -2182,8 +2160,6 @@ describe("Rooms view meetings", function () { cy.get('[data-test="room-join-dialog"]') .should("be.visible") .within(() => { - cy.contains("rooms.first_and_lastname"); - cy.get("#guest-name").type("John Doe 123!"); cy.get("#record-attendance-agreement").should("not.be.checked").click(); cy.get("#record-agreement").should("not.be.checked").click(); cy.get("#record-video-agreement").should("not.be.checked").click(); @@ -2193,7 +2169,7 @@ describe("Rooms view meetings", function () { // Check that correct query is sent cy.wait("@startRequest").then((interception) => { expect(interception.request.body).to.eql({ - name: "John Doe 123!", + name: "Laura Rivera", consent_record_attendance: true, consent_record: true, consent_record_video: true, @@ -2209,8 +2185,6 @@ describe("Rooms view meetings", function () { "The name contains the following non-permitted characters: 123!", ); - cy.get("#guest-name").should("have.value", "John Doe 123!"); - // Test 500 error cy.intercept("POST", "/api/v1/rooms/abc-def-123/start*", { statusCode: 500, @@ -2239,11 +2213,22 @@ describe("Rooms view meetings", function () { }); it("start meeting with access code", function () { + 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 = false; + room.data.record_attendance = true; + room.data.record = 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"); @@ -2264,34 +2249,7 @@ describe("Rooms view meetings", function () { cy.interceptRoomFilesRequest(); - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - 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.record_attendance = true; - room.data.record = 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#accessCode=123456789"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -2365,12 +2323,6 @@ describe("Rooms view meetings", function () { }, }); - cy.visit("/rooms/abc-def-123"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - cy.get("#access-code").type("123456789"); - cy.intercept("POST", "/api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -2392,7 +2344,7 @@ describe("Rooms view meetings", function () { }).as("roomRequest"); }); - cy.get('[data-test="room-login-button"]').click(); + cy.visit("/rooms/abc-def-123#accessCode=123456789"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -2537,7 +2489,7 @@ describe("Rooms view meetings", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR", ); cy.wait("@roomAuthRequest"); @@ -2663,6 +2615,8 @@ describe("Rooms view meetings", function () { }).as("roomRequest"); }); + cy.interceptRoomFilesRequest(); + cy.intercept("OPTIONS", "api/v1/rooms/abc-def-123/start", { statusCode: 200, body: { @@ -3065,6 +3019,8 @@ describe("Rooms view meetings", function () { }).as("roomRequest"); }); + cy.interceptRoomFilesRequest(); + // Test guests not allowed cy.intercept("OPTIONS", "api/v1/rooms/abc-def-123/start", { statusCode: 403, @@ -3230,6 +3186,7 @@ describe("Rooms view meetings", function () { ); cy.wait("@roomAuthRequest"); + cy.wait("@roomRequest"); // Test invalid_auth_token cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { @@ -3257,6 +3214,9 @@ describe("Rooms view meetings", function () { cy.get('[data-test="room-join-dialog"]').should("not.exist"); // Reload + cy.window().then((win) => { + win.sessionStorage.clear(); + }); cy.visit("/rooms/abc-def-123"); // Test missing permissions @@ -3267,6 +3227,8 @@ describe("Rooms view meetings", function () { }, }).as("preStartRequest"); + cy.wait("@roomRequest"); + // Try to start meeting cy.get('[data-test="room-start-button"]').click(); cy.wait("@preStartRequest"); diff --git a/tests/Frontend/e2e/RoomsViewMembers.cy.js b/tests/Frontend/e2e/RoomsViewMembers.cy.js index 93873acd8c..cda41b9e24 100644 --- a/tests/Frontend/e2e/RoomsViewMembers.cy.js +++ b/tests/Frontend/e2e/RoomsViewMembers.cy.js @@ -318,10 +318,23 @@ describe("Rooms view members", function () { // Check that room gets reloaded cy.wait("@roomRequest"); + // Enter guest name + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#participant-name").type("Max Doe"); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@checkParticipantNameRequest"); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + // Check that file tab is shown cy.wait("@roomFilesRequest"); cy.url().should("not.include", "#tab=members"); - cy.url().should("include", "/rooms/abc-def-123#tab=files"); // Check that error message is shown cy.checkToastMessage("app.flash.unauthenticated"); @@ -372,7 +385,7 @@ describe("Rooms view members", function () { cy.wait("@roomRequest"); // Check that access code overlay is shown - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); // Check that error message is shown cy.checkToastMessage("app.flash.unauthenticated"); diff --git a/tests/Frontend/e2e/RoomsViewPersonalizedLinks.cy.js b/tests/Frontend/e2e/RoomsViewPersonalizedLinks.cy.js index 23c4c59ff3..5abd802686 100644 --- a/tests/Frontend/e2e/RoomsViewPersonalizedLinks.cy.js +++ b/tests/Frontend/e2e/RoomsViewPersonalizedLinks.cy.js @@ -330,10 +330,24 @@ describe("Rooms view personalized links", function () { // Check that room gets reloaded cy.wait("@roomRequest"); + // Enter guest name + cy.get('[data-test="room-access-overlay"]').should("be.visible"); + cy.get("#participant-name").type("Max Doe"); + + cy.intercept("POST", "api/v1/participantName/check", { + statusCode: 204, + }).as("checkParticipantNameRequest"); + + cy.get('[data-test="room-login-button"]').click(); + + cy.wait("@checkParticipantNameRequest"); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + // Check that file tab is shown cy.wait("@roomFilesRequest"); + cy.url().should("not.include", "#tab=tokens"); - cy.url().should("include", "/rooms/abc-def-123#tab=files"); // Check that error message is shown cy.checkToastMessage("app.flash.unauthenticated"); @@ -384,7 +398,7 @@ describe("Rooms view personalized links", function () { cy.wait("@roomRequest"); // Check that access code overlay is shown - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); // Check that error message is shown cy.checkToastMessage("app.flash.unauthenticated"); diff --git a/tests/Frontend/e2e/RoomsViewPersonalizedLinksTokenActions.cy.js b/tests/Frontend/e2e/RoomsViewPersonalizedLinksTokenActions.cy.js index a685c680ce..1c099f2842 100644 --- a/tests/Frontend/e2e/RoomsViewPersonalizedLinksTokenActions.cy.js +++ b/tests/Frontend/e2e/RoomsViewPersonalizedLinksTokenActions.cy.js @@ -857,7 +857,7 @@ describe("Rooms view personalized links actions", function () { win.navigator.clipboard.readText().then((text) => { expect(text).to.eq( Cypress.config("baseUrl") + - "/rooms/abc-def-123/1ZKctHSaGd7qLDpFa0emXSjoVTkJHkiTm0xajVOXhHU9BA9CCZquf6sDZtAAEGgdO40neF5dXITbH0CxhKM5940eW988WiIKxC8R", + "/rooms/abc-def-123#personalizedLink=1ZKctHSaGd7qLDpFa0emXSjoVTkJHkiTm0xajVOXhHU9BA9CCZquf6sDZtAAEGgdO40neF5dXITbH0CxhKM5940eW988WiIKxC8R", ); }); }); diff --git a/tests/Frontend/e2e/RoomsViewRecordings.cy.js b/tests/Frontend/e2e/RoomsViewRecordings.cy.js index 743026d317..e7b17a9061 100644 --- a/tests/Frontend/e2e/RoomsViewRecordings.cy.js +++ b/tests/Frontend/e2e/RoomsViewRecordings.cy.js @@ -5,6 +5,8 @@ describe("Rooms view recordings", function () { cy.init(); cy.interceptRoomViewRequests(); cy.interceptRoomRecordingsRequests(); + + cy.setValidRememberedParticipantName("Laura Rivera"); }); it("load recordings", function () { @@ -310,11 +312,20 @@ describe("Rooms view recordings", function () { }); it("load recordings with access code", function () { + 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 = false; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { statusCode: 200, body: room, }).as("roomRequest"); @@ -332,32 +343,7 @@ describe("Rooms view recordings", function () { }).as("roomRecordingsRequest"); }); - cy.visit("/rooms/abc-def-123#tab=recordings"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - 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" }; - - 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#accessCode=123456789&tab=recordings"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -394,16 +380,6 @@ describe("Rooms view recordings", function () { }); it("load recordings with access code errors", function () { - cy.fixture("room.json").then((room) => { - room.data.owner = { id: 2, name: "Max Doe" }; - room.data.authenticated = false; - - cy.intercept("GET", "api/v1/rooms/abc-def-123", { - statusCode: 200, - body: room, - }).as("roomRequest"); - }); - cy.intercept("GET", "api/v1/rooms/abc-def-123/recordings*", { statusCode: 401, body: { @@ -411,12 +387,6 @@ describe("Rooms view recordings", function () { }, }).as("roomRecordingsRequest"); - cy.visit("/rooms/abc-def-123#tab=recordings"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - cy.get("#access-code").type("123456789"); - cy.intercept("POST", "api/v1/rooms/abc-def-123/auth", { statusCode: 201, body: { @@ -440,7 +410,7 @@ describe("Rooms view recordings", function () { "roomRequest", ); - cy.get('[data-test="room-login-button"]').click(); + cy.visit("/rooms/abc-def-123#accessCode=123456789&tab=recordings"); cy.wait("@roomAuthRequest"); cy.fixture("room.json").then((room2) => { @@ -574,7 +544,7 @@ describe("Rooms view recordings", function () { }); cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR#tab=recordings", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&tab=recordings", ); cy.wait("@roomAuthRequest"); @@ -647,7 +617,7 @@ describe("Rooms view recordings", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR#tab=recordings", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&tab=recordings", ); cy.wait("@roomAuthRequest").then(() => { diff --git a/tests/Frontend/e2e/RoomsViewRecordingsRecordingActions.cy.js b/tests/Frontend/e2e/RoomsViewRecordingsRecordingActions.cy.js index 34487ae805..eb2d407d91 100644 --- a/tests/Frontend/e2e/RoomsViewRecordingsRecordingActions.cy.js +++ b/tests/Frontend/e2e/RoomsViewRecordingsRecordingActions.cy.js @@ -5,6 +5,8 @@ describe("Rooms view recordings recording actions", function () { cy.init(); cy.interceptRoomViewRequests(); cy.interceptRoomRecordingsRequests(); + + cy.setValidRememberedParticipantName("Laura Rivera"); }); it("view recording", function () { @@ -69,11 +71,20 @@ describe("Rooms view recordings recording actions", function () { }); it("view recording with access code", function () { + 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 = false; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { statusCode: 200, body: room, }).as("roomRequest"); @@ -91,32 +102,7 @@ describe("Rooms view recordings recording actions", function () { }).as("roomRecordingsRequest"); }); - cy.visit("/rooms/abc-def-123#tab=recordings"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - 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" }; - - 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#accessCode=123456789&tab=recordings"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -172,11 +158,20 @@ describe("Rooms view recordings recording actions", function () { }); it("view recording with access code errors", function () { + 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 = false; - cy.intercept("GET", "api/v1/rooms/abc-def-123", { + cy.intercept("GET", "api/v1/rooms/abc-def-123*", { statusCode: 200, body: room, }).as("roomRequest"); @@ -194,32 +189,7 @@ describe("Rooms view recordings recording actions", function () { }).as("roomRecordingsRequest"); }); - cy.visit("/rooms/abc-def-123#tab=recordings"); - - // Type in access code to get access to the room - cy.wait("@roomRequest"); - 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" }; - - 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#accessCode=123456789&tab=recordings"); cy.wait("@roomAuthRequest"); cy.wait("@roomRequest"); @@ -336,7 +306,7 @@ describe("Rooms view recordings recording actions", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR#tab=recordings", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&tab=recordings", ); cy.wait("@roomAuthRequest"); @@ -428,7 +398,7 @@ describe("Rooms view recordings recording actions", function () { // Visit room with personalized link cy.visit( - "/rooms/abc-def-123/xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR#tab=recordings", + "/rooms/abc-def-123#personalizedLink=xWDCevVTcMys1ftzt3nFPgU56Wf32fopFWgAEBtklSkFU22z1ntA4fBHsHeMygMiOa9szJbNEfBAgEWSLNWg2gcF65PwPZ2ylPQR&tab=recordings", ); cy.wait("@roomAuthRequest"); @@ -612,6 +582,10 @@ describe("Rooms view recordings recording actions", function () { // Check that room and recordings are reloaded (because of changes in the room (current_user)) cy.wait("@reloadRoomRequest"); + cy.wait("@checkParticipantNameRequest"); + + cy.get('[data-test="room-access-overlay"]').should("not.exist"); + cy.wait("@roomRecordingsRequest"); // Check that recording list was updated again diff --git a/tests/Frontend/e2e/RoomsViewSettings.cy.js b/tests/Frontend/e2e/RoomsViewSettings.cy.js index 348b5c95f3..be80f07445 100644 --- a/tests/Frontend/e2e/RoomsViewSettings.cy.js +++ b/tests/Frontend/e2e/RoomsViewSettings.cy.js @@ -2202,7 +2202,7 @@ describe("Rooms view settings", function () { cy.contains("Laura Walter").should("be.visible"); // Check that access code overlay is shown - cy.get('[data-test="room-access-code-overlay"]').should("be.visible"); + cy.get('[data-test="room-access-overlay"]').should("be.visible"); }); it("transfer ownership errors", function () { diff --git a/tests/Frontend/e2e/UserProfile.cy.js b/tests/Frontend/e2e/UserProfile.cy.js index d99f298b0d..4a0e8225c7 100644 --- a/tests/Frontend/e2e/UserProfile.cy.js +++ b/tests/Frontend/e2e/UserProfile.cy.js @@ -63,8 +63,8 @@ describe("User Profile", function () { // Check that base tab is shown cy.get("#firstname").should("be.visible"); - // Check that invalid tab hash stays in the hash - cy.url().should("include", "/profile#tab=invalid"); + // Check that invalid tab hash is cleared + cy.url().should("not.include", "#tab=invalid"); }); it("open user profile errors", function () { diff --git a/tests/Frontend/fixtures/config.json b/tests/Frontend/fixtures/config.json index 74c9bf8782..d227fe5f76 100644 --- a/tests/Frontend/fixtures/config.json +++ b/tests/Frontend/fixtures/config.json @@ -32,7 +32,8 @@ "file_mimes": "pdf,doc,docx,xls,xlsx,ppt,pptx,txt,rtf,odt,ods,odp,odg,odc,odi,jpg,jpeg,png", "max_filesize": 30, "welcome_message_limit": 500, - "room_name_limit": 50 + "room_name_limit": 50, + "allowed_name_characters": "\\w ,.'\\-+\\/&()" }, "user": { "password_change_allowed": true diff --git a/tests/Frontend/support/commands/generalCommands.js b/tests/Frontend/support/commands/generalCommands.js index ba8d4d3d8a..54fc9047ab 100644 --- a/tests/Frontend/support/commands/generalCommands.js +++ b/tests/Frontend/support/commands/generalCommands.js @@ -60,3 +60,25 @@ Cypress.Commands.add("checkToastMessage", (messages) => { cy.wrap($toast, { log: false }).should("not.exist"); }); }); + +/** + * Set the hash without triggering a hashchange event and reload the page. + * @memberof cy + * @method reloadWithHash + * @param {string} hash + * @returns {Cypress.Chainable