Skip to content

Commit 3f1515b

Browse files
authored
Merge branch 'dev' into fix/align-cache-hashes
2 parents 0f1df5c + b37d84b commit 3f1515b

File tree

14 files changed

+183
-4
lines changed

14 files changed

+183
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pnpm add -D @synthetixio/synpress@latest
4545

4646
## 📝 Documentation
4747

48-
For comprehensive guides, API references, and examples, refer to our [official documentation](https://synpress.io/docs/getting-started).
48+
For comprehensive guides, API references, and examples, refer to our [official documentation](https://docs.synpress.io/docs/introduction).
4949

5050
## 🧑‍🤝‍🧑 Community
5151

docs/api/cypress/classes/MetaMask.md

+32
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ True if the token was added successfully
101101

102102
***
103103

104+
### approveNewEthereumRPC()
105+
106+
```ts
107+
approveNewEthereumRPC(): Promise<boolean>
108+
```
109+
110+
Approves adding a new RPC provider for Ethereum Mainnet.
111+
112+
#### Returns
113+
114+
`Promise`\<`boolean`\>
115+
116+
True if the RPC provider was added successfully
117+
118+
***
119+
104120
### approveNewNetwork()
105121

106122
```ts
@@ -558,6 +574,22 @@ True if the key was provided successfully, false otherwise
558574
559575
***
560576
577+
### rejectNewEthereumRPC()
578+
579+
```ts
580+
rejectNewEthereumRPC(): Promise<boolean>
581+
```
582+
583+
Rejects adding a new RPC provider for Ethereum Mainnet.
584+
585+
#### Returns
586+
587+
`Promise`\<`boolean`\>
588+
589+
True if the new RPC provided was rejected successfully
590+
591+
***
592+
561593
### rejectNewNetwork()
562594
563595
```ts

docs/api/playwright/classes/MetaMask.md

+36
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,24 @@ If extensionId is not set.
132132
133133
***
134134
135+
### approveNewEthereumRPC()
136+
137+
```ts
138+
approveNewEthereumRPC(): Promise<void>
139+
```
140+
141+
Approves adding a new RPC provider for Ethereum Mainnet.
142+
143+
#### Returns
144+
145+
`Promise`\<`void`\>
146+
147+
#### Throws
148+
149+
If extensionId is not set.
150+
151+
***
152+
135153
### approveNewNetwork()
136154
137155
```ts
@@ -586,6 +604,24 @@ If extensionId is not set.
586604
587605
***
588606
607+
### rejectNewEthereumRPC()
608+
609+
```ts
610+
rejectNewEthereumRPC(): Promise<void>
611+
```
612+
613+
Rejects adding a new RPC provider for Ethereum Mainnet.
614+
615+
#### Returns
616+
617+
`Promise`\<`void`\>
618+
619+
#### Throws
620+
621+
If extensionId is not set.
622+
623+
***
624+
589625
### rejectNewNetwork()
590626
591627
```ts

examples/metamask/cypress.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { configureSynpressForMetaMask } from '@synthetixio/synpress/cypress'
22
import { defineConfig } from 'cypress'
33

44
export default defineConfig({
5-
chromeWebSecurity: false,
5+
chromeWebSecurity: true,
66
e2e: {
77
baseUrl: 'http://localhost:9999',
88
specPattern: 'test/cypress/**/*.cy.{js,jsx,ts,tsx}',

wallets/metamask/src/cypress/MetaMask.ts

+20
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,26 @@ export default class MetaMask {
332332
return true
333333
}
334334

335+
/**
336+
* Approves adding a new RPC provider for Ethereum Mainnet.
337+
*
338+
* @returns True if the RPC provider was approved successfully
339+
*/
340+
async approveNewEthereumRPC(): Promise<boolean> {
341+
await this.metamaskPlaywright.approveNewEthereumRPC()
342+
return true
343+
}
344+
345+
/**
346+
* Rejects adding a new RPC provider for Ethereum Mainnet.
347+
*
348+
* @returns True if the RPC provider was rejected successfully
349+
*/
350+
async rejectNewEthereumRPC(): Promise<boolean> {
351+
await this.metamaskPlaywright.rejectNewEthereumRPC()
352+
return true
353+
}
354+
335355
/**
336356
* Locks the MetaMask wallet.
337357
* @returns True if the wallet was locked successfully

wallets/metamask/src/cypress/configureSynpress.ts

+2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ export default function configureSynpress(
135135
addNetwork: (network: Network) => metamask?.addNetwork(network),
136136
approveNewNetwork: () => metamask?.approveNewNetwork(),
137137
approveSwitchNetwork: () => metamask?.approveSwitchNetwork(),
138+
approveNewEthereumRPC: () => metamask?.approveNewEthereumRPC(),
138139
rejectNewNetwork: () => metamask?.rejectNewNetwork(),
139140
rejectSwitchNetwork: () => metamask?.rejectSwitchNetwork(),
141+
rejectNewEthereumRPC: () => metamask?.rejectNewEthereumRPC(),
140142

141143
// Anvil
142144
createAnvilNode: (options?: CreateAnvilOptions) => metamask?.createAnvilNode(options),

wallets/metamask/src/cypress/support/synpressCommands.ts

+16
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ declare global {
4242
addNetwork(network: Network): Chainable<void>
4343
approveNewNetwork(): Chainable<void>
4444
approveSwitchNetwork(): Chainable<void>
45+
approveNewEthereumRPC(): Chainable<void>
4546
rejectNewNetwork(): Chainable<void>
4647
rejectSwitchNetwork(): Chainable<void>
48+
rejectNewEthereumRPC(): Chainable<void>
4749

4850
deployToken(): Chainable<void>
4951
addNewToken(): Chainable<void>
@@ -268,6 +270,20 @@ export default function synpressCommandsForMetaMask(): void {
268270
return cy.task('rejectSwitchNetwork')
269271
})
270272

273+
/**
274+
* Approves adding a new RPC provider for Ethereum Mainnet
275+
*/
276+
Cypress.Commands.add('approveNewEthereumRPC', () => {
277+
return cy.task('approveNewEthereumRPC')
278+
})
279+
280+
/**
281+
* Rejects adding a new RPC provider for Ethereum Mainnet
282+
*/
283+
Cypress.Commands.add('rejectNewEthereumRPC', () => {
284+
return cy.task('rejectNewEthereumRPC')
285+
})
286+
271287
// Token
272288

273289
/**

wallets/metamask/src/playwright/MetaMask.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,41 @@ export class MetaMask extends MetaMaskAbstract {
283283
await this.notificationPage.rejectSwitchNetwork(this.extensionId)
284284
}
285285

286+
/**
287+
* Approves adding a new RPC provider for Ethereum Mainnet.
288+
*
289+
* @throws {Error} If extensionId is not set.
290+
*/
291+
async approveNewEthereumRPC(): Promise<void> {
292+
if (!this.extensionId) {
293+
throw NO_EXTENSION_ID_ERROR
294+
}
295+
296+
await this.notificationPage.approveNewEthereumRPC(this.extensionId)
297+
}
298+
299+
/**
300+
* Rejects adding a new RPC provider for Ethereum Mainnet.
301+
*
302+
* @throws {Error} If extensionId is not set.
303+
*/
304+
async rejectNewEthereumRPC(): Promise<void> {
305+
if (!this.extensionId) {
306+
throw NO_EXTENSION_ID_ERROR
307+
}
308+
309+
await this.notificationPage.rejectNewEthereumRPC(this.extensionId)
310+
}
311+
286312
/**
287313
* Confirms a transaction.
288314
*
289315
* @param options - Optional gas settings for the transaction.
290316
* @throws {Error} If extensionId is not set.
291317
*/
292-
async confirmTransaction(options?: { gasSetting?: GasSettings }): Promise<void> {
318+
async confirmTransaction(options?: {
319+
gasSetting?: GasSettings
320+
}): Promise<void> {
293321
if (!this.extensionId) {
294322
throw NO_EXTENSION_ID_ERROR
295323
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Page } from '@playwright/test'
2+
import Selectors from '../../../../selectors/pages/NotificationPage'
3+
4+
const approveNewEthereumRPC = async (notificationPage: Page) => {
5+
await notificationPage.locator(Selectors.EthereumRpcPage.approveNewRpc).click()
6+
}
7+
8+
const rejectNewEthereumRPC = async (notificationPage: Page) => {
9+
await notificationPage.locator(Selectors.EthereumRpcPage.rejectNewRpc).click()
10+
}
11+
12+
export const ethereumRpc = {
13+
approveNewEthereumRPC,
14+
rejectNewEthereumRPC
15+
}

wallets/metamask/src/playwright/pages/NotificationPage/actions/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export * from './transaction'
66
export * from './network'
77
export * from './token'
88
export * from './encryption'
9+
export * from './ethereumRpc'

wallets/metamask/src/playwright/pages/NotificationPage/page.ts

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
approvePermission,
77
connectToDapp,
88
decryptMessage,
9+
ethereumRpc,
910
network,
1011
providePublicEncryptionKey,
1112
signSimpleMessage,
@@ -99,6 +100,18 @@ export class NotificationPage {
99100
await network.rejectSwitchNetwork(notificationPage)
100101
}
101102

103+
async approveNewEthereumRPC(extensionId: string) {
104+
const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId)
105+
106+
await ethereumRpc.approveNewEthereumRPC(notificationPage)
107+
}
108+
109+
async rejectNewEthereumRPC(extensionId: string) {
110+
const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId)
111+
112+
await ethereumRpc.rejectNewEthereumRPC(notificationPage)
113+
}
114+
102115
async confirmTransaction(extensionId: string, options?: { gasSetting?: GasSettings }) {
103116
const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId)
104117

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
approveNewRpc: '.confirmation-warning-modal__content .mm-button-primary--type-danger',
3+
rejectNewRpc: '.confirmation-warning-modal__content .mm-button-secondary'
4+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ActionFooter from './actionFooter'
22
import ConnectPage from './connectPage'
3+
import EthereumRpcPage from './ethereumRpcPage'
34
import NetworkPage from './networkPage'
45
import PermissionPage from './permissionPage'
56
import SignaturePage from './signaturePage'
@@ -8,8 +9,9 @@ import TransactionPage from './transactionPage'
89
export default {
910
ActionFooter,
1011
ConnectPage,
11-
SignaturePage,
12+
EthereumRpcPage,
1213
NetworkPage,
1314
PermissionPage,
15+
SignaturePage,
1416
TransactionPage
1517
}

wallets/metamask/src/type/MetaMaskAbstract.ts

+10
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ export abstract class MetaMaskAbstract {
126126
*/
127127
abstract rejectSwitchNetwork(): void
128128

129+
/**
130+
* Approves a new RPC provider request.
131+
*/
132+
abstract approveNewEthereumRPC(): void
133+
134+
/**
135+
* Rejects a new RPC provider request.
136+
*/
137+
abstract rejectNewEthereumRPC(): void
138+
129139
/**
130140
* Confirms a transaction request.
131141
*

0 commit comments

Comments
 (0)