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
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ function SideBarItemTemplateWithData({
const badges = (
<Margins inlineStart={8}>
{showBadge && isUnread && (
<Badge role='status' {...({ style: { display: 'inline-flex', flexShrink: 0 } } as any)} variant={variant} title={badgeTitle}>
{unread + tunread?.length}
<Badge
role='status'
{...({ style: { display: 'inline-flex', flexShrink: 0 } } as any)}
variant={variant}
title={badgeTitle}
aria-label={t('__unreadTitle__from__roomTitle__', { unreadTitle: badgeTitle, roomTitle: title })}
>
<span aria-hidden>{unread + tunread?.length}</span>
</Badge>
)}
{isOmnichannelRoom(room) && <OmnichannelBadges room={room} />}
Expand All @@ -184,7 +190,7 @@ function SideBarItemTemplateWithData({
onClick={(): void => {
!selected && sidebar.toggle();
}}
aria-label={title}
aria-label={showBadge && isUnread ? t('__unreadTitle__from__roomTitle__', { unreadTitle: badgeTitle, roomTitle: title }) : title}
title={title}
time={lastMessage?.ts}
subtitle={subtitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ const SidebarItemTemplateWithData = ({
const badges = (
<>
{showUnread && (
<SidebarV2ItemBadge variant={unreadVariant} title={unreadTitle} role='status'>
{unreadCount.total}
<SidebarV2ItemBadge
variant={unreadVariant}
title={unreadTitle}
role='status'
aria-label={t('__unreadTitle__from__roomTitle__', { unreadTitle, roomTitle: title })}
>
<span aria-hidden>{unreadCount.total}</span>
</SidebarV2ItemBadge>
)}
{isOmnichannelRoom(room) && <OmnichannelBadges room={room} />}
Expand All @@ -144,7 +149,7 @@ const SidebarItemTemplateWithData = ({
onClick={(): void => {
!selected && sidebar.toggle();
}}
aria-label={title}
aria-label={showUnread ? t('__unreadTitle__from__roomTitle__', { unreadTitle, roomTitle: title }) : title}
title={title}
time={lastMessage?.ts}
subtitle={subtitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useItemData = (
<>
{showUnread && (
<SidebarItemBadge variant={unreadVariant} title={unreadTitle} role='status'>
{unreadCount.total}
<span aria-hidden>{unreadCount.total}</span>
</SidebarItemBadge>
)}
</>
Expand Down
20 changes: 9 additions & 11 deletions apps/meteor/tests/e2e/mark-unread.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ test.describe.serial('mark-unread', () => {
test('should not mark empty room as unread', async () => {
await poHomeChannel.sidenav.selectMarkAsUnread(targetChannel);

await expect(poHomeChannel.sidenav.getRoomBadge(targetChannel)).not.toBeVisible();
await expect(poHomeChannel.sidenav.getSidebarItemBadge(targetChannel)).not.toBeVisible();
});

test('should mark a populated room as unread', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.sendMessage('this is a message for reply');
await poHomeChannel.sidenav.selectMarkAsUnread(targetChannel);

await expect(poHomeChannel.sidenav.getRoomBadge(targetChannel)).toBeVisible();
await expect(poHomeChannel.sidenav.getSidebarItemBadge(targetChannel)).toBeVisible();
});

test('should mark a populated room as unread - search', async () => {
Expand All @@ -43,7 +43,7 @@ test.describe.serial('mark-unread', () => {
await poHomeChannel.sidenav.selectMarkAsUnread(targetChannel);
await poHomeChannel.sidenav.searchRoom(targetChannel);

await expect(poHomeChannel.sidenav.getSearchChannelBadge(targetChannel)).toBeVisible();
await expect(poHomeChannel.sidenav.getSearchItemBadge(targetChannel)).toBeVisible();
});
});

Expand All @@ -58,14 +58,12 @@ test.describe.serial('mark-unread', () => {
await poHomeChannelUser2.content.sendMessage('this is a message for reply');
await user2Page.close();

await poHomeChannel.sidenav.openChat(targetChannel);

// wait for the sidebar item to be read
await poHomeChannel.sidenav.getSidebarItemByName(targetChannel, true).waitFor();
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.markUnread.click();

await expect(poHomeChannel.sidenav.getRoomBadge(targetChannel)).toBeVisible();
await expect(async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.markUnread.click();
await expect(poHomeChannel.sidenav.getSidebarItemBadge(targetChannel)).toBeVisible();
}).toPass();
});
});
});
37 changes: 19 additions & 18 deletions apps/meteor/tests/e2e/page-objects/fragments/home-sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,24 @@ export class HomeSidenav {
return this.page.locator('role=menuitemcheckbox[name="Preferences"]');
}

// TODO: refactor getSidebarItemByName to not use data-qa
getSidebarItemByName(name: string, isRead?: boolean): Locator {
return this.page.locator(
['[data-qa="sidebar-item"]', `[aria-label="${name}"]`, isRead && '[data-unread="false"]'].filter(Boolean).join(''),
);
get searchList(): Locator {
return this.page.getByRole('search').getByRole('listbox');
}

getSidebarItemByName(name: string): Locator {
return this.page.getByRole('link').filter({ has: this.page.getByText(name, { exact: true }) });
}

getSearchItemByName(name: string): Locator {
return this.searchList.getByRole('link').filter({ has: this.page.getByText(name, { exact: true }) });
}

getSidebarItemBadge(name: string): Locator {
return this.getSidebarItemByName(name).getByRole('status', { name: 'unread' });
}

getSearchItemBadge(name: string): Locator {
return this.getSearchItemByName(name).getByRole('status', { name: 'unread' });
}

async selectMarkAsUnread(name: string) {
Expand Down Expand Up @@ -112,10 +125,6 @@ export class HomeSidenav {
await this.page.locator('role=navigation >> role=button[name=Search]').click();
}

getSearchRoomByName(name: string): Locator {
return this.page.locator(`role=search >> role=listbox >> role=link >> text="${name}"`);
}

async searchRoom(name: string): Promise<void> {
await this.openSearch();
await this.page.locator('role=search >> role=searchbox').fill(name);
Expand All @@ -133,7 +142,7 @@ export class HomeSidenav {

async openChat(name: string): Promise<void> {
await this.searchRoom(name);
await this.getSearchRoomByName(name).click();
await this.getSearchItemByName(name).click();
await this.waitForChannel();
}

Expand Down Expand Up @@ -184,12 +193,4 @@ export class HomeSidenav {
await this.checkboxEncryption.click();
await this.btnCreate.click();
}

getRoomBadge(roomName: string): Locator {
return this.getSidebarItemByName(roomName).getByRole('status', { exact: true });
}

getSearchChannelBadge(name: string): Locator {
return this.page.locator(`[data-qa="sidebar-item"][aria-label="${name}"]`).first().getByRole('status', { exact: true });
}
}
2 changes: 1 addition & 1 deletion apps/meteor/tests/e2e/team-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ test.describe.serial('teams-management', () => {

await poHomeTeam.tabs.room.confirmDeleteTeam();
await poHomeTeam.sidenav.searchRoom(targetTeamNonPrivate);
await expect(poHomeTeam.sidenav.getSearchRoomByName(targetTeamNonPrivate)).not.toBeVisible();
await expect(poHomeTeam.sidenav.getSearchItemByName(targetTeamNonPrivate)).not.toBeVisible();
});

test('should user1 leave from targetTeam', async ({ browser }) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6785,5 +6785,6 @@
"different_values_found": "{{number}} different values found",
"Recent": "Recent",
"On_All_Contacts": "On All Contacts",
"Once": "Once"
"Once": "Once",
"__unreadTitle__from__roomTitle__": "{{unreadTitle}} from {{roomTitle}}"
}
Loading