Skip to content

Commit

Permalink
test: Flaky "expect add "user1" as monitor" test (#32226)
Browse files Browse the repository at this point in the history
Co-authored-by: Tasso Evangelista <[email protected]>
  • Loading branch information
dougfabris and tassoevan authored Apr 17, 2024
1 parent 7f3b17b commit b3b93f0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 35 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/client/components/FilterByText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const isFilterByTextPropsWithButton = (props: any): props is FilterByTextPropsWi
'displayButton' in props && props.displayButton === true;

const FilterByText = forwardRef<HTMLInputElement, FilterByTextProps>(function FilterByText(
{ placeholder, onChange: setFilter, shouldAutoFocus, children, ...props },
{ placeholder, onChange: setFilter, shouldAutoFocus = false, children, ...props },
ref,
) {
const t = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ const ManagersTable = () => {
)}
{isSuccess && data.users.length > 0 && (
<>
<GenericTable aria-busy={text !== debouncedText}>
<GenericTable aria-busy={text !== debouncedText} aria-label={t('Managers')}>
<GenericTableHeader>{headers}</GenericTableHeader>
<GenericTableBody data-qa-id='GenericTableManagerInfoBody'>
<GenericTableBody>
{data.users.map((user) => (
<GenericTableRow key={user._id} tabIndex={0} qa-user-id={user._id}>
<GenericTableCell withTruncatedText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test.describe.serial('OC - Manage Agents', () => {

await test.step('expect remove "user1" as agent', async () => {
await poOmnichannelAgents.inputSearch.fill('user1');
await poOmnichannelAgents.btnDeletefirstRowInTable.click();
await poOmnichannelAgents.btnDeleteFirstRowInTable.click();
await poOmnichannelAgents.btnModalRemove.click();

await poOmnichannelAgents.inputSearch.fill('user1');
Expand Down
22 changes: 10 additions & 12 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ test.describe('OC - Manager Role', () => {
});
});

test('OC - Manager Role - Add/remove agents', async ({ page }) => {
test('OC - Manager Role - Add/remove agents', async () => {
await poOmnichannel.agents.sidenav.linkAgents.click();

await test.step('expect add "user1" as agent', async () => {
await poOmnichannel.agents.inputUsername.type('user1');
await page.locator('role=option[name="user1"]').click();
await poOmnichannel.agents.selectUsername('user1');
await poOmnichannel.agents.btnAdd.click();

await poOmnichannel.agents.inputSearch.fill('user1');
Expand All @@ -183,32 +182,31 @@ test.describe('OC - Manager Role', () => {

await test.step('expect remove "user1" as agent', async () => {
await poOmnichannel.agents.inputSearch.fill('user1');
await poOmnichannel.agents.btnDeletefirstRowInTable.click();
await poOmnichannel.agents.btnDeleteFirstRowInTable.click();
await poOmnichannel.agents.btnModalRemove.click();

await poOmnichannel.agents.inputSearch.fill('');
await poOmnichannel.agents.inputSearch.type('user1');
await poOmnichannel.agents.inputSearch.fill('user1');
await expect(poOmnichannel.agents.findRowByName('user1')).toBeHidden();
});
});

test('OC - Manager Role - Add/remove managers', async ({ page }) => {
test('OC - Manager Role - Add/remove managers', async () => {
await poOmnichannel.omnisidenav.linkManagers.click();

await test.step('expect add "user1" as manager', async () => {
await poOmnichannel.managers.inputUsername.type('user1');
await page.locator('role=option[name="user1"]').click();
await poOmnichannel.managers.selectUsername('user1');
await poOmnichannel.managers.btnAdd.click();

await expect(poOmnichannel.managers.firstRowInTable('user1')).toBeVisible();
await expect(poOmnichannel.managers.findRowByName('user1')).toBeVisible();
});

await test.step('expect search for manager', async () => {
await poOmnichannel.managers.search('user1');
await expect(poOmnichannel.managers.firstRowInTable('user1')).toBeVisible();
await expect(poOmnichannel.managers.findRowByName('user1')).toBeVisible();

await poOmnichannel.managers.search('NonExistingUser');
await expect(poOmnichannel.managers.firstRowInTable('user1')).toBeHidden();
await expect(poOmnichannel.managers.findRowByName('user1')).toBeHidden();

await poOmnichannel.managers.clearSearch();
});
Expand All @@ -218,7 +216,7 @@ test.describe('OC - Manager Role', () => {
await poOmnichannel.managers.btnDeleteSelectedAgent('user1').click();
await poOmnichannel.managers.btnModalRemove.click();

await expect(poOmnichannel.managers.firstRowInTable('user1')).toBeHidden();
await expect(poOmnichannel.managers.findRowByName('user1')).toBeHidden();
});
});

Expand Down
19 changes: 8 additions & 11 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,23 @@ test.describe.serial('omnichannel-manager', () => {

test('OC - Manage Managers - Add, Search and Remove', async ({ page }) => {
await test.step('expect "user1" be first ', async () => {
await poOmnichannelManagers.inputUsername.type('user');
await poOmnichannelManagers.inputUsername.fill('user');
await expect(page.locator('role=option[name="user1"]')).toContainText('user1');

await poOmnichannelManagers.inputUsername.type('');
});

await test.step('expect add "user1" as manager', async () => {
await poOmnichannelManagers.inputUsername.type('user1');
await page.locator('role=option[name="user1"]').click();
await poOmnichannelManagers.selectUsername('user1');
await poOmnichannelManagers.btnAdd.click();

await expect(poOmnichannelManagers.firstRowInTable('user1')).toBeVisible();
await expect(poOmnichannelManagers.findRowByName('user1')).toBeVisible();
});

await test.step('expect search for manager', async () => {
await poOmnichannelManagers.search('user1');
await expect(poOmnichannelManagers.firstRowInTable('user1')).toBeVisible();
await expect(poOmnichannelManagers.findRowByName('user1')).toBeVisible();

await poOmnichannelManagers.search('NonExistingUser');
await expect(poOmnichannelManagers.firstRowInTable('user1')).toBeHidden();
await expect(poOmnichannelManagers.findRowByName('user1')).toBeHidden();

await poOmnichannelManagers.clearSearch();
});
Expand All @@ -45,7 +42,7 @@ test.describe.serial('omnichannel-manager', () => {
await poOmnichannelManagers.btnDeleteSelectedAgent('user1').click();
await poOmnichannelManagers.btnModalRemove.click();

await expect(poOmnichannelManagers.firstRowInTable('user1')).toBeHidden();
await expect(poOmnichannelManagers.findRowByName('user1')).toBeHidden();
});
});
});
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/page-objects/omnichannel-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class OmnichannelAgents {
return this.page.locator('[data-qa-id="agents-table"] tr:first-child td:first-child');
}

get btnDeletefirstRowInTable() {
get btnDeleteFirstRowInTable() {
return this.page.locator('[data-qa-id="agents-table"] tr:first-child').locator('role=button[name="Remove"]');
}

Expand Down
15 changes: 8 additions & 7 deletions apps/meteor/tests/e2e/page-objects/omnichannel-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class OmnichannelManager {
this.sidenav = new OmnichannelSidenav(page);
}

get inputSearch() {
private get inputSearch() {
return this.page.locator('[placeholder="Search"]');
}

Expand All @@ -30,16 +30,17 @@ export class OmnichannelManager {
return this.page.locator('input').first();
}

get btnAdd(): Locator {
return this.page.locator('button.rcx-button--primary.rcx-button >> text="Add manager"');
async selectUsername(username: string) {
await this.inputUsername.fill(username);
await this.page.locator(`role=option[name="${username}"]`).click();
}

firstRowInTable(userId: string) {
return this.page.locator(`[data-qa-id="GenericTableManagerInfoBody"] [qa-user-id="${userId}"]`);
get btnAdd(): Locator {
return this.page.locator('button.rcx-button--primary.rcx-button >> text="Add manager"');
}

get btnDeleteFirstRowInTable() {
return this.page.locator('button[title="Remove"]');
findRowByName(name: string) {
return this.page.locator('role=table[name="Managers"] >> role=row', { has: this.page.locator(`role=cell[name="${name}"]`) });
}

btnDeleteSelectedAgent(text: string) {
Expand Down

0 comments on commit b3b93f0

Please sign in to comment.