Skip to content

Commit d359458

Browse files
Merge branch 'main' into MMQA-1367-serve-test-snaps-locally
2 parents 0d8af7b + 9355fcc commit d359458

18 files changed

Lines changed: 211 additions & 29 deletions

File tree

.agents/skills/e2e-test/references/mocking.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,17 @@ Add a mock for every such request to ensure test determinism.
127127

128128
## Features using WebSockets or complex transport
129129

130-
Some features depend on **WebSockets** or other non-HTTP transport (e.g. Perps/HyperLiquid, real-time data). The HTTP mock server cannot intercept these. The repo uses two patterns:
130+
Some features depend on **WebSockets** or other non-HTTP transport (e.g. Perps/HyperLiquid, real-time data). The HTTP mock server cannot intercept these. The repo uses three patterns:
131131

132-
1. **Controller-level mocking** — A mixin under `tests/controller-mocking/mock-config/` replaces provider SDK touchpoints so E2E runs with stable, test-controlled data. Example: `perps-controller-mixin.ts` for HyperLiquid. See **`tests/docs/CONTROLLER_MOCKING.md`** for when and how to use it.
133-
2. **Command queue / test server** — Tests that need to drive the app (e.g. inject state or commands) can use **`CommandQueueServer`** (`tests/framework/fixtures/CommandQueueServer.ts`). Enable it in the fixture with `useCommandQueueServer: true`. Used by Perps specs (e.g. `tests/smoke/perps/perps-add-funds.spec.ts`, `tests/regression/perps/perps-limit-long-fill.spec.ts`). The app consumes the queue in E2E context.
132+
1. **WebSocket mocking** — A `LocalWebSocketServer` (`tests/websocket/server.ts`) intercepts production WebSocket connections via URL rewriting in the E2E shim. Protocol-specific mocks handle subscribe/unsubscribe and push notifications. See **`tests/docs/WEBSOCKET_MOCKING.md`** for full usage guide and how to add new services. Example: `tests/websocket/account-activity-mocks.ts` for AccountActivity.
133+
2. **Controller-level mocking** — A mixin under `tests/controller-mocking/mock-config/` replaces provider SDK touchpoints so E2E runs with stable, test-controlled data. Example: `perps-controller-mixin.ts` for HyperLiquid. See **`tests/docs/CONTROLLER_MOCKING.md`** for when and how to use it.
134+
3. **Command queue / test server** — Tests that need to drive the app (e.g. inject state or commands) can use **`CommandQueueServer`** (`tests/framework/fixtures/CommandQueueServer.ts`). Enable it in the fixture with `useCommandQueueServer: true`. Used by Perps specs (e.g. `tests/smoke/perps/perps-add-funds.spec.ts`, `tests/regression/perps/perps-limit-long-fill.spec.ts`). The app consumes the queue in E2E context.
134135

135136
**When adding support for a new feature that uses WebSockets or similar:**
136137

137-
- Follow the **same pattern** as existing features (controller mixin and/or CommandQueueServer).
138-
- Implement under `tests/controller-mocking/mock-config/` or extend the command-queue protocol as needed.
138+
- For WebSocket services: add a service config in `tests/websocket/constants.ts` and a protocol mock. See `tests/docs/WEBSOCKET_MOCKING.md`.
139+
- For SDK-level mocking: implement under `tests/controller-mocking/mock-config/`.
140+
- For test-driven commands: extend the command-queue protocol as needed.
139141
- Add or update **tests/specs** that cover the mock infrastructure and the E2E flow.
140142

141-
Prefer HTTP mocking whenever the feature’s API is plain HTTP; use controller mocking or the command server only when necessary.
143+
Prefer HTTP mocking whenever the feature’s API is plain HTTP; use WebSocket mocking for WS connections; use controller mocking or the command server only when necessary.

app/component-library/components-temp/ButtonFilter/ButtonFilter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ButtonFilterProps } from './ButtonFilter.types';
99
* @deprecated Please update your code to use `ButtonFilter` from `@metamask/design-system-react-native`.
1010
* The API may have changed — compare props before migrating.
1111
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/ButtonFilter/README.md}
12+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#buttonfilter-component Migration docs}
1213
* @since @metamask/design-system-react-native@0.11.0
1314
*/
1415
const ButtonFilter = ({

app/component-library/components-temp/Buttons/ButtonHero/ButtonHero.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const ButtonHeroInner = ({
6060
* @deprecated Please update your code to use `ButtonHero` from `@metamask/design-system-react-native`.
6161
* The API may have changed - compare props before migrating.
6262
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/ButtonHero/README.md}
63+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#buttonhero-component Migration docs}
6364
*/
6465
const ButtonHero = (props: ButtonBaseProps) => (
6566
<ThemeProvider theme={Theme.Light}>

app/component-library/components/Banners/Banner/foundation/BannerBase/BannerBase.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
* @deprecated Please update your code to use `BannerBase` from `@metamask/design-system-react-native`.
2929
* The API may have changed — compare props before migrating.
3030
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/BannerBase/README.md}
31+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#bannerbase-component Migration docs}
3132
* @since @metamask/design-system-react-native@0.11.0
3233
*/
3334
const BannerBase: React.FC<BannerBaseProps> = ({

app/component-library/components/BottomSheets/BottomSheet/BottomSheet.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import BottomSheetDialog, {
3535
* @deprecated Please update your code to use `BottomSheet` from `@metamask/design-system-react-native`.
3636
* The API may have changed — compare props before migrating.
3737
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/BottomSheet/README.md}
38+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#bottomsheet-component Migration docs}
3839
* @since @metamask/design-system-react-native@0.11.0
3940
*/
4041
const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(

app/component-library/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
* @deprecated Please update your code to use `BottomSheetFooter` from `@metamask/design-system-react-native`.
2323
* The API may have changed — compare props before migrating.
2424
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/BottomSheets/BottomSheetFooter/README.md}
25+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#bottomsheetfooter-component Migration docs}
2526
* @since @metamask/design-system-react-native@0.7.0
2627
*/
2728
const BottomSheetFooter: React.FC<BottomSheetFooterProps> = ({

app/component-library/components/BottomSheets/BottomSheetHeader/BottomSheetHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
* @deprecated Please update your code to use `BottomSheetHeader` from `@metamask/design-system-react-native`.
2424
* The API may have changed - compare props before migrating.
2525
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/BottomSheetHeader/README.md}
26+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#bottomsheetheader-component Migration docs}
2627
*/
2728
const BottomSheetHeader: React.FC<BottomSheetHeaderProps> = ({
2829
style,

app/component-library/components/Buttons/Button/foundation/ButtonBase/ButtonBase.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
* @deprecated Please update your code to use `ButtonBase` from `@metamask/design-system-react-native`.
2525
* The API may have changed - compare props before migrating.
2626
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/ButtonBase/README.md}
27+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#buttonbase-component Migration docs}
2728
*/
2829
const ButtonBase = ({
2930
label,

app/component-library/components/Buttons/Button/variants/ButtonLink/ButtonLink.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
*
3535
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/TextButton/README.md | TextButton}
3636
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/Button/README.md | Button}
37+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#textbutton-component-buttonlink Migration docs}
3738
*/
3839
const ButtonLink: React.FC<ButtonLinkProps> = ({
3940
style,

app/component-library/components/Buttons/ButtonIcon/ButtonIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
* @deprecated Please update your code to use `ButtonIcon` from `@metamask/design-system-react-native`.
2222
* The API may have changed — compare props before migrating.
2323
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/ButtonIcon/README.md}
24+
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#buttonicon-component Migration docs}
2425
*/
2526
const ButtonIcon = ({
2627
iconName,

0 commit comments

Comments
 (0)