Skip to content

Commit

Permalink
test: re-enable contact center skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Nov 21, 2024
1 parent 7c68607 commit 1711fc2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 105 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/client/NavBarV2/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const NavBar = () => {
<NavBarGroup role='toolbar' ref={omnichannelToolbarRef} {...omnichannelToolbarProps}>
{showOmnichannelQueueLink && <NavBarItemOmnichannelQueue title={t('Queue')} />}
{isCallReady && <NavBarItemOmniChannelCallDialPad />}
<NavBarItemOmnichannelContact title={t('Contacts')} />
<NavBarItemOmnichannelContact title={t('Contact_Center')} />
{isCallEnabled && <NavBarItemOmnichannelCallToggle />}
<NavBarItemOmnichannelLivechatToggle />
</NavBarGroup>
Expand Down
136 changes: 40 additions & 96 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,20 @@ const URL = {
const ERROR = {
nameRequired: 'Name required',
invalidEmail: 'Invalid email address',
existingEmail: 'Email already exists',
existingPhone: 'Phone already exists',
emailRequired: 'Email required',
phoneRequired: 'Phone required',
};

test.use({ storageState: Users.admin.state });

// TODO: this will need to be refactored
test.describe.skip('Omnichannel Contact Center', () => {
test.describe('Omnichannel Contact Center', () => {
let poContacts: OmnichannelContacts;
let poOmniSection: OmnichannelSection;

test.beforeAll(async ({ api }) => {
// Add a contact
const { id: _, ...data } = EXISTING_CONTACT;
await api.post('/omnichannel/contact', data);
await api.post('/omnichannel/contacts', data);

if (IS_EE) {
await api.post('/livechat/custom.field', NEW_CUSTOM_FIELD);
Expand All @@ -81,11 +80,11 @@ test.describe.skip('Omnichannel Contact Center', () => {

test.afterEach(async ({ api }) => {
await api
.get('/omnichannel/contact.search', { phone: NEW_CONTACT.phone })
.get('/omnichannel/contacts.search', { searchText: NEW_CONTACT.phone })
.then((res) => res.json())
.then((res) => {
NEW_CONTACT.token = res.contact?.token;
NEW_CONTACT.id = res.contact?._id;
NEW_CONTACT.token = res.contacts?.[0]?.token;
NEW_CONTACT.id = res.contacts?.[0]?._id;
});
});

Expand All @@ -110,69 +109,45 @@ test.describe.skip('Omnichannel Contact Center', () => {
await poContacts.btnNewContact.click();
await page.waitForURL(URL.newContact);
await expect(poContacts.newContact.inputName).toBeVisible();
await expect(poContacts.newContact.btnSave).toBeDisabled();
});

await test.step('input name', async () => {
await poContacts.newContact.inputName.type(NEW_CONTACT.name);
await poContacts.newContact.inputName.fill(NEW_CONTACT.name);
});

await test.step('validate email format', async () => {
await poContacts.newContact.inputEmail.type('invalidemail');
await expect(poContacts.newContact.errorMessage(ERROR.invalidEmail)).toBeVisible();
await poContacts.newContact.btnAddEmail.click();
await poContacts.newContact.inputEmail.fill('invalidemail');
await page.keyboard.press('Tab');
await expect(poContacts.newContact.getErrorMessage(ERROR.invalidEmail)).toBeVisible();
});

await test.step('input existing email', async () => {
await poContacts.newContact.inputEmail.selectText();
await poContacts.newContact.inputEmail.type(EXISTING_CONTACT.email);
await expect(poContacts.newContact.errorMessage(ERROR.invalidEmail)).not.toBeVisible();
await expect(poContacts.newContact.errorMessage(ERROR.existingEmail)).not.toBeVisible();
});

await test.step('input existing phone ', async () => {
await poContacts.newContact.inputPhone.selectText();
await poContacts.newContact.inputPhone.type(EXISTING_CONTACT.phone);
await expect(poContacts.newContact.errorMessage(ERROR.existingPhone)).not.toBeVisible();
});

await test.step('run async validations ', async () => {
await expect(poContacts.newContact.btnSave).toBeEnabled();
await poContacts.newContact.btnSave.click();

await expect(poContacts.newContact.errorMessage(ERROR.existingEmail)).toBeVisible();
await expect(poContacts.newContact.btnSave).toBeDisabled();

await expect(poContacts.newContact.errorMessage(ERROR.existingPhone)).toBeVisible();
await expect(poContacts.newContact.btnSave).toBeDisabled();
});

await test.step('input phone ', async () => {
await poContacts.newContact.inputPhone.selectText();
await poContacts.newContact.inputPhone.type(NEW_CONTACT.phone);
await expect(poContacts.newContact.errorMessage(ERROR.existingPhone)).not.toBeVisible();
await test.step('input email', async () => {
await poContacts.newContact.inputEmail.fill(NEW_CONTACT.email);
await page.keyboard.press('Tab');
await expect(poContacts.newContact.getErrorMessage(ERROR.invalidEmail)).not.toBeVisible();
await expect(poContacts.newContact.getErrorMessage(ERROR.emailRequired)).not.toBeVisible();
});

await test.step('input email', async () => {
await poContacts.newContact.inputEmail.selectText();
await poContacts.newContact.inputEmail.type(NEW_CONTACT.email);
await expect(poContacts.newContact.errorMessage(ERROR.invalidEmail)).not.toBeVisible();
await expect(poContacts.newContact.errorMessage(ERROR.existingEmail)).not.toBeVisible();
await test.step('input phone', async () => {
await poContacts.newContact.btnAddPhone.click();
await poContacts.newContact.inputPhone.fill(NEW_CONTACT.phone);
await page.keyboard.press('Tab');
await expect(poContacts.newContact.getErrorMessage(ERROR.phoneRequired)).not.toBeVisible();
});

await test.step('save new contact ', async () => {
await test.step('save new contact', async () => {
await expect(poContacts.newContact.btnSave).toBeEnabled();
await poContacts.newContact.btnSave.click();
await page.waitForURL(URL.contactCenter);
await expect(poContacts.toastSuccess).toBeVisible();

await poContacts.inputSearch.type(NEW_CONTACT.name);
await poContacts.inputSearch.fill(NEW_CONTACT.name);
await expect(poContacts.findRowByName(NEW_CONTACT.name)).toBeVisible();
});
});

test('Edit new contact', async ({ page }) => {
await test.step('search contact and open contextual bar', async () => {
await poContacts.inputSearch.type(NEW_CONTACT.name);
await poContacts.inputSearch.fill(NEW_CONTACT.name);
const row = poContacts.findRowByName(NEW_CONTACT.name);
await expect(row).toBeVisible();
await row.click();
Expand All @@ -198,69 +173,38 @@ test.describe.skip('Omnichannel Contact Center', () => {
});

await test.step('validate email format', async () => {
await poContacts.contactInfo.inputEmail.selectText();
await poContacts.contactInfo.inputEmail.type('invalidemail');
await expect(poContacts.contactInfo.errorMessage(ERROR.invalidEmail)).toBeVisible();
});

await test.step('input existing email', async () => {
await poContacts.contactInfo.inputEmail.selectText();
await poContacts.contactInfo.inputEmail.type(EXISTING_CONTACT.email);
await expect(poContacts.contactInfo.errorMessage(ERROR.invalidEmail)).not.toBeVisible();
await expect(poContacts.contactInfo.errorMessage(ERROR.existingEmail)).not.toBeVisible();
await expect(poContacts.contactInfo.btnSave).toBeEnabled();
});

await test.step('input existing phone ', async () => {
await poContacts.contactInfo.inputPhone.selectText();
await poContacts.contactInfo.inputPhone.type(EXISTING_CONTACT.phone);
await expect(poContacts.contactInfo.errorMessage(ERROR.existingPhone)).not.toBeVisible();
await expect(poContacts.contactInfo.btnSave).toBeEnabled();
await poContacts.contactInfo.inputEmail.fill('invalidemail');
await page.keyboard.press('Tab');
await expect(poContacts.contactInfo.getErrorMessage(ERROR.invalidEmail)).toBeVisible();
});

await test.step('validate name is required', async () => {
await poContacts.contactInfo.inputName.selectText();
await poContacts.contactInfo.inputName.type(' ');
await expect(poContacts.contactInfo.errorMessage(ERROR.nameRequired)).toBeVisible();

await expect(poContacts.contactInfo.btnSave).not.toBeEnabled();
await poContacts.contactInfo.inputName.clear();
await page.keyboard.press('Tab');
await expect(poContacts.contactInfo.getErrorMessage(ERROR.nameRequired)).toBeVisible();
});

await test.step('edit name', async () => {
await poContacts.contactInfo.inputName.selectText();
await poContacts.contactInfo.inputName.type(EDIT_CONTACT.name);
});

await test.step('run async validations ', async () => {
await expect(poContacts.newContact.btnSave).toBeEnabled();
await poContacts.newContact.btnSave.click();

await expect(poContacts.newContact.errorMessage(ERROR.existingEmail)).toBeVisible();
await expect(poContacts.newContact.btnSave).toBeDisabled();

await expect(poContacts.newContact.errorMessage(ERROR.existingPhone)).toBeVisible();
await expect(poContacts.newContact.btnSave).toBeDisabled();
await poContacts.contactInfo.inputName.fill(EDIT_CONTACT.name);
});

await test.step('input phone ', async () => {
await poContacts.newContact.inputPhone.selectText();
await poContacts.newContact.inputPhone.type(EDIT_CONTACT.phone);
await expect(poContacts.newContact.errorMessage(ERROR.existingPhone)).not.toBeVisible();
await poContacts.newContact.inputPhone.fill(EDIT_CONTACT.phone);
await page.keyboard.press('Tab');
await expect(poContacts.newContact.getErrorMessage(ERROR.phoneRequired)).not.toBeVisible();
});

await test.step('input email', async () => {
await poContacts.newContact.inputEmail.selectText();
await poContacts.newContact.inputEmail.type(EDIT_CONTACT.email);
await expect(poContacts.newContact.errorMessage(ERROR.invalidEmail)).not.toBeVisible();
await expect(poContacts.newContact.errorMessage(ERROR.existingEmail)).not.toBeVisible();
await poContacts.newContact.inputEmail.fill(EDIT_CONTACT.email);
await page.keyboard.press('Tab');
await expect(poContacts.newContact.getErrorMessage(ERROR.invalidEmail)).not.toBeVisible();
await expect(poContacts.newContact.getErrorMessage(ERROR.emailRequired)).not.toBeVisible();
});

await test.step('save new contact ', async () => {
await poContacts.contactInfo.btnSave.click();
await expect(poContacts.toastSuccess).toBeVisible();

await poContacts.inputSearch.selectText();
await poContacts.inputSearch.type(EDIT_CONTACT.name);
await poContacts.inputSearch.fill(EDIT_CONTACT.name);
await expect(poContacts.findRowByName(EDIT_CONTACT.name)).toBeVisible();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ export class OmnichannelContacts {
findRowByName(contactName: string) {
return this.page.locator(`td >> text="${contactName}"`);
}

get toastSuccess(): Locator {
return this.page.locator('.rcx-toastbar.rcx-toastbar--success');
}
}
16 changes: 12 additions & 4 deletions apps/meteor/tests/e2e/page-objects/omnichannel-manage-contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export class OmnichannelManageContact {
}

get inputEmail(): Locator {
return this.page.locator('input[name=email]');
return this.page.locator('input[name="emails.0.address"]');
}

get inputPhone(): Locator {
return this.page.locator('input[name=phone]');
return this.page.locator('input[name="phones.0.phoneNumber"]');
}

get inputContactManager(): Locator {
Expand All @@ -31,7 +31,15 @@ export class OmnichannelManageContact {
return this.page.locator('button >> text="Cancel"');
}

errorMessage(message: string): Locator {
return this.page.locator(`.rcx-field__error >> text="${message}"`);
get btnAddEmail(): Locator {
return this.page.locator('role=button[name="Add email"]');
}

get btnAddPhone(): Locator {
return this.page.locator('role=button[name="Add phone"]');
}

getErrorMessage(message: string): Locator {
return this.page.locator(`role=alert >> text="${message}"`);
}
}

0 comments on commit 1711fc2

Please sign in to comment.