Skip to content
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

fix: Monitors dissapearing from Unit upon edit #32393

Merged
merged 6 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-rocks-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed an issue causing monitors to dissapear from a saved unit every time a user saved the item. This was caused by the UI not sending the correct _id of the monitors that were already saved, and this caused the Backend to ignore them and remove from the list.
4 changes: 2 additions & 2 deletions apps/meteor/ee/client/omnichannel/units/UnitEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ const UnitEdit = ({ unitData, unitMonitors, unitDepartments }: UnitEditProps) =>

const currUnitMonitors = useMemo(
() =>
unitMonitors?.map(({ _id, username }) => ({
value: _id,
unitMonitors?.map(({ monitorId, username }) => ({
value: monitorId,
label: username,
})) || [],
[unitMonitors],
Expand Down
35 changes: 33 additions & 2 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-units.spec.ts
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test.describe('OC - Manage Units', () => {

let monitor: Awaited<ReturnType<typeof createMonitor>>;

let monitor2: Awaited<ReturnType<typeof createMonitor>>;

test.beforeAll(async ({ api }) => {
department = await createDepartment(api);
department2 = await createDepartment(api);
Expand All @@ -35,12 +37,14 @@ test.describe('OC - Manage Units', () => {

test.beforeAll(async ({ api }) => {
monitor = await createMonitor(api, 'user2');
monitor2 = await createMonitor(api, 'user3');
});

test.afterAll(async () => {
await department.delete();
await department2.delete();
await monitor.delete();
await monitor2.delete();
await agent.delete();
});

Expand Down Expand Up @@ -101,8 +105,9 @@ test.describe('OC - Manage Units', () => {
return newUnit;
});

await page.reload();

await page.goto('/omnichannel');
await poOmnichannelUnits.sidenav.linkUnits.click();

await test.step('expect to edit unit', async () => {
await poOmnichannelUnits.search(unit.name);
await poOmnichannelUnits.findRowByName(unit.name).click();
Expand All @@ -117,6 +122,32 @@ test.describe('OC - Manage Units', () => {
await expect(poOmnichannelUnits.findRowByName(editedUnitName)).toBeVisible();
});

await test.step('expect to add another monitor to list', async () => {
await poOmnichannelUnits.findRowByName(editedUnitName).click();
await poOmnichannelUnits.selectMonitor('user3');
await poOmnichannelUnits.btnSave.click();
});

await test.step('expect unit to have been edited with 2 monitors', async () => {
await poOmnichannelUnits.search(editedUnitName);
await poOmnichannelUnits.findRowByName(editedUnitName).click();

await expect(poOmnichannelUnits.inputMonitors).toHaveText(/user2/);
await expect(poOmnichannelUnits.inputMonitors).toHaveText(/user3/);
});

KevLehman marked this conversation as resolved.
Show resolved Hide resolved
await test.step('expect unit to remove one of the two monitors', async () => {
await poOmnichannelUnits.search(editedUnitName);
await poOmnichannelUnits.findRowByName(editedUnitName).click();
await poOmnichannelUnits.selectMonitor('user2');
await poOmnichannelUnits.btnSave.click();

await poOmnichannelUnits.search(editedUnitName);
await poOmnichannelUnits.findRowByName(editedUnitName).click();
await expect(poOmnichannelUnits.inputMonitors).toHaveText(/user3/);
await expect(poOmnichannelUnits.inputMonitors).not.toHaveText(/user2/);
});

await test.step('expect to delete unit', async () => {
await poOmnichannelUnits.findRowByName(editedUnitName).click();
await expect(poOmnichannelUnits.contextualBar).toBeVisible();
Expand Down
Loading