Skip to content
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/rotten-candles-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes the "Enabled" toggle always being displayed as active when editing a business hour.
Original file line number Diff line number Diff line change
Expand Up @@ -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 })) || [],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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],
});
Expand Down Expand Up @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]`);
}
Expand Down
Loading