Skip to content

Commit 0865fb2

Browse files
committed
Fix test issue with icon on channel context menu
1 parent b701e99 commit 0865fb2

6 files changed

Lines changed: 90 additions & 36 deletions

File tree

packages/desktop/src/renderer/components/ContextMenu/ContextMenu.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ export const ContextMenu: FC<ContextMenuProps> = ({ visible, handleClose, handle
6161
flex: 5,
6262
gap: '1px',
6363
}}
64+
data-testid={'contextMenu-title-wrapper'}
6465
>
6566
{titleIcon && titleIcon}
66-
<Typography fontSize={16} fontWeight={'medium'}>
67+
<Typography fontSize={16} fontWeight={'medium'} data-testid={'contextMenu-title'}>
6768
{title}
6869
</Typography>
6970
</Grid>

packages/desktop/src/renderer/components/ContextMenu/menus/ChannelContextMenu.container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const ChannelContextMenu: FC = () => {
7676
isPublic={channel?.public ?? true}
7777
fill={'currentColor'}
7878
style={{ fontSize: 16, fontWeight: 'medium' }}
79-
data-testid={`${channel?.name}-settings-channel-icon`}
79+
data-testid={`contextMenu-channel-settings-type-icon`}
8080
/>
8181
}
8282
{...channelContextMenu}

packages/e2e-tests/src/selectors.ts

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { By, Key, type ThenableWebDriver, type WebElement, until } from 'selenium-webdriver'
1+
import { By, Key, type ThenableWebDriver, type WebElement, until, WebElementPromise } from 'selenium-webdriver'
22
import { BuildSetup, logAndReturnError, promiseWithRetries, sleep, type BuildSetupInit } from './utils'
33
import path from 'path'
44
import { FileDownloadStatus, PhotoExt, SettingsModalTabName, FileAttachmentType, X_DATA_TESTID } from './enums'
@@ -628,32 +628,64 @@ export class ChannelContextMenu {
628628
this.driver = driver
629629
}
630630

631-
async openMenu(channelName: string) {
632-
const menu = this.driver.wait(
633-
until.elementLocated(By.xpath('//div[@data-testid="channelContextMenuButton"]')),
634-
15_000,
635-
`Channel context menu couldn't be located within timeout`,
636-
500
637-
)
638-
await this.driver.wait(
639-
until.elementIsVisible(menu),
640-
15_000,
641-
`Channel context menu was not visibile within timeout`,
642-
500
643-
)
644-
await menu.click()
645-
const channelTypeIcon = this.driver.wait(
646-
until.elementLocated(By.xpath(`//*[@data-testid="${channelName}-settings-channel-icon"]`)),
647-
15_000,
648-
`Channel context menu lock/hash icon couldn't be located within timeout`,
649-
500
650-
)
651-
await this.driver.wait(
652-
until.elementIsVisible(channelTypeIcon),
653-
15_000,
654-
`Channel context menu lock/hash icon was not visibile within timeout`,
655-
500
656-
)
631+
async openMenu(): Promise<{ menuButton: boolean; menuOpened: boolean; iconVisible: boolean }> {
632+
let menu: WebElement
633+
try {
634+
menu = await this.driver.wait(
635+
until.elementLocated(By.xpath('//div[@data-testid="channelContextMenuButton"]')),
636+
15_000,
637+
`Channel context menu couldn't be located within timeout`,
638+
500
639+
)
640+
await this.driver.wait(
641+
until.elementIsVisible(menu),
642+
15_000,
643+
`Channel context menu was not visibile within timeout`,
644+
500
645+
)
646+
} catch (e) {
647+
logger.error('Error while checking for channel context menu button', e)
648+
return {
649+
menuButton: false,
650+
menuOpened: false,
651+
iconVisible: false,
652+
}
653+
}
654+
try {
655+
await menu.click()
656+
} catch (e) {
657+
return {
658+
menuButton: true,
659+
menuOpened: false,
660+
iconVisible: false,
661+
}
662+
}
663+
try {
664+
const channelTypeIcon = this.driver.wait(
665+
until.elementLocated(By.xpath(`//*[@data-testid="contextMenu-channel-settings-type-icon"]`)),
666+
15_000,
667+
`Channel context menu lock/hash icon couldn't be located within timeout`,
668+
500
669+
)
670+
await this.driver.wait(
671+
until.elementIsVisible(channelTypeIcon),
672+
15_000,
673+
`Channel context menu lock/hash icon was not visibile within timeout`,
674+
500
675+
)
676+
return {
677+
menuButton: true,
678+
menuOpened: true,
679+
iconVisible: true,
680+
}
681+
} catch (e) {
682+
logger.error('Error while checking for channel icon on context menu', e)
683+
return {
684+
menuButton: true,
685+
menuOpened: true,
686+
iconVisible: false,
687+
}
688+
}
657689
}
658690

659691
async openDeletionChannelModal() {

packages/e2e-tests/src/tests/multipleClients.privateChannels.qss.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,25 @@ describe('Multiple Clients (QSS - Private Channels)', () => {
338338

339339
it('Owner adds first user to private channel', async () => {
340340
channelContextMenuOwner = new ChannelContextMenu(users.owner.app.driver)
341-
await channelContextMenuOwner.openMenu(privateChannelName)
341+
const { menuButton, menuOpened, iconVisible } = await channelContextMenuOwner.openMenu()
342342
await channelContextMenuOwner.openAddMembersModal()
343343
await channelContextMenuOwner.addMembersToChannel(privateChannelName, [users.user1.username])
344+
expect(menuButton).toBe(true)
345+
expect(menuOpened).toBe(true)
346+
expect(iconVisible).toBe(true)
344347
})
345348

346349
it('Owner verifies first user is no longer in autocomplete', async () => {
347-
await channelContextMenuOwner.openMenu(privateChannelName)
350+
const { menuButton, menuOpened, iconVisible } = await channelContextMenuOwner.openMenu()
348351
await channelContextMenuOwner.openAddMembersModal()
349352
const membersLeftInAutocomplete = await channelContextMenuOwner.checkForMembersInAddMembersAutocomplete(
350353
privateChannelName,
351354
[users.user1.username, users.owner.username]
352355
)
353356
expect(membersLeftInAutocomplete.length).toBe(0)
357+
expect(menuButton).toBe(true)
358+
expect(menuOpened).toBe(true)
359+
expect(iconVisible).toBe(true)
354360
})
355361
})
356362

@@ -441,9 +447,12 @@ describe('Multiple Clients (QSS - Private Channels)', () => {
441447

442448
it('Owner adds first user to second private channel', async () => {
443449
channelContextMenuOwner = new ChannelContextMenu(users.owner.app.driver)
444-
await channelContextMenuOwner.openMenu(privateChannel2Name)
450+
const { menuButton, menuOpened, iconVisible } = await channelContextMenuOwner.openMenu()
445451
await channelContextMenuOwner.openAddMembersModal()
446452
await channelContextMenuOwner.addMembersToChannel(privateChannel2Name, [users.user1.username])
453+
expect(menuButton).toBe(true)
454+
expect(menuOpened).toBe(true)
455+
expect(iconVisible).toBe(true)
447456
})
448457

449458
it(`First user sees second private channel in sidebar`, async () => {

packages/e2e-tests/src/tests/multipleClients.privateChannels.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,12 @@ describe('Multiple Clients (Private Channels)', () => {
306306
describe(`Owner Adds User To Private Channel`, () => {
307307
it('Owner adds first user to private channel', async () => {
308308
channelContextMenuOwner = new ChannelContextMenu(users.owner.app.driver)
309-
await channelContextMenuOwner.openMenu(privateChannelName)
309+
const { menuButton, menuOpened, iconVisible } = await channelContextMenuOwner.openMenu()
310310
await channelContextMenuOwner.openAddMembersModal()
311311
await channelContextMenuOwner.addMembersToChannel(privateChannelName, [users.user1.username])
312+
expect(menuButton).toBe(true)
313+
expect(menuOpened).toBe(true)
314+
expect(iconVisible).toBe(true)
312315
})
313316

314317
it(`Private channel is in user's sidebar`, async () => {
@@ -389,9 +392,12 @@ describe('Multiple Clients (Private Channels)', () => {
389392

390393
it('Owner adds first user to second private channel', async () => {
391394
channelContextMenuOwner = new ChannelContextMenu(users.owner.app.driver)
392-
await channelContextMenuOwner.openMenu(privateChannel2Name)
395+
const { menuButton, menuOpened, iconVisible } = await channelContextMenuOwner.openMenu()
393396
await channelContextMenuOwner.openAddMembersModal()
394397
await channelContextMenuOwner.addMembersToChannel(privateChannel2Name, [users.user1.username])
398+
expect(menuButton).toBe(true)
399+
expect(menuOpened).toBe(true)
400+
expect(iconVisible).toBe(true)
395401
})
396402

397403
it(`Second private channel is in user's sidebar`, async () => {

packages/e2e-tests/src/tests/multipleClients.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ describe('Multiple Clients', () => {
378378
describe('Channel Deletion', () => {
379379
it('Owner deletes second channel', async () => {
380380
channelContextMenuOwner = new ChannelContextMenu(users.owner.app.driver)
381-
await channelContextMenuOwner.openMenu(generalChannelName)
381+
const { iconVisible, menuOpened, menuButton } = await channelContextMenuOwner.openMenu()
382+
expect(menuButton).toBe(true)
383+
expect(menuOpened).toBe(true)
384+
expect(iconVisible).toBe(true)
382385
await channelContextMenuOwner.openDeletionChannelModal()
383386
await channelContextMenuOwner.deleteChannel()
384387
const channels = await sidebarOwner.getChannelList()
@@ -454,9 +457,12 @@ describe('Multiple Clients', () => {
454457
expect(await generalChannelOwner.isReady()).toBeTruthy()
455458
expect(await generalChannelOwner.isOpen()).toBeTruthy()
456459
expect(await generalChannelOwner.isMessageInputReady()).toBeTruthy()
457-
await channelContextMenuOwner.openMenu(generalChannelName)
460+
const { menuOpened, menuButton, iconVisible } = await channelContextMenuOwner.openMenu()
458461
await channelContextMenuOwner.openDeletionChannelModal()
459462
await channelContextMenuOwner.deleteChannel()
463+
expect(menuButton).toBe(true)
464+
expect(menuOpened).toBe(true)
465+
expect(iconVisible).toBe(true)
460466
})
461467

462468
it('Owner sees recreated general channel', async () => {

0 commit comments

Comments
 (0)