Skip to content

refactor(client): Meteor-less absoluteUrl()#40324

Merged
ggazzo merged 7 commits intodevelopfrom
refactor/meteorless-absolute-url
Apr 28, 2026
Merged

refactor(client): Meteor-less absoluteUrl()#40324
ggazzo merged 7 commits intodevelopfrom
refactor/meteorless-absolute-url

Conversation

@tassoevan
Copy link
Copy Markdown
Member

@tassoevan tassoevan commented Apr 27, 2026

Proposed changes (including videos or screenshots)

It adds a absoluteUrl function that mimics the original Meteor.absoluteUrl to client-side code.

Issue(s)

Steps to test or reproduce

Further comments

It's inspired by automated review comments on #40268.

Task: ARCH-2120

Summary by CodeRabbit

  • New Features

    • Introduced a new client-side URL utility that normalizes absolute URLs with configurable scheme handling, localhost rewriting, and secure context detection.
  • Refactor

    • Updated multiple client-side modules to use the new URL utility, improving consistency in how application URLs are constructed across login flows, room coordination, and server configuration.

@tassoevan tassoevan added this to the 8.5.0 milestone Apr 27, 2026
@tassoevan tassoevan requested a review from a team as a code owner April 27, 2026 16:07
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 27, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

⚠️ No Changeset found

Latest commit: 98dca7a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@tassoevan
Copy link
Copy Markdown
Member Author

/jira ARCH-2083

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 540ff473-1feb-4c27-9f53-c6f9aa637952

📥 Commits

Reviewing files that changed from the base of the PR and between c2e3f66 and fcaa621.

📒 Files selected for processing (1)
  • apps/meteor/client/lib/absoluteUrl.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build

Walkthrough

This PR extracts URL utility logic from Meteor.absoluteUrl into a new shared absoluteUrl module on the client side, with comprehensive tests. Multiple client files are updated to import and use this new utility instead of the Meteor dependency.

Changes

Cohort / File(s) Summary
New absoluteUrl Utility
apps/meteor/client/lib/absoluteUrl.ts, apps/meteor/client/lib/absoluteUrl.spec.ts
Introduces absoluteUrl() function with protocol normalization, trailing-slash handling, path appending, secure/localhost transformations, and _relativeToSiteRootUrl() for path-prefix handling. Includes comprehensive test suite covering URL construction, protocol inference, security upgrades, localhost replacement, and root-path-prefix prefixing.
Client Module Refactoring
apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts, apps/meteor/client/lib/openCASLoginPopup.ts, apps/meteor/client/lib/rooms/roomCoordinator.tsx, apps/meteor/client/meteor/login/saml.ts, apps/meteor/client/meteor/login/twitter.ts, apps/meteor/client/providers/ServerProvider.tsx
Migrate from Meteor.absoluteUrl to imported absoluteUrl utility for computing application URLs in recorder worker paths, CAS login, room routing, SAML logout redirect, Twitter OAuth, and provider initialization.
Configuration & Integration
apps/meteor/client/meteor/startup/absoluteUrl.ts, apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts
Attach new absoluteUrl and _relativeToSiteRootUrl functions to Meteor object in startup; update SSL config hook to mutate absoluteUrl.defaultOptions instead of Meteor.absoluteUrl.defaultOptions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 accurately summarizes the main objective: introducing a client-side absoluteUrl function independent of Meteor, which is the core change across all modified files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ARCH-2120: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
apps/meteor/client/lib/absoluteUrl.ts (2)

1-1: Drop the leading remark.

Per the repository coding guideline "Avoid code comments in the implementation," this speculative note should not live in the source file. If the future relocation needs to be tracked, prefer the PR description, an ADR, or an issue.

♻️ Proposed change
-// There is a good chance this module may be promoted to root lib/ in the future
-
 import { baseURI } from './baseURI';

As per coding guidelines: **/*.{ts,tsx,js} — "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/lib/absoluteUrl.ts` at line 1, Remove the speculative
leading file comment in the absoluteUrl.ts module—the line "// There is a good
chance this module may be promoted to root lib/ in the future"—so the
implementation contains no extraneous comments; if relocation needs tracking,
add the note to the PR description, an ADR, or an issue instead.

11-15: Add an overload to type the polymorphic call shape.

The body accepts absoluteUrl(options) (options-as-first-arg) but the declared signature only models (path?, options?). This forces as any at call sites/tests (e.g., absoluteUrl.spec.ts Line 63). Adding an overload restores type safety without changing runtime behavior.

♻️ Proposed overloads
-export function absoluteUrl(path?: string, options?: AbsoluteUrlOptions): string {
+export function absoluteUrl(options?: AbsoluteUrlOptions): string;
+export function absoluteUrl(path?: string, options?: AbsoluteUrlOptions): string;
+export function absoluteUrl(path?: string | AbsoluteUrlOptions, options?: AbsoluteUrlOptions): string {
 	if (!options && typeof path === 'object') {
 		options = path;
 		path = undefined;
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/lib/absoluteUrl.ts` around lines 11 - 15, Add TypeScript
overloads to absoluteUrl so callers can pass either (options?:
AbsoluteUrlOptions) or (path?: string, options?: AbsoluteUrlOptions) while
keeping the same implementation body; update the function declaration for
absoluteUrl to include the single-argument overload that accepts
AbsoluteUrlOptions and the two-argument overload that accepts (path?: string,
options?: AbsoluteUrlOptions), then keep the existing implementation (the block
that checks typeof path === 'object' and swaps args) unchanged so runtime
behavior stays identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/meteor/client/lib/absoluteUrl.ts`:
- Around line 51-60: The client currently caches defaultOptions.rootUrl at
module load (via absoluteUrl.defaultOptions), causing stale values when
useSettingsOnLoadSiteUrl later mutates __meteor_runtime_config__.ROOT_URL;
update the client-side fix to mirror the server: when useSettingsOnLoadSiteUrl
updates __meteor_runtime_config__.ROOT_URL, also assign
absoluteUrl.defaultOptions.rootUrl (and set defaultOptions.secure if needed) so
Meteor.absoluteUrl uses the new Site_Url, or alternatively refactor the
absoluteUrl() implementation to resolve __meteor_runtime_config__.ROOT_URL
lazily on each call instead of reading it once at module initialization.

In `@apps/meteor/client/providers/ServerProvider.tsx`:
- Line 20: Update the ServerContextValue type so its absoluteUrl signature
matches the new helper: change the declaration of absoluteUrl in
ServerContext.ts to accept optional path and options parameters (i.e.,
absoluteUrl: (path?: string, options?: AbsoluteUrlOptions) => string) and update
the context value creation (the block that constructs the context value around
lines where the ServerContext is created) to conform to that type when assigning
the imported absoluteUrl helper; ensure any references to absoluteUrl within
ServerContextValue and the object built for the context use the optional path
and options parameters.

---

Nitpick comments:
In `@apps/meteor/client/lib/absoluteUrl.ts`:
- Line 1: Remove the speculative leading file comment in the absoluteUrl.ts
module—the line "// There is a good chance this module may be promoted to root
lib/ in the future"—so the implementation contains no extraneous comments; if
relocation needs tracking, add the note to the PR description, an ADR, or an
issue instead.
- Around line 11-15: Add TypeScript overloads to absoluteUrl so callers can pass
either (options?: AbsoluteUrlOptions) or (path?: string, options?:
AbsoluteUrlOptions) while keeping the same implementation body; update the
function declaration for absoluteUrl to include the single-argument overload
that accepts AbsoluteUrlOptions and the two-argument overload that accepts
(path?: string, options?: AbsoluteUrlOptions), then keep the existing
implementation (the block that checks typeof path === 'object' and swaps args)
unchanged so runtime behavior stays identical.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0cbf4bc4-ce40-494f-ac83-c3ff02ef7862

📥 Commits

Reviewing files that changed from the base of the PR and between 9498359 and a7fe5ad.

📒 Files selected for processing (11)
  • apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts
  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
  • apps/meteor/client/lib/absoluteUrl.ts
  • apps/meteor/client/lib/openCASLoginPopup.ts
  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/meteor/login/twitter.ts
  • apps/meteor/client/meteor/startup/absoluteUrl.ts
  • apps/meteor/client/providers/ServerProvider.tsx
  • apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/providers/ServerProvider.tsx
  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts
  • apps/meteor/client/meteor/login/twitter.ts
  • apps/meteor/client/meteor/startup/absoluteUrl.ts
  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.ts
  • apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts
  • apps/meteor/client/lib/openCASLoginPopup.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
🧠 Learnings (31)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.

Applied to files:

  • apps/meteor/client/providers/ServerProvider.tsx
  • apps/meteor/client/meteor/login/twitter.ts
  • apps/meteor/client/lib/openCASLoginPopup.ts
  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/providers/ServerProvider.tsx
  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/client/meteor/login/twitter.ts
  • apps/meteor/client/meteor/startup/absoluteUrl.ts
  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.ts
  • apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts
  • apps/meteor/client/lib/openCASLoginPopup.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts
  • apps/meteor/client/meteor/login/twitter.ts
  • apps/meteor/client/meteor/startup/absoluteUrl.ts
  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.ts
  • apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts
  • apps/meteor/client/lib/openCASLoginPopup.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/meteor/login/saml.ts
  • apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts
  • apps/meteor/client/meteor/login/twitter.ts
  • apps/meteor/client/meteor/startup/absoluteUrl.ts
  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.ts
  • apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts
  • apps/meteor/client/lib/openCASLoginPopup.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-10-07T15:08:37.419Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 36942
File: apps/meteor/client/lib/e2ee/pbkdf2.ts:13-45
Timestamp: 2025-10-07T15:08:37.419Z
Learning: In apps/meteor/client/lib/e2ee/pbkdf2.ts, the team has decided to use Latin-1 encoding (via Binary.toArrayBuffer and Binary.toString) for password encoding and decrypt output instead of UTF-8 encoding. This is a deliberate choice for E2EE password/key material handling.

Applied to files:

  • apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts
📚 Learning: 2026-03-09T23:46:52.173Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 39492
File: apps/meteor/app/oauth2-server-config/server/oauth/oauth2-server.ts:22-24
Timestamp: 2026-03-09T23:46:52.173Z
Learning: In `apps/meteor/app/oauth2-server-config/server/oauth/oauth2-server.ts`, the `oAuth2ServerAuth` function's `authorization` field in `partialRequest` is exclusively expected to carry Bearer tokens. Basic authentication is not supported in this OAuth flow, so there is no need to guard against non-Bearer schemes when extracting the token from the `Authorization` header.

Applied to files:

  • apps/meteor/client/meteor/login/twitter.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/page-objects/**/*.ts : Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`

Applied to files:

  • apps/meteor/client/meteor/startup/absoluteUrl.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2026-03-06T18:09:17.867Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/elements/Timestamp/DateTimeFormats.spec.tsx:20-23
Timestamp: 2026-03-06T18:09:17.867Z
Learning: In the RocketChat/Rocket.Chat gazzodown package (`packages/gazzodown`), tests are intended to run under the UTC timezone, but as of PR `#39397` this is NOT yet explicitly enforced in `jest.config.ts` or the `package.json` test scripts (which just run `jest` without `TZ=UTC`). To make timezone-sensitive snapshot tests reliable across all environments, `TZ=UTC` should be added to the test scripts in `package.json` or to `jest.config.ts` via `testEnvironmentOptions.timezone`. Without explicit UTC enforcement, snapshot tests involving date-fns formatted output or `toLocaleString()` will fail for contributors in non-UTC timezones.

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.https.spec.ts
  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • apps/meteor/client/lib/absoluteUrl.spec.ts
📚 Learning: 2026-04-13T16:40:55.864Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40100
File: apps/meteor/client/views/root/MainLayout/EmbeddedPreload.tsx:18-35
Timestamp: 2026-04-13T16:40:55.864Z
Learning: In Rocket.Chat's embedded mode (`?layout=embedded`), route changes are driven by the parent frame reloading the iframe URL, which causes a full remount of the React tree (including `EmbeddedPreload` at `apps/meteor/client/views/root/MainLayout/EmbeddedPreload.tsx`). The component never survives a navigation, so `roomParams` (computed via `useMemo`) is always fresh on mount. A `[router]` singleton as the sole `useMemo` dependency is therefore correct and intentional — do not flag it as a stale-dependency bug in this component.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2025-11-27T17:56:26.050Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2026-03-15T14:31:28.969Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2026-04-17T17:38:15.994Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 39858
File: packages/ui-kit/src/interactions/UserInteraction.ts:33-33
Timestamp: 2026-04-17T17:38:15.994Z
Learning: In RocketChat/Rocket.Chat (`packages/ui-kit/src/interactions/UserInteraction.ts`), `ViewSubmitUserInteraction` and `ViewClosedUserInteraction` intentionally do NOT include `rid` when the interaction originates from a **modal** surface. Modals are not scoped to a room, so no room id is available in that context. The `rid?: string` field is optional to support the contextual bar surface (where room context exists) while remaining absent for modals. Do not flag the absence of `rid` in modal viewSubmit/viewClosed interactions as a missing-context bug.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings (mapping subscription documents to room IDs), never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings by mapping subscription documents to room IDs, never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
📚 Learning: 2026-03-10T08:13:52.153Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 39414
File: apps/meteor/app/api/server/v1/rooms.ts:1241-1297
Timestamp: 2026-03-10T08:13:52.153Z
Learning: In the RocketChat/Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1/rooms.ts, the pattern `ajv.compile<void>({...})` is intentionally used for the 200 response schema even when the endpoint returns `{ success: true }`. This is an established convention across all migrated endpoints (rooms.leave, rooms.favorite, rooms.delete, rooms.muteUser, rooms.unmuteUser). Do not flag this as a type mismatch during reviews of these migration PRs.

Applied to files:

  • apps/meteor/client/lib/rooms/roomCoordinator.tsx
🔇 Additional comments (9)
apps/meteor/client/lib/rooms/roomCoordinator.tsx (1)

19-19: LGTM!

Clean drop-in replacement of Meteor.absoluteUrl(...) with the local helper; router.buildRoutePath(...) output is wrapped identically.

Also applies to: 206-211

apps/meteor/client/meteor/login/saml.ts (1)

6-6: LGTM!

SLO bounce URL is built identically; only the URL prefixing helper changed.

Also applies to: 79-79

apps/meteor/app/ui/client/lib/recorderjs/AudioEncoder.ts (1)

3-3: LGTM!

Worker URL construction is unchanged in semantics. The ../../../../../client/lib/absoluteUrl import is a bit deep but acceptable given this module is already client-only.

Also applies to: 13-13

apps/meteor/client/views/root/hooks/useCorsSSLConfig.ts (1)

4-12: LGTM — pre-existing semantics preserved.

The mutation target moved from Meteor.absoluteUrl.defaultOptions to the local absoluteUrl.defaultOptions. Note (informational, not blocking): when Force_SSL=false on an https page, this still overrides the auto-detected secure: true set during module init — same behavior as before, kept intentionally.

apps/meteor/client/meteor/login/twitter.ts (1)

9-9: LGTM!

Drop-in replacement; OAuth flow and loginPath composition unchanged.

Also applies to: 47-47

apps/meteor/client/lib/openCASLoginPopup.ts (1)

34-35: No issue. The absoluteUrl() function does not include ROOT_URL_PATH_PREFIX in its return value; it only returns the base URL (protocol + host + optional path). The pattern on line 34 of appending the prefix is correct and does not duplicate it.

apps/meteor/client/meteor/startup/absoluteUrl.ts (1)

3-8: No client-side conflicts detected—migration is safe.

All client-side references to absoluteUrl.defaultOptions use the local helper (imported from apps/meteor/client/lib/absoluteUrl.ts), which has its own defaultOptions property. Server-side mutations in configureBoilerplate.ts and app/cors/server/index.ts remain unaffected. The local helper fully supports the secure property needed by useCorsSSLConfig.ts, confirming the migration is complete and correct.

apps/meteor/client/lib/absoluteUrl.https.spec.ts (1)

1-20: LGTM!

Per-file jsdom env override plus jest.isolateModulesAsync correctly forces a fresh module evaluation under https location, and assertions match the module-init logic in absoluteUrl.ts (location-derived rootUrl and secure: true).

apps/meteor/client/lib/absoluteUrl.spec.ts (1)

1-120: Tests look thorough and correct.

Coverage spans default-option resolution, protocol normalization, secure/localhost rules, and module-init paths (including __meteor_runtime_config__.ROOT_URL). The as any cast at Line 63 reflects a typing gap in the public signature of absoluteUrl; addressing it via overloads in absoluteUrl.ts (see comment there) will let this test drop the cast.

Comment thread apps/meteor/client/lib/absoluteUrl.ts Outdated
Comment thread apps/meteor/client/providers/ServerProvider.tsx
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 98.43750% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.86%. Comparing base (0d34fc1) to head (98dca7a).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40324      +/-   ##
===========================================
- Coverage    69.87%   69.86%   -0.01%     
===========================================
  Files         3296     3297       +1     
  Lines       119186   119243      +57     
  Branches     21525    21555      +30     
===========================================
+ Hits         83285    83314      +29     
- Misses       32613    32623      +10     
- Partials      3288     3306      +18     
Flag Coverage Δ
e2e 59.72% <46.42%> (-0.07%) ⬇️
e2e-api 47.08% <ø> (+0.83%) ⬆️
unit 70.62% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

LGTM!

@gabriellsh
Copy link
Copy Markdown
Member

image

@tassoevan tassoevan enabled auto-merge April 28, 2026 00:03
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Apr 28, 2026
@ggazzo ggazzo disabled auto-merge April 28, 2026 15:18
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 28, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Apr 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 28, 2026
@dougfabris dougfabris removed this from the 8.5.0 milestone Apr 28, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Apr 28, 2026
@dougfabris dougfabris added this to the 8.5.0 milestone Apr 28, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 28, 2026
@dougfabris dougfabris modified the milestone: 8.5.0 Apr 28, 2026
@dionisio-bot dionisio-bot Bot added stat: ready to merge PR tested and approved waiting for merge and removed stat: ready to merge PR tested and approved waiting for merge labels Apr 28, 2026
@dougfabris dougfabris removed the stat: QA assured Means it has been tested and approved by a company insider label Apr 28, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Apr 28, 2026
@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Apr 28, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 28, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Apr 28, 2026
@ggazzo ggazzo removed this pull request from the merge queue due to a manual request Apr 28, 2026
@ggazzo ggazzo merged commit 700fcb1 into develop Apr 28, 2026
83 of 86 checks passed
@ggazzo ggazzo deleted the refactor/meteorless-absolute-url branch April 28, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants