Skip to content

Commit

Permalink
Promote dev to master (#1085)
Browse files Browse the repository at this point in the history
* Remove leftover TODOs

* Remove text based locators

* Add `Known problems with MetaMask` section

* Remove Promise wrap from `cy.setupMetamask()` (#927)

* Fix localized Chrome's extension id (#928)

* Fix localized Chrome's extension id

* Improve id handling

---------

Co-authored-by: Piotr Frankowski <[email protected]>

* Lint

* Feature/revoke permission to all (#932)

* Fix typo in Permission word

* Add permission revoking actions

* Add tests for permission revoking actions

* Regenerate synpress commands file

* Add `switchNetwork` option to `acceptAccess` function

* Add new release section to README

* Use `goerli` for testing (#1082)

* Use `goerli` for testing

* Trigger tests

* Add `shouldWaitForPopupClosure` option to approvals and txs (#1081)

---------

Co-authored-by: Peter F <[email protected]>
Co-authored-by: Piotr Frankowski <[email protected]>
Co-authored-by: Rafał Majchrzak <[email protected]>
  • Loading branch information
4 people authored Jan 25, 2024
1 parent f759b8e commit 99792cf
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 67 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ it directly. Check
[usage examples](https://github.com/Synthetixio/synpress/#usage-examples) for
more details.

# ♨️ New release

⚠️ This branch showcases the current stable release of Synpress which will receive **only** critical hotfixes. ⚠️

Active development of the upcoming version of Synpress is happening on [this branch](https://github.com/Synthetixio/synpress/tree/new-dawn).
The new release is a full rewrite of Synpress and will feature major breaking changes, and multitude of new features and improvements across the board such as:
- ⭐ Full TypeScript support
- ⭐ Multi-wallet support
- ⭐ Full parallelism support
- ⭐ Test runtime speed **faster** than any other Web3 alternative, and **equal** to native Web2 frameworks

Curious and want to learn more? 🤓

[Read this Twitter thread 🧵](https://twitter.com/0xDuckception/status/1712961542176596054) and do not forget to check out the attached document there!

# Table of content

- [](#)
Expand Down
14 changes: 10 additions & 4 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,10 @@ const metamask = {
);
return true;
},
async confirmPermissionToSpend(spendLimit) {
async confirmPermissionToSpend({
spendLimit,
shouldWaitForPopupClosure = false,
} = {}) {
const notificationPage = await playwright.switchToMetamaskNotification();
// experimental mode on
if (
Expand All @@ -874,7 +877,7 @@ const metamask = {
await playwright.waitAndClick(
notificationPageElements.allowToSpendButton,
notificationPage,
{ waitForEvent: 'close' },
shouldWaitForPopupClosure ? undefined : { waitForEvent: 'close' },
);
return true;
},
Expand Down Expand Up @@ -963,7 +966,10 @@ const metamask = {
);
return true;
},
async confirmTransaction(gasConfig) {
async confirmTransaction({
gasConfig,
shouldWaitForPopupClosure = false,
} = {}) {
let txData = {};
const notificationPage = await playwright.switchToMetamaskNotification();
if (gasConfig) {
Expand Down Expand Up @@ -1189,7 +1195,7 @@ const metamask = {
await playwright.waitAndClick(
confirmPageElements.confirmButton,
notificationPage,
{ waitForEvent: 'close' },
shouldWaitForPopupClosure ? undefined : { waitForEvent: 'close' },
);
txData.confirmed = true;
log('[confirmTransaction] Transaction confirmed!');
Expand Down
26 changes: 15 additions & 11 deletions docs/synpress-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ rejectMetamaskAddToken(): Chainable<boolean>;
Confirm metamask permission to spend asset.

```ts
confirmMetamaskPermissionToSpend(spendLimit?: string): Chainable<string>;
confirmMetamaskPermissionToSpend(options: {
spendLimit?: string
shouldWaitForPopupClosure?: boolean
}): Chainable<string>;
```

#### `cy.confirmMetamaskPermissionToApproveAll()`
Expand Down Expand Up @@ -415,22 +418,23 @@ rejectMetamaskAccess(): Chainable<boolean>;
Confirm metamask transaction (auto-detects eip-1559 and legacy transactions).

```ts
confirmMetamaskTransaction(
gasConfig?:
confirmMetamaskTransaction(options: {
gasConfig:
| {
gasLimit?: number;
baseFee?: number;
priorityFee?: number;
gasLimit?: number;
baseFee?: number;
priorityFee?: number;
}
| {
gasLimit?: number;
gasPrice?: number;
}
gasLimit?: number;
gasPrice?: number;
}
| 'low'
| 'market'
| 'aggressive'
| 'site',
): Chainable<Subject>;
| 'site',
shouldWaitForPopupClosure?: boolean
}): Chainable<Subject>;
```

#### `cy.confirmMetamaskTransactionAndWaitForMining()`
Expand Down
22 changes: 17 additions & 5 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,14 @@ Cypress.Commands.add('rejectMetamaskAddToken', () => {

Cypress.Commands.add(
'confirmMetamaskPermissionToSpend',
(spendLimit = '999999999999999999') => {
return cy.task('confirmMetamaskPermissionToSpend', spendLimit);
({
spendLimit = '999999999999999999',
shouldWaitForPopupClosure = false,
} = {}) => {
return cy.task('confirmMetamaskPermissionToSpend', {
spendLimit,
shouldWaitForPopupClosure,
});
},
);

Expand All @@ -192,9 +198,15 @@ Cypress.Commands.add('rejectMetamaskAccess', () => {
return cy.task('rejectMetamaskAccess');
});

Cypress.Commands.add('confirmMetamaskTransaction', gasConfig => {
return cy.task('confirmMetamaskTransaction', gasConfig);
});
Cypress.Commands.add(
'confirmMetamaskTransaction',
({ gasConfig, shouldWaitForPopupClosure = false } = {}) => {
return cy.task('confirmMetamaskTransaction', {
gasConfig,
shouldWaitForPopupClosure,
});
},
);

Cypress.Commands.add(
'confirmMetamaskTransactionAndWaitForMining',
Expand Down
36 changes: 21 additions & 15 deletions support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,13 @@ declare namespace Cypress {
* Confirm metamask permission to spend asset
* @example
* cy.confirmMetamaskPermissionToSpend()
* cy.confirmMetamaskPermissionToSpend('999999999')
* cy.confirmMetamaskPermissionToSpend({ spendLimit: '999999999' })
* cy.confirmMetamaskPermissionToSpend({ spendLimit: '999999999', shouldWaitForPopupClosure: false })
*/
confirmMetamaskPermissionToSpend(spendLimit?: string): Chainable<string>;
confirmMetamaskPermissionToSpend(options: {
spendLimit?: string
shouldWaitForPopupClosure?: boolean
}): Chainable<string>;
/**
* Confirm metamask permission to access all elements (example: collectibles)
* @example
Expand Down Expand Up @@ -327,26 +331,28 @@ declare namespace Cypress {
* Confirm metamask transaction (auto-detects eip-1559 and legacy transactions)
* @example
* cy.confirmMetamaskTransaction()
* cy.confirmMetamaskTransaction({ gasLimit: 1000000, baseFee: 20, priorityFee: 20 }) // eip-1559
* cy.confirmMetamaskTransaction({ gasLimit: 1000000, gasPrice: 20 }) // legacy
* cy.confirmMetamaskTransaction('aggressive') // eip-1559 only! => available options: 'low', 'market', 'aggressive', 'site' (site is usually by default)
* cy.confirmMetamaskTransaction({ gasConfig: { gasLimit: 1000000, baseFee: 20, priorityFee: 20 } }) // eip-1559
* cy.confirmMetamaskTransaction({ gasConfig: { gasLimit: 1000000, gasPrice: 20 } }) // legacy
* cy.confirmMetamaskTransaction({ gasConfig: 'aggressive' }) // eip-1559 only! => available options: 'low', 'market', 'aggressive', 'site' (site is usually by default)
* cy.confirmMetamaskTransaction({ shouldWaitForPopupClosure: false })
*/
confirmMetamaskTransaction(
gasConfig?:
confirmMetamaskTransaction(options: {
gasConfig:
| {
gasLimit?: number;
baseFee?: number;
priorityFee?: number;
}
gasLimit?: number;
baseFee?: number;
priorityFee?: number;
}
| {
gasLimit?: number;
gasPrice?: number;
}
gasLimit?: number;
gasPrice?: number;
}
| 'low'
| 'market'
| 'aggressive'
| 'site',
): Chainable<Subject>;
shouldWaitForPopupClosure?: boolean
}): Chainable<Subject>;
/**
* Confirm metamask transaction (auto-detects eip-1559 and legacy transactions) and wait for ALL pending transactions to be mined
* @example
Expand Down
Loading

0 comments on commit 99792cf

Please sign in to comment.