-
Notifications
You must be signed in to change notification settings - Fork 972
E2E: Tray, settings, and deep linking #3864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yasserfaraazkhan
merged 3 commits into
e2e/06-server-management
from
e2e/10-tray-settings-deeplink
Jul 1, 2026
Merged
Changes from 4 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import {expect} from '@playwright/test'; | ||
| import type {ElectronApplication} from 'playwright'; | ||
|
|
||
| import {buildServerMap} from './serverMap'; | ||
|
|
||
| export function mattermostDeepLinkUrl(hostAndPath: string): string { | ||
| const protocol = process.env.NODE_ENV === 'test' ? 'mattermost-dev' : 'mattermost'; | ||
| return `${protocol}://${hostAndPath}`; | ||
| } | ||
|
|
||
| /** Build a channel deep link that preserves the team path from the configured server URL. */ | ||
| export function channelDeepLinkUrl(serverUrl: string, channelName: string): string { | ||
| const normalized = serverUrl.endsWith('/') ? serverUrl : `${serverUrl}/`; | ||
| const parsed = new URL(normalized); | ||
| const teamPath = parsed.pathname.replace(/\/$/, ''); | ||
| const channelPath = teamPath ? `${teamPath}/channels/${channelName}` : `/channels/${channelName}`; | ||
| return mattermostDeepLinkUrl(`${parsed.host}${channelPath}`); | ||
| } | ||
|
|
||
| export async function openDeepLinkInApp(app: ElectronApplication, url: string): Promise<void> { | ||
| await app.evaluate((_, deepLinkUrl) => { | ||
| const openDeepLink = (global as any).__e2eOpenDeepLink as ((value: string) => void) | undefined; | ||
| if (!openDeepLink) { | ||
| throw new Error('__e2eOpenDeepLink not exposed (NODE_ENV must be test)'); | ||
| } | ||
| openDeepLink(deepLinkUrl); | ||
| }, url); | ||
| } | ||
|
|
||
| /** Poll any tab for the server until one navigates to the expected channel. */ | ||
| export async function waitForServerChannelNavigation( | ||
| app: ElectronApplication, | ||
| serverName: string, | ||
| channelName: string, | ||
| options?: {timeout?: number}, | ||
| ): Promise<void> { | ||
| await expect.poll(async () => { | ||
| const map = await buildServerMap(app); | ||
| const entries = map[serverName] ?? []; | ||
| for (const entry of entries) { | ||
| const url = await entry.win.url(); | ||
| if (url.includes(channelName)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| }, { | ||
| timeout: options?.timeout ?? 15_000, | ||
| message: `Server view should navigate to ${channelName}`, | ||
| }).toBe(true); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import {test, expect} from '../../fixtures/index'; | ||
| import {waitForAppReady} from '../../helpers/appReadiness'; | ||
| import {demoConfig} from '../../helpers/config'; | ||
| import {mattermostDeepLinkUrl, openDeepLinkInApp} from '../../helpers/deeplink'; | ||
| import {buildServerMap} from '../../helpers/serverMap'; | ||
|
|
||
| test( | ||
| 'DL-03 OAuth callback deep link navigates the active server view', | ||
| {tag: ['@P1', '@all']}, | ||
| async ({electronApp}) => { | ||
| await waitForAppReady(electronApp); | ||
|
|
||
| const serverName = demoConfig.servers[0].name; | ||
| const oauthPath = '/oauth/authorize?client_id=desktop&response_type=code&state=e2e-test'; | ||
| const deepLink = mattermostDeepLinkUrl(`example.com${oauthPath}`); | ||
|
|
||
| await openDeepLinkInApp(electronApp, deepLink); | ||
|
|
||
| await expect.poll(async () => { | ||
| const serverMap = await buildServerMap(electronApp); | ||
| const view = serverMap[serverName]?.[0]?.win; | ||
| return view?.url() ?? ''; | ||
| }, { | ||
| timeout: 30_000, | ||
| message: 'OAuth callback deep link should navigate the example server view', | ||
| }).toContain('example.com/oauth/authorize'); | ||
|
|
||
| const mainWindow = electronApp.windows().find((window) => window.url().includes('index')); | ||
| expect(mainWindow).toBeDefined(); | ||
| await expect.poll( | ||
| () => mainWindow!.innerText('.ServerDropdownButton'), | ||
| {timeout: 15_000}, | ||
| ).toBe(serverName); | ||
| }, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.