Skip to content

Commit

Permalink
regression: error when archiving rooms through the admin panel (Rocke…
Browse files Browse the repository at this point in the history
…tChat#31503)

Co-authored-by: Henrique Guimarães Ribeiro <[email protected]>
Co-authored-by: Douglas Fabris <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2024
1 parent b681d7f commit 1e441d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apps/meteor/client/views/admin/rooms/EditRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
FieldError,
} from '@rocket.chat/fuselage';
import { useMutableCallback, useUniqueId } from '@rocket.chat/fuselage-hooks';
import { useEndpoint, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts';
import { useEndpoint, useRouter, useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';
import { useForm, Controller } from 'react-hook-form';

Expand Down Expand Up @@ -64,6 +64,7 @@ const getInitialValues = (room: Pick<IRoom, RoomAdminFieldsType>): EditRoomFormV

const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {
const t = useTranslation();
const router = useRouter();
const dispatchToastMessage = useToastMessageDispatch();

const {
Expand Down Expand Up @@ -97,6 +98,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {

const handleUpdateRoomData = useMutableCallback(async ({ isDefault, roomName, favorite, ...formData }) => {
const data = getDirtyFields(formData, dirtyFields);
delete data.archived;

try {
await saveAction({
Expand All @@ -109,6 +111,7 @@ const EditRoom = ({ room, onChange, onDelete }: EditRoomProps) => {

dispatchToastMessage({ type: 'success', message: t('Room_updated_successfully') });
onChange();
router.navigate('/admin/rooms');
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/tests/e2e/administration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test.describe.parallel('administration', () => {
await page.goto('/admin/rooms');
});

test('expect find "general" channel', async ({ page }) => {
test('should find "general" channel', async ({ page }) => {
await poAdmin.inputSearchRooms.type('general');
await page.waitForSelector('[qa-room-id="GENERAL"]');
});
Expand All @@ -77,7 +77,16 @@ test.describe.parallel('administration', () => {
await poAdmin.btnSave.click();
await expect(poAdmin.getRoomRow(targetChannel)).toContainText('Private Channel');
});


test('should archive target channel', async () => {
await poAdmin.inputSearchRooms.type(targetChannel);
await poAdmin.getRoomRow(targetChannel).click();
await poAdmin.archivedLabel.click();
await poAdmin.btnSave.click();

await poAdmin.getRoomRow(targetChannel).click();
await expect(poAdmin.archivedInput).toBeChecked();
});
});

test.describe('Permissions', () => {
Expand Down
8 changes: 8 additions & 0 deletions apps/meteor/tests/e2e/page-objects/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export class Admin {
return this.page.locator(`label >> text=Private`);
}

get archivedLabel(): Locator {
return this.page.locator('label >> text=Archived');
}

get archivedInput(): Locator {
return this.page.locator('input[name="archived"]');
}

get inputSearchUsers(): Locator {
return this.page.locator('input[placeholder="Search Users"]');
}
Expand Down

0 comments on commit 1e441d0

Please sign in to comment.