diff --git a/.changeset/pink-ants-sing.md b/.changeset/pink-ants-sing.md
new file mode 100644
index 000000000000..7b4841a11561
--- /dev/null
+++ b/.changeset/pink-ants-sing.md
@@ -0,0 +1,6 @@
+---
+"@rocket.chat/meteor": patch
+---
+
+Fixed a UI issue that allowed a user to "mark" a room as favorite even when a room was not default. The Back-End was correctly ignoring the `favorite` property from being updated when the room was not default, but the UI still allowed users to try.
+As UI allowed but changes were not saved, this gave the impression that the function was not working.
diff --git a/apps/meteor/client/views/admin/rooms/EditRoom.tsx b/apps/meteor/client/views/admin/rooms/EditRoom.tsx
index 1522f4694160..cc165bca215b 100644
--- a/apps/meteor/client/views/admin/rooms/EditRoom.tsx
+++ b/apps/meteor/client/views/admin/rooms/EditRoom.tsx
@@ -86,7 +86,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {
canViewReactWhenReadOnly,
} = useEditAdminRoomPermissions(room);
- const { roomType, readOnly, archived } = watch();
+ const { roomType, readOnly, archived, isDefault } = watch();
const changeArchiving = archived !== !!room.archived;
@@ -324,7 +324,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {
name='favorite'
control={control}
render={({ field: { value, ...field } }) => (
-
+
)}
/>
diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts
index dcfb85373186..23d9d5214aaf 100644
--- a/apps/meteor/tests/e2e/administration.spec.ts
+++ b/apps/meteor/tests/e2e/administration.spec.ts
@@ -123,6 +123,21 @@ test.describe.parallel('administration', () => {
await poAdmin.getRoomRow(targetChannel).click();
await expect(poAdmin.favoriteInput).toBeChecked();
});
+
+ test('should see favorite switch disabled when default is not true', async () => {
+ await poAdmin.inputSearchRooms.type(targetChannel);
+ await poAdmin.getRoomRow(targetChannel).click();
+ await poAdmin.defaultLabel.click();
+
+ await expect(poAdmin.favoriteInput).toBeDisabled();
+ });
+
+ test('should see favorite switch enabled when default is true', async () => {
+ await poAdmin.inputSearchRooms.type(targetChannel);
+ await poAdmin.getRoomRow(targetChannel).click();
+
+ await expect(poAdmin.favoriteInput).toBeEnabled();
+ });
});
});
diff --git a/apps/meteor/tests/end-to-end/api/09-rooms.js b/apps/meteor/tests/end-to-end/api/09-rooms.js
index e60cf8c1f6b4..92b73f34557e 100644
--- a/apps/meteor/tests/end-to-end/api/09-rooms.js
+++ b/apps/meteor/tests/end-to-end/api/09-rooms.js
@@ -1742,7 +1742,7 @@ describe('[Rooms]', function () {
});
});
- describe('/rooms.saveRoomSettings', () => {
+ describe('rooms.saveRoomSettings', () => {
let testChannel;
const randomString = `randomString${Date.now()}`;
let discussion;
@@ -1847,5 +1847,64 @@ describe('[Rooms]', function () {
expect(res.body.room).to.have.property('fname', newDiscussionName);
});
});
+
+ it('should mark a room as favorite', async () => {
+ await request
+ .post(api('rooms.saveRoomSettings'))
+ .set(credentials)
+ .send({
+ rid: testChannel._id,
+ favorite: {
+ favorite: true,
+ defaultValue: true,
+ },
+ })
+ .expect('Content-Type', 'application/json')
+ .expect(200);
+
+ await request
+ .get(api('rooms.info'))
+ .set(credentials)
+ .query({
+ roomId: testChannel._id,
+ })
+ .expect(200)
+ .expect((res) => {
+ expect(res.body).to.have.property('success', true);
+ expect(res.body).to.have.property('room').and.to.be.an('object');
+
+ expect(res.body.room).to.have.property('_id', testChannel._id);
+ expect(res.body.room).to.have.property('favorite', true);
+ });
+ });
+ it('should not mark a room as favorite when room is not a default room', async () => {
+ await request
+ .post(api('rooms.saveRoomSettings'))
+ .set(credentials)
+ .send({
+ rid: testChannel._id,
+ favorite: {
+ favorite: true,
+ defaultValue: false,
+ },
+ })
+ .expect('Content-Type', 'application/json')
+ .expect(200);
+
+ await request
+ .get(api('rooms.info'))
+ .set(credentials)
+ .query({
+ roomId: testChannel._id,
+ })
+ .expect(200)
+ .expect((res) => {
+ expect(res.body).to.have.property('success', true);
+ expect(res.body).to.have.property('room').and.to.be.an('object');
+
+ expect(res.body.room).to.have.property('_id', testChannel._id);
+ expect(res.body.room).to.not.have.property('favorite');
+ });
+ });
});
});