fix: Active toggle now reflects current active status (#35698)

Co-authored-by: Aleksander Nicacio da Silva <aleksander.silva@rocket.chat>
pull/35717/head
Lucas Pelegrino 9 months ago committed by GitHub
parent dc6cf3ef5f
commit f72fa30a16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/rotten-candles-train.md
  2. 2
      apps/meteor/client/views/omnichannel/businessHours/EditBusinessHours.tsx
  3. 54
      apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts
  4. 4
      apps/meteor/tests/e2e/page-objects/omnichannel-business-hours.ts

@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---
Fixes the "Enabled" toggle always being displayed as active when editing a business hour.

@ -25,7 +25,7 @@ const getInitialData = (businessHourData: Serialized<ILivechatBusinessHour> | un
open,
})),
departmentsToApplyBusinessHour: '',
active: businessHourData?.active || true,
active: businessHourData?.active ?? true,
departments: businessHourData?.departments?.map(({ _id, name }) => ({ value: _id, label: name })) || [],
});

@ -19,6 +19,9 @@ test.describe('OC - Business Hours', () => {
let department2: Awaited<ReturnType<typeof createDepartment>>;
let agent: Awaited<ReturnType<typeof createAgent>>;
const BHid = faker.string.uuid();
const BHName = 'TEST Business Hours';
test.beforeAll(async ({ api }) => {
department = await createDepartment(api);
department2 = await createDepartment(api);
@ -40,8 +43,6 @@ test.describe('OC - Business Hours', () => {
});
test('OC - Manage Business Hours - Create Business Hours', async ({ page }) => {
const BHName = faker.string.uuid();
await page.goto('/omnichannel');
await poOmnichannelBusinessHours.sidenav.linkBusinessHours.click();
@ -86,11 +87,9 @@ test.describe('OC - Business Hours', () => {
});
test('OC - Business hours - Edit BH departments', async ({ api, page }) => {
const BHName = faker.string.uuid();
await test.step('expect to create new businessHours', async () => {
const createBH = await createBusinessHour(api, {
id: '33',
id: BHid,
name: BHName,
departments: [department.data._id],
});
@ -136,4 +135,49 @@ test.describe('OC - Business Hours', () => {
await expect(poOmnichannelBusinessHours.confirmDeleteModal).not.toBeVisible();
});
});
test('OC - Business hours - Toggle BH active status', async ({ api, page }) => {
await test.step('expect to create new businessHours', async () => {
const createBH = await createBusinessHour(api, {
id: BHid,
name: BHName,
departments: [department.data._id],
});
expect(createBH.status()).toBe(200);
});
await page.goto('/omnichannel');
await poOmnichannelBusinessHours.sidenav.linkBusinessHours.click();
await test.step('expect to disable business hours', async () => {
await poOmnichannelBusinessHours.sidenav.linkBusinessHours.click();
await poOmnichannelBusinessHours.search(BHName);
await poOmnichannelBusinessHours.findRowByName(BHName).click();
await poOmnichannelBusinessHours.getCheckboxByLabel('Enabled').click();
await expect(poOmnichannelBusinessHours.getCheckboxByLabel('Enabled')).not.toBeChecked();
await poOmnichannelBusinessHours.btnSave.click();
});
await test.step('expect to enable business hours', async () => {
await poOmnichannelBusinessHours.sidenav.linkBusinessHours.click();
await poOmnichannelBusinessHours.search(BHName);
await poOmnichannelBusinessHours.findRowByName(BHName).click();
await poOmnichannelBusinessHours.getCheckboxByLabel('Enabled').click();
await expect(poOmnichannelBusinessHours.getCheckboxByLabel('Enabled')).toBeChecked();
await poOmnichannelBusinessHours.btnSave.click();
});
await test.step('expect delete business hours', async () => {
await poOmnichannelBusinessHours.btnDeleteByName(BHName).click();
await expect(poOmnichannelBusinessHours.confirmDeleteModal).toBeVisible();
await poOmnichannelBusinessHours.btnConfirmDeleteModal.click();
});
});
});

@ -51,6 +51,10 @@ export class OmnichannelBusinessHours extends OmnichannelAdministration {
return this.confirmDeleteModal.locator('role=button[name="Delete"]');
}
getCheckboxByLabel(name: string): Locator {
return this.page.locator('label', { has: this.page.getByRole('checkbox', { name }) });
}
private selectOption(name: string): Locator {
return this.page.locator(`[role=option][value="${name}"]`);
}

Loading…
Cancel
Save