Skip to content

Commit

Permalink
fix: Monitors dissapearing from Unit upon edit (#32393)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored May 17, 2024
1 parent 0d93307 commit 3cbbecd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
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
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/);
});

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

0 comments on commit 3cbbecd

Please sign in to comment.