-
Notifications
You must be signed in to change notification settings - Fork 13.7k
feat: add rooms.join endpoint for all room types #40996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
661be04
feat: add rooms.join endpoint for all room types
ggazzo 2aabed4
chore: point joinRoom deprecation to rooms.join
ggazzo 309584d
test: add e2e coverage for rooms.join endpoint
ggazzo 391fcd6
test(e2e): add Playwright coverage for rooms.join
ggazzo 12cac3e
test(e2e): cover joining a discussion inside a private channel
ggazzo 3af6a9b
test(e2e): open private discussion via /group route and preview composer
ggazzo a11fbf4
test(e2e): remove test.only from private discussion test
ggazzo 2cb157b
fix(client): refresh room view after joining
ggazzo b52aead
Update apps/meteor/tests/e2e/rooms-join.spec.ts
ggazzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixed the "not subscribed" room screen not updating after joining a room. The join mutation invalidated a stale React Query key that no longer matched the open-room query, so the UI kept showing the join prompt until a manual page refresh. It now invalidates the correct `rooms` reference key, so the room opens immediately after joining. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@rocket.chat/meteor": minor | ||
| "@rocket.chat/rest-typings": minor | ||
| --- | ||
|
|
||
| Added a new `rooms.join` REST endpoint that lets a user join any room type, replicating the behavior of the deprecated `joinRoom` DDP method. Unlike `channels.join`, it resolves all room types through the shared `Room.join` service (access checks, join codes, federation and omnichannel rules). The client now uses `rooms.join` instead of `channels.join`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| import { faker } from '@faker-js/faker'; | ||
| import type { IRoom } from '@rocket.chat/core-typings'; | ||
|
|
||
| import { Users } from './fixtures/userStates'; | ||
| import { HomeChannel } from './page-objects'; | ||
| import { | ||
| createTargetChannel, | ||
| createTargetDiscussion, | ||
| createTargetGroupAndReturnFullRoom, | ||
| deleteRoom, | ||
| sendTargetChannelMessage, | ||
| } from './utils'; | ||
| import { test, expect } from './utils/test'; | ||
|
|
||
| test.describe.serial('Join rooms', () => { | ||
| test.use({ storageState: Users.user1.state }); | ||
|
|
||
| test.describe('public channels without preview-c-room', () => { | ||
| let targetChannel: string; | ||
| let poHomeChannel: HomeChannel; | ||
|
|
||
| test.beforeEach(async ({ api }) => { | ||
| targetChannel = await createTargetChannel(api); | ||
| await sendTargetChannelMessage(api, targetChannel, { msg: 'message from a channel the user has not joined' }); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeChannel(page); | ||
| await page.goto(`/channel/${targetChannel}`); | ||
| }); | ||
|
|
||
| test.afterEach(async ({ api }) => { | ||
| await api.post('/channels.delete', { roomName: targetChannel }); | ||
| }); | ||
|
|
||
| test.beforeAll(async ({ api }) => { | ||
| // restrict preview to admin so a regular user lands on the "not subscribed" | ||
| // screen, whose "Join channel" button drives /v1/rooms.join via useJoinRoom | ||
| await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin'] }] }); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| await api.post('/permissions.update', { permissions: [{ _id: 'preview-c-room', roles: ['admin', 'user', 'anonymous'] }] }); | ||
| }); | ||
|
|
||
| test('should let a non-member join a public channel', async () => { | ||
| await expect(poHomeChannel.btnJoinChannel).toBeVisible(); | ||
| await poHomeChannel.btnJoinChannel.click(); | ||
| await expect(poHomeChannel.btnJoinChannel).not.toBeVisible(); | ||
| await expect(poHomeChannel.composer.inputMessage).toBeEnabled(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('public channel with preview-c-room', () => { | ||
| let targetChannel: string; | ||
| let poHomeChannel: HomeChannel; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeChannel(page); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ api }) => { | ||
| targetChannel = await createTargetChannel(api); | ||
| await sendTargetChannelMessage(api, targetChannel, { msg: 'message from a channel the user has not joined' }); | ||
| }); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeChannel(page); | ||
| await page.goto(`/channel/${targetChannel}`); | ||
| }); | ||
|
|
||
| test.afterEach(async ({ api }) => { | ||
| await api.post('/channels.delete', { roomName: targetChannel }); | ||
| }); | ||
|
|
||
| test('should let a non-member join a public channel', async () => { | ||
| await expect(poHomeChannel.composer.btnJoinRoom).toBeVisible(); | ||
| await poHomeChannel.composer.btnJoinRoom.click(); | ||
| await expect(poHomeChannel.composer.btnJoinRoom).not.toBeVisible(); | ||
| await expect(poHomeChannel.composer.inputMessage).toBeEnabled(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('discussion with preview-c-room', () => { | ||
| test.use({ storageState: Users.user1.state }); | ||
|
|
||
| let poHomeChannel: HomeChannel; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeChannel(page); | ||
| }); | ||
|
|
||
| let discussion: Record<string, string>; | ||
|
|
||
| test.beforeAll(async ({ api }) => { | ||
| discussion = await createTargetDiscussion(api); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| await deleteRoom(api, discussion._id); | ||
| }); | ||
|
|
||
| test('should let a non-member join a discussion', async ({ page }) => { | ||
| await page.goto(`/channel/${discussion.name}`); | ||
|
|
||
| await expect(poHomeChannel.composer.btnJoinRoom).toBeVisible(); | ||
|
|
||
| await poHomeChannel.composer.btnJoinRoom.click(); | ||
|
|
||
| await expect(poHomeChannel.composer.btnJoinRoom).not.toBeVisible(); | ||
| await expect(poHomeChannel.composer.inputMessage).toBeEnabled(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('discussion inside a private channel', () => { | ||
| let poHomeChannel: HomeChannel; | ||
| let group: IRoom; | ||
| let discussion: Record<string, string>; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| poHomeChannel = new HomeChannel(page); | ||
| }); | ||
|
|
||
| test.beforeAll(async ({ api }) => { | ||
| // The user is a member of the private parent but NOT of the discussion. | ||
| // The discussion is type `p` and its access is inherited from the parent, | ||
| // so `channels.join` could not resolve it but `rooms.join` can. | ||
| ({ group } = await createTargetGroupAndReturnFullRoom(api, { members: [Users.user1.data.username] })); | ||
| const response = await api.post('/rooms.createDiscussion', { prid: group._id, t_name: faker.string.uuid() }); | ||
| ({ discussion } = await response.json()); | ||
| }); | ||
|
|
||
| test.afterAll(async ({ api }) => { | ||
| await deleteRoom(api, discussion._id); | ||
| await api.post('/groups.delete', { roomId: group._id }); | ||
| }); | ||
|
|
||
| test('should let a parent member join a discussion in a private channel', async ({ page }) => { | ||
| await page.goto(`/group/${discussion.name}`); | ||
|
|
||
| await expect(poHomeChannel.composer.btnJoinRoom).toBeVisible(); | ||
| await poHomeChannel.composer.btnJoinRoom.click(); | ||
|
|
||
| await expect(poHomeChannel.composer.btnJoinRoom).not.toBeVisible(); | ||
| await expect(poHomeChannel.composer.inputMessage).toBeEnabled(); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.