Skip to content

E2E: Tray, settings, and deep linking - #3864

Merged
yasserfaraazkhan merged 3 commits into
e2e/06-server-managementfrom
e2e/10-tray-settings-deeplink
Jul 1, 2026
Merged

E2E: Tray, settings, and deep linking#3864
yasserfaraazkhan merged 3 commits into
e2e/06-server-managementfrom
e2e/10-tray-settings-deeplink

Conversation

@yasserfaraazkhan

@yasserfaraazkhan yasserfaraazkhan commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacked PR 10/10 — final slice: tray, settings, deep linking, policy, popup.

Completes the #3847 split when merged after PRs 1–9.

Test plan

  • e2e/specs/system/tray_menu.test.ts
  • e2e/specs/deep_linking/
  • e2e/specs/settings/

Change Impact: 🟡 Medium

Regression Risk: Changes are isolated to end-to-end test helpers and test coverage, but they touch shared E2E utilities, app lifecycle/teardown helpers, and several scenarios around tray, settings, and deep linking. That creates moderate risk of brittle test regressions or flaky behavior, though production code is not directly affected.

QA Recommendation: Automated coverage should catch most issues; targeted manual QA is optional but recommended for the new tray and deep-link flows if there’s concern about platform-specific behavior.
Generated by CodeRabbitAI

@mm-cloud-bot

Copy link
Copy Markdown

@yasserfaraazkhan: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

I understand the commands that are listed here

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2b1475e3-58cb-4e16-89ce-d3bd39c236b1

📥 Commits

Reviewing files that changed from the base of the PR and between 4fda22b and 623df4b.

📒 Files selected for processing (3)
  • e2e/helpers/deeplink.ts
  • e2e/specs/deep_linking/deeplink.test.ts
  • e2e/specs/settings/autostart.test.ts
📝 Walkthrough

Walkthrough

This PR adds e2e deep-link helper utilities and refactors deep-linking tests to use them, migrates several specs to a faster Electron app teardown helper (closeElectronAppFast), narrows settings tests to platform-specific tags, and introduces new e2e suites for autostart, tray icon visibility, tray menu interaction, and window-close-to-tray behavior.

Changes

Deep-link helpers and consuming tests

Layer / File(s) Summary
Deep-link helper utilities
e2e/helpers/deeplink.ts
Adds mattermostDeepLinkUrl, channelDeepLinkUrl, openDeepLinkInApp, and waitForServerChannelNavigation functions for constructing and verifying deep links.
Windows/macOS deep link test updates
e2e/specs/deep_linking/deeplink.test.ts
Switches teardown to registerElectronMainProcess/closeElectronAppFast, extends Windows UI assertions, and adds a macOS open-url deep link test suite.
Running-server deep link test refactor
e2e/specs/deep_linking/deeplink_running.test.ts
Replaces manual OS-level deep-link triggering with helper functions, and adds a no-trailing-slash server URL test scenario.
OAuth callback deep link test
e2e/specs/deep_linking/oauth_callback.test.ts
Adds a new test verifying OAuth callback deep links navigate to the correct server view and dropdown state.

Electron app teardown migration to closeElectronAppFast

Layer / File(s) Summary
closeElectronAppFast adoption
e2e/specs/policy/policy.test.ts, e2e/specs/popup.test.ts, e2e/specs/system/tray_restore.test.ts
Replaces lock-file-wait based shutdown with closeElectronAppFast calls across multiple specs.

Settings test platform tag narrowing

Layer / File(s) Summary
Platform tag narrowing
e2e/specs/settings.test.ts
Replaces in-test process.platform skip guards with tag-based platform scoping for three tests.

New tray, autostart, and window-close system test suites

Layer / File(s) Summary
Autostart settings toggle test
e2e/specs/settings/autostart.test.ts
Adds openSettingsWindow retry helper and a test verifying the autostart config value toggles via the UI.
Tray icon hide config test
e2e/specs/settings/tray_icon_hide.test.ts
Adds a test toggling showTrayIcon off and polling for tray teardown.
Tray menu restore and server switch tests
e2e/specs/system/tray_menu.test.ts
Adds tests for restoring a hidden window via tray click and switching servers via the tray menu.
Window close-to-tray dialog test
e2e/specs/system/window_close_tray.test.ts
Adds a test verifying the app stays running when the user declines a stubbed quit dialog on window close.

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant ElectronApp
  participant MainProcess
  participant ServerView

  Test->>ElectronApp: openDeepLinkInApp(url)
  ElectronApp->>MainProcess: __e2eOpenDeepLink(url)
  MainProcess->>ServerView: navigate to deep-linked channel/server
  Test->>ElectronApp: waitForServerChannelNavigation(serverName, channelName)
  ElectronApp->>ServerView: poll current URL
  ServerView-->>ElectronApp: URL contains channelName
  ElectronApp-->>Test: navigation confirmed
Loading
sequenceDiagram
  participant Test
  participant MainProcess
  participant Tray
  participant MainWindow

  Test->>MainProcess: hide main window
  Test->>Tray: emit tray icon click
  Tray->>MainWindow: restore visibility
  Test->>Tray: click tray menu item for target server
  Tray->>MainWindow: switch active server view
  MainWindow-->>Test: ServerDropdownButton reflects new server
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main E2E changes around tray, settings, and deep linking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e/10-tray-settings-deeplink

Comment @coderabbitai help to get the list of available commands.

@yasserfaraazkhan yasserfaraazkhan changed the title E2E: Tray, settings, and deep linking (10/10) E2E: Tray, settings, and deep linking Jun 19, 2026
Base automatically changed from e2e/02-main-hooks to e2e/01-harness-ci June 19, 2026 11:21
Base automatically changed from e2e/01-harness-ci to master June 30, 2026 23:13
Resolve harness/hook conflicts by keeping merged #3855 changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the E2E/Run Run Desktop E2E Tests label Jun 30, 2026
@mm-cloud-bot

Copy link
Copy Markdown

❌ E2E Test Setup Failed

Failed to create E2E test instances: failed to create installation: failed with status code 409

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
e2e/specs/deep_linking/oauth_callback.test.ts (1)

31-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the mainWindow fixture instead of re-deriving it.

electronApp.windows().find((window) => window.url().includes('index')) duplicates the existing mainWindow fixture, which already performs this lookup with retry/try-catch protection around .url() (avoiding a thrown error if a window's execution context is transiently destroyed). Destructuring mainWindow from the test fixture would remove this duplication and the unguarded .url() call.

♻️ Proposed refactor
-    async ({electronApp}) => {
+    async ({electronApp, mainWindow}) => {
         await waitForAppReady(electronApp);
         ...
-        const mainWindow = electronApp.windows().find((window) => window.url().includes('index'));
-        expect(mainWindow).toBeDefined();
         await expect.poll(
-            () => mainWindow!.innerText('.ServerDropdownButton'),
+            () => mainWindow.innerText('.ServerDropdownButton'),
             {timeout: 15_000},
         ).toBe(serverName);
     },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/specs/deep_linking/oauth_callback.test.ts` around lines 31 - 36, The test
is re-deriving the Electron main window instead of using the existing mainWindow
fixture, which duplicates lookup logic and bypasses the fixture’s safer
retry/try-catch handling around .url(). Update the oauth_callback deep linking
spec to destructure and use the mainWindow fixture directly in place of
electronApp.windows().find(...), keeping the existing expect.poll assertions but
removing the manual window lookup.
e2e/specs/settings/autostart.test.ts (1)

43-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace arbitrary sleep with deterministic wait.

This backoff uses a fixed setTimeout sleep between retries. Since the next loop iteration already performs a bounded waitForEvent(..., {timeout: 3_000}), this extra sleep is unnecessary and conflicts with the project preference for deterministic waits over arbitrary sleeps.

As per coding guidelines, "Prefer deterministic selectors and explicit waits with waitForSelector() or expect().toContainText({timeout}) over arbitrary sleep statements".

♻️ Proposed fix
         } catch (error) {
             if (attempt === 4) {
                 throw error;
             }
-            await new Promise((resolve) => setTimeout(resolve, 250));
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/specs/settings/autostart.test.ts` at line 43, Remove the fixed
`setTimeout` delay in the retry/backoff logic inside `autostart.test.ts` and
rely on the existing bounded `waitForEvent(..., { timeout: 3_000 })` in the
retry loop for deterministic waiting. Keep the retry behavior in the same test
flow, but eliminate the arbitrary sleep so the `waitForEvent` path is the only
wait mechanism used.

Source: Coding guidelines

e2e/specs/system/tray_menu.test.ts (1)

48-86: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Use the demo config URL here instead of hardcoding github.com.
This keeps the assertion aligned with demoConfig.servers[1] and avoids a brittle test if the fixture changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/specs/system/tray_menu.test.ts` around lines 48 - 86, The tray menu e2e
test currently hardcodes the expected server URL when verifying the switched
view, which makes it brittle. Update the assertion in the TRAY-02 flow to derive
the expected URL from demoConfig.servers[1] instead of matching github.com
directly, and keep the check aligned with the existing targetServer/serverMap
logic in tray_menu.test.ts so the test stays consistent with the fixture.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/helpers/deeplink.ts`:
- Around line 9-21: The deeplink helper is selecting the protocol from the
Playwright process environment, which can produce the non-test scheme and break
e2e launches; update mattermostDeepLinkUrl to use the test deeplink scheme based
on the app launch mode rather than NODE_ENV in the helper process, and keep
channelDeepLinkUrl delegating through that same protocol selection so
openDeepLinkInApp and deeplink tests always receive the test scheme.

In `@e2e/specs/deep_linking/deeplink.test.ts`:
- Around line 98-149: This macOS open-url suite is bypassing the shared
`electronApp`/`mainWindow` fixtures by manually launching Electron and
re-discovering windows. Update the `test.describe('macOS open-url deep link')`
block to use `test.use({appConfig})` with the shared fixture instead of
`electron.launch`, so it inherits the darwin stability flags and longer timeout
already handled by the fixture. Also replace the inline
`app!.windows().find(...)` and `.url()`/dropdown polling with the existing
`mainWindow`/fixture-based helpers to avoid duplicating the discovery logic.

In `@e2e/specs/settings/autostart.test.ts`:
- Around line 50-68: The autostart settings test mutates a real login-item
setting and does not restore the original state, so update the SET-01 flow in
autostart.test.ts to capture the initial autostart value, perform the
toggle/assertion, and then revert it in a finally block or equivalent cleanup
path. Use the existing settings window interactions and config.json verification
around autostart to locate the test body, and ensure the cleanup runs even if
the assertion fails so subsequent tests and local runs see the original
OS/login-item state.

---

Nitpick comments:
In `@e2e/specs/deep_linking/oauth_callback.test.ts`:
- Around line 31-36: The test is re-deriving the Electron main window instead of
using the existing mainWindow fixture, which duplicates lookup logic and
bypasses the fixture’s safer retry/try-catch handling around .url(). Update the
oauth_callback deep linking spec to destructure and use the mainWindow fixture
directly in place of electronApp.windows().find(...), keeping the existing
expect.poll assertions but removing the manual window lookup.

In `@e2e/specs/settings/autostart.test.ts`:
- Line 43: Remove the fixed `setTimeout` delay in the retry/backoff logic inside
`autostart.test.ts` and rely on the existing bounded `waitForEvent(..., {
timeout: 3_000 })` in the retry loop for deterministic waiting. Keep the retry
behavior in the same test flow, but eliminate the arbitrary sleep so the
`waitForEvent` path is the only wait mechanism used.

In `@e2e/specs/system/tray_menu.test.ts`:
- Around line 48-86: The tray menu e2e test currently hardcodes the expected
server URL when verifying the switched view, which makes it brittle. Update the
assertion in the TRAY-02 flow to derive the expected URL from
demoConfig.servers[1] instead of matching github.com directly, and keep the
check aligned with the existing targetServer/serverMap logic in
tray_menu.test.ts so the test stays consistent with the fixture.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b2358c83-4406-4ca3-b9f0-4ff6e48f1d14

📥 Commits

Reviewing files that changed from the base of the PR and between 08129c4 and 4fda22b.

📒 Files selected for processing (12)
  • e2e/helpers/deeplink.ts
  • e2e/specs/deep_linking/deeplink.test.ts
  • e2e/specs/deep_linking/deeplink_running.test.ts
  • e2e/specs/deep_linking/oauth_callback.test.ts
  • e2e/specs/policy/policy.test.ts
  • e2e/specs/popup.test.ts
  • e2e/specs/settings.test.ts
  • e2e/specs/settings/autostart.test.ts
  • e2e/specs/settings/tray_icon_hide.test.ts
  • e2e/specs/system/tray_menu.test.ts
  • e2e/specs/system/tray_restore.test.ts
  • e2e/specs/system/window_close_tray.test.ts

Comment thread e2e/helpers/deeplink.ts
Comment thread e2e/specs/deep_linking/deeplink.test.ts
Comment thread e2e/specs/settings/autostart.test.ts
@yasserfaraazkhan

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Always use mattermost-dev deep links in E2E helpers, use shared fixtures
for the macOS open-url test, and restore autostart after SET-01.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yasserfaraazkhan

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions github-actions Bot added E2E/Run Run Desktop E2E Tests and removed E2E/Run Run Desktop E2E Tests labels Jun 30, 2026
@github-actions github-actions Bot removed the E2E/Run Run Desktop E2E Tests label Jul 1, 2026
@yasserfaraazkhan yasserfaraazkhan added E2E/Reset-Servers Destroy E2E server for a fresh Run. Add E2E/Run label to kick off an e2e run. and removed E2E/Reset-Servers Destroy E2E server for a fresh Run. Add E2E/Run label to kick off an e2e run. labels Jul 1, 2026
@yasserfaraazkhan
yasserfaraazkhan changed the base branch from master to e2e/06-server-management July 1, 2026 00:25
@yasserfaraazkhan
yasserfaraazkhan merged commit dfda040 into e2e/06-server-management Jul 1, 2026
40 of 43 checks passed
@yasserfaraazkhan
yasserfaraazkhan deleted the e2e/10-tray-settings-deeplink branch July 1, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants