diff --git a/.changeset/fresh-walls-nail.md b/.changeset/fresh-walls-nail.md new file mode 100644 index 000000000..0324417f0 --- /dev/null +++ b/.changeset/fresh-walls-nail.md @@ -0,0 +1,9 @@ +--- +"@synthetixio/synpress": major +"@synthetixio/synpress-core": patch +"@synthetixio/synpress-fixtures": patch +"@synthetixio/synpress-tsconfig": patch +"@synthetixio/synpress-metamask": patch +--- + +Initial Alpha Release diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..9d1022277 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,14 @@ +{ + "mode": "pre", + "tag": "alpha", + "initialVersions": { + "docs": "0.0.0", + "example-new-dawn": "0.0.0", + "@synthetixio/synpress-core": "0.0.0", + "@synthetixio/synpress-fixtures": "0.0.0", + "@synthetixio/synpress-tsconfig": "0.0.0", + "@synthetixio/synpress": "3.0.0", + "@synthetixio/synpress-metamask": "0.0.0" + }, + "changesets": ["fresh-walls-nail"] +} diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 000000000..f57e91fbe --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,39 @@ +# Deployment Guide + +## Materials worth reading + +- https://github.com/changesets/changesets/blob/main/docs/intro-to-using-changesets.md +- https://github.com/changesets/changesets/blob/main/docs/prereleases.md + +## How to deploy + +⚠️ Remember to run all the commands from the root directory of the repository! + +1. Run the following command to select the package to be released: + +```bash +pnpm changeset +``` + +2. Consume the changeset by running: + +```bash +pnpm changeset version +``` + +3. Verify all the `package.json` and `CHANGELOG.md` files that were changed by the previous command. + +4. Publish the packages by running: + +```bash +# You might have to run this command twice if it fails to publish the `@synthetixio/synpress` package on the first run. +pnpm changeset publish +``` + +## Tags + +If you're running in prerelease mode, make sure you're also pushing the release tags to GitHub with: + +```bash +git push --follow-tags +``` diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 00bf0067a..abd32544a 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -9,6 +9,7 @@ export default defineConfig({ title: 'Synpress', description: 'E2E testing library for Web3 dapps.', lastUpdated: true, + head: [['link', { rel: 'icon', href: '/favicon.ico' }]], themeConfig: { editLink: { pattern: 'https://github.com/Synthetixio/synpress/tree/new-dawn/docs/:path', diff --git a/docs/api/classes/MetaMask.md b/docs/api/classes/MetaMask.md index 993969147..3051ef60d 100644 --- a/docs/api/classes/MetaMask.md +++ b/docs/api/classes/MetaMask.md @@ -11,8 +11,8 @@ This class is the heart of Synpress's MetaMask API. - [addNetwork()](MetaMask.md#addnetwork) - [addNewAccount()](MetaMask.md#addnewaccount) - [approveNewNetwork()](MetaMask.md#approvenewnetwork) - - [approvePermission()](MetaMask.md#approvepermission) - [approveSwitchNetwork()](MetaMask.md#approveswitchnetwork) + - [approveTokenPermission()](MetaMask.md#approvetokenpermission) - [confirmSignature()](MetaMask.md#confirmsignature) - [confirmTransaction()](MetaMask.md#confirmtransaction) - [connectToDapp()](MetaMask.md#connecttodapp) @@ -23,9 +23,9 @@ This class is the heart of Synpress's MetaMask API. - [openSettings()](MetaMask.md#opensettings) - [openSidebarMenu()](MetaMask.md#opensidebarmenu) - [rejectNewNetwork()](MetaMask.md#rejectnewnetwork) - - [rejectPermission()](MetaMask.md#rejectpermission) - [rejectSignature()](MetaMask.md#rejectsignature) - [rejectSwitchNetwork()](MetaMask.md#rejectswitchnetwork) + - [rejectTokenPermission()](MetaMask.md#rejecttokenpermission) - [rejectTransaction()](MetaMask.md#rejecttransaction) - [resetAccount()](MetaMask.md#resetaccount) - [switchAccount()](MetaMask.md#switchaccount) @@ -138,16 +138,30 @@ Approves a new network request. *** -### approvePermission() +### approveSwitchNetwork() + +```ts +approveSwitchNetwork(): Promise +``` + +Approves a switch network request. + +#### Returns + +`Promise`\<`void`\> + +*** + +### approveTokenPermission() ```ts -approvePermission(options?): Promise +approveTokenPermission(options?): Promise ``` Approves a permission request to spend tokens. ::: warning -This function does not work with the NFTs approvals. +For NFT approvals, use `confirmTransaction` method. ::: #### Parameters @@ -164,20 +178,6 @@ This function does not work with the NFTs approvals. *** -### approveSwitchNetwork() - -```ts -approveSwitchNetwork(): Promise -``` - -Approves a switch network request. - -#### Returns - -`Promise`\<`void`\> - -*** - ### confirmSignature() ```ts @@ -343,17 +343,13 @@ Rejects a new network request. *** -### rejectPermission() +### rejectSignature() ```ts -rejectPermission(): Promise +rejectSignature(): Promise ``` -Rejects a permission request to spend tokens. - -::: warning -This function does not work with the NFTs approvals. -::: +Rejects a signature request. This function supports all types of commonly used signatures. #### Returns @@ -361,13 +357,13 @@ This function does not work with the NFTs approvals. *** -### rejectSignature() +### rejectSwitchNetwork() ```ts -rejectSignature(): Promise +rejectSwitchNetwork(): Promise ``` -Rejects a signature request. This function supports all types of commonly used signatures. +Rejects a switch network request. #### Returns @@ -375,13 +371,17 @@ Rejects a signature request. This function supports all types of commonly used s *** -### rejectSwitchNetwork() +### rejectTokenPermission() ```ts -rejectSwitchNetwork(): Promise +rejectTokenPermission(): Promise ``` -Rejects a switch network request. +Rejects a permission request to spend tokens. + +::: warning +For NFT approvals, use `confirmTransaction` method. +::: #### Returns diff --git a/docs/docs/known-issues.md b/docs/docs/known-issues.md index f871ce8d2..32144ecb5 100644 --- a/docs/docs/known-issues.md +++ b/docs/docs/known-issues.md @@ -15,3 +15,7 @@ If you require the previews for development purposes, your only option is to com ### MetaMask is not working in headless mode on GitHub Actions CI Due to a bug in MetaMask, it's impossible to run MetaMask in headless mode on GitHub Actions. We're certain this bug affects other CI providers, however, we have yet to test it. + +::: warning NOTE +You can run the tests in the headful mode on CI, and they will work just fine. +::: diff --git a/docs/package.json b/docs/package.json index ba6dd7bd8..981ba4415 100644 --- a/docs/package.json +++ b/docs/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "@synthetixio/synpress": "workspace:*", - "tsconfig": "workspace:*", + "@synthetixio/synpress-tsconfig": "workspace:*", "typedoc": "^0.25.6", "typedoc-plugin-markdown": "4.0.0-next.38", "typedoc-vitepress-theme": "^1.0.0-next.4", diff --git a/docs/public/favicon.ico b/docs/public/favicon.ico new file mode 100644 index 000000000..66b08d637 Binary files /dev/null and b/docs/public/favicon.ico differ diff --git a/docs/tsconfig.json b/docs/tsconfig.json index da24f2723..bb0ba38bc 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "tsconfig/base.json", + "extends": "@synthetixio/synpress-tsconfig/base.json", "compilerOptions": { "rootDir": "." }, diff --git a/examples/new-dawn/package.json b/examples/new-dawn/package.json index e03e28558..acf989e55 100644 --- a/examples/new-dawn/package.json +++ b/examples/new-dawn/package.json @@ -13,8 +13,8 @@ "test:e2e:headless:ui": "HEADLESS=true playwright test --ui" }, "dependencies": { - "@playwright/test": "1.40.0", - "@synthetixio/synpress": "0.0.0-devtest-20231206214259", + "@playwright/test": "1.41.1", + "@synthetixio/synpress": "4.0.0-alpha.0", "dotenv": "16.3.1" }, "devDependencies": { diff --git a/examples/new-dawn/test/e2e/03_advanced.spec.ts b/examples/new-dawn/test/e2e/03_advanced.spec.ts index 6affb6d2e..3641b9293 100644 --- a/examples/new-dawn/test/e2e/03_advanced.spec.ts +++ b/examples/new-dawn/test/e2e/03_advanced.spec.ts @@ -14,7 +14,7 @@ describe('Token', () => { await deployToken() await page.locator('#approveTokens').click() - await metamask.approvePermission() + await metamask.approveTokenPermission() }) }) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md new file mode 100644 index 000000000..345046110 --- /dev/null +++ b/packages/core/CHANGELOG.md @@ -0,0 +1,7 @@ +# @synthetixio/synpress-core + +## 0.0.1-alpha.0 + +### Patch Changes + +- Initial Alpha Release diff --git a/packages/core/package.json b/packages/core/package.json index 8d8304e55..c0bb41bda 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@synthetixio/synpress-core", - "version": "0.0.0", + "version": "0.0.1-alpha.0", "type": "module", "exports": { "types": "./types/index.d.ts", @@ -42,6 +42,7 @@ "zod": "^3.22.4" }, "devDependencies": { + "@synthetixio/synpress-tsconfig": "0.0.1-alpha.0", "@types/archiver": "^5.3.3", "@types/fs-extra": "^11.0.2", "@types/gradient-string": "^1.1.4", @@ -53,7 +54,6 @@ "memfs": "^4.5.0", "msw": "^2.0.11", "rimraf": "^5.0.1", - "tsconfig": "workspace:*", "typescript": "^5.2.2", "vitest": "^0.34.6" }, diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index 97afa3ef9..9af73f809 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -1,5 +1,5 @@ { - "extends": "tsconfig/base.json", + "extends": "@synthetixio/synpress-tsconfig/base.json", "compilerOptions": { "rootDir": "src", "outDir": "types", diff --git a/packages/fixtures/CHANGELOG.md b/packages/fixtures/CHANGELOG.md new file mode 100644 index 000000000..2fd213653 --- /dev/null +++ b/packages/fixtures/CHANGELOG.md @@ -0,0 +1,7 @@ +# @synthetixio/synpress-fixtures + +## 0.0.1-alpha.0 + +### Patch Changes + +- Initial Alpha Release diff --git a/packages/fixtures/package.json b/packages/fixtures/package.json index f734bb4cf..5a9a4d702 100644 --- a/packages/fixtures/package.json +++ b/packages/fixtures/package.json @@ -1,6 +1,6 @@ { "name": "@synthetixio/synpress-fixtures", - "version": "0.0.0", + "version": "0.0.1-alpha.0", "type": "module", "exports": { "types": "./types/index.d.ts", @@ -25,16 +25,16 @@ "types:check": "tsc --noEmit" }, "dependencies": { - "@synthetixio/synpress-core": "workspace:*", + "@synthetixio/synpress-core": "0.0.1-alpha.0", "@viem/anvil": "^0.0.6", "fs-extra": "^11.1.1", "zod": "^3.22.4" }, "devDependencies": { + "@synthetixio/synpress-tsconfig": "0.0.1-alpha.0", "@types/fs-extra": "^11.0.2", "@types/node": "^20.8.0", "rimraf": "^5.0.1", - "tsconfig": "workspace:*", "tsup": "^7.2.0", "typescript": "^5.2.2" }, diff --git a/packages/fixtures/tsconfig.json b/packages/fixtures/tsconfig.json index 97afa3ef9..9af73f809 100644 --- a/packages/fixtures/tsconfig.json +++ b/packages/fixtures/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "tsconfig/base.json", + "extends": "@synthetixio/synpress-tsconfig/base.json", "compilerOptions": { "rootDir": "src", "outDir": "types", diff --git a/packages/tsconfig/CHANGELOG.md b/packages/tsconfig/CHANGELOG.md new file mode 100644 index 000000000..747e3b622 --- /dev/null +++ b/packages/tsconfig/CHANGELOG.md @@ -0,0 +1,7 @@ +# @synthetixio/synpress-tsconfig + +## 0.0.1-alpha.0 + +### Patch Changes + +- Initial Alpha Release diff --git a/packages/tsconfig/package.json b/packages/tsconfig/package.json index 00010618d..a7f8ac82a 100644 --- a/packages/tsconfig/package.json +++ b/packages/tsconfig/package.json @@ -1,7 +1,7 @@ { - "name": "tsconfig", - "version": "0.0.0", - "private": true, + "name": "@synthetixio/synpress-tsconfig", + "version": "0.0.1-alpha.0", + "type": "module", "files": [ "base.json" ] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 30388fdbc..93458a7bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,7 +41,7 @@ importers: '@synthetixio/synpress': specifier: workspace:* version: link:../release - tsconfig: + '@synthetixio/synpress-tsconfig': specifier: workspace:* version: link:../packages/tsconfig typedoc: @@ -60,11 +60,11 @@ importers: examples/new-dawn: dependencies: '@playwright/test': - specifier: 1.40.0 - version: 1.40.0 + specifier: 1.41.1 + version: 1.41.1 '@synthetixio/synpress': - specifier: 0.0.0-devtest-20231206214259 - version: 0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2) + specifier: 4.0.0-alpha.0 + version: 4.0.0-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2) dotenv: specifier: 16.3.1 version: 16.3.1 @@ -121,6 +121,9 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: + '@synthetixio/synpress-tsconfig': + specifier: 0.0.1-alpha.0 + version: link:../tsconfig '@types/archiver': specifier: ^5.3.3 version: 5.3.3 @@ -154,9 +157,6 @@ importers: rimraf: specifier: ^5.0.1 version: 5.0.1 - tsconfig: - specifier: workspace:* - version: link:../tsconfig typescript: specifier: ^5.2.2 version: 5.2.2 @@ -170,7 +170,7 @@ importers: specifier: ^1.41.1 version: 1.41.1 '@synthetixio/synpress-core': - specifier: workspace:* + specifier: 0.0.1-alpha.0 version: link:../core '@viem/anvil': specifier: ^0.0.6 @@ -182,6 +182,9 @@ importers: specifier: ^3.22.4 version: 3.22.4 devDependencies: + '@synthetixio/synpress-tsconfig': + specifier: 0.0.1-alpha.0 + version: link:../tsconfig '@types/fs-extra': specifier: ^11.0.2 version: 11.0.2 @@ -191,9 +194,6 @@ importers: rimraf: specifier: ^5.0.1 version: 5.0.1 - tsconfig: - specifier: workspace:* - version: link:../tsconfig tsup: specifier: ^7.2.0 version: 7.2.0(typescript@5.2.2) @@ -209,24 +209,24 @@ importers: specifier: ^1.41.1 version: 1.41.1 '@synthetixio/synpress-core': - specifier: workspace:* + specifier: 0.0.1-alpha.0 version: link:../packages/core '@synthetixio/synpress-fixtures': - specifier: workspace:* + specifier: 0.0.1-alpha.0 version: link:../packages/fixtures '@synthetixio/synpress-metamask': - specifier: workspace:* + specifier: 0.0.1-alpha.0 version: link:../wallets/metamask devDependencies: + '@synthetixio/synpress-tsconfig': + specifier: 0.0.1-alpha.0 + version: link:../packages/tsconfig '@types/node': specifier: ^20.8.0 version: 20.8.0 rimraf: specifier: ^5.0.1 version: 5.0.1 - tsconfig: - specifier: workspace:* - version: link:../packages/tsconfig tsup: specifier: ^7.2.0 version: 7.2.0(typescript@5.2.2) @@ -240,15 +240,18 @@ importers: specifier: ^1.41.1 version: 1.41.1 '@synthetixio/synpress-core': - specifier: workspace:* + specifier: 0.0.1-alpha.0 version: link:../../packages/core '@synthetixio/synpress-fixtures': - specifier: workspace:* + specifier: 0.0.1-alpha.0 version: link:../../packages/fixtures zod: specifier: ^3.22.4 version: 3.22.4 devDependencies: + '@synthetixio/synpress-tsconfig': + specifier: 0.0.1-alpha.0 + version: link:../../packages/tsconfig '@types/node': specifier: ^20.8.0 version: 20.8.0 @@ -258,9 +261,6 @@ importers: rimraf: specifier: ^5.0.1 version: 5.0.1 - tsconfig: - specifier: workspace:* - version: link:../../packages/tsconfig tsup: specifier: ^7.2.0 version: 7.2.0(typescript@5.2.2) @@ -1287,14 +1287,6 @@ packages: requiresBuild: true optional: true - /@playwright/test@1.40.0: - resolution: {integrity: sha512-PdW+kn4eV99iP5gxWNSDQCbhMaDVej+RXL5xr6t04nbKLCBwYtA046t7ofoczHOm8u6c+45hpDKQVZqtqwkeQg==} - engines: {node: '>=16'} - hasBin: true - dependencies: - playwright: 1.40.0 - dev: false - /@playwright/test@1.41.1: resolution: {integrity: sha512-9g8EWTjiQ9yFBXc6HjCWe41msLpxEX0KhmfmPl9RPLJdfzL4F0lg2BdJ91O9azFdl11y1pmpwdjBiSxvqc+btw==} engines: {node: '>=16'} @@ -1411,11 +1403,11 @@ packages: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true - /@synthetixio/synpress-core@0.0.0-devtest-20231206214259(playwright-core@1.40.0)(typescript@5.3.2): - resolution: {integrity: sha512-QVn0R7l6o2PBF9KOEJZ39SQtcQNd0UXPDdICcO1nIIeJjVIFWAX0J151ovBkaL/pB1X5ydqsoQjdOniutn1t+Q==} + /@synthetixio/synpress-core@0.0.1-alpha.0(playwright-core@1.41.1)(typescript@5.3.2): + resolution: {integrity: sha512-r8mJSt3B90aLJqnXXFSfpjv1ucOfrZ9Q8iRdAuKtxHwrc/C7r7LfwiuxED/c2/rOjelZXntlLtKrbQs+Q5C8nw==} hasBin: true peerDependencies: - playwright-core: 1.40.0 + playwright-core: ^1.41.1 dependencies: axios: 1.5.0 chalk: 5.3.0 @@ -1424,7 +1416,8 @@ packages: fs-extra: 11.1.1 glob: 10.3.10 gradient-string: 2.0.2 - playwright-core: 1.40.0 + playwright-core: 1.41.1 + progress: 2.0.3 tsup: 7.2.0(typescript@5.3.2) unzipper: 0.10.14 zod: 3.22.4 @@ -1437,13 +1430,13 @@ packages: - typescript dev: false - /@synthetixio/synpress-fixtures@0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2): - resolution: {integrity: sha512-PyLRLwXDcr1HbOd4e7hcetPjbpj48SbZiJGjw4mjj9luRMdjcgkbwXesNQkEtAjZiwSmYjVyCfur1mWUsbC62w==} + /@synthetixio/synpress-fixtures@0.0.1-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2): + resolution: {integrity: sha512-vRO2nPbN585s0d6sO1ekxQLwyp7r5JJN7Nu7Eya/KTZ2nEApbCSd8hmTyAepkUCl771GhcSD+ITyqPA78OYf/A==} peerDependencies: - '@playwright/test': 1.40.0 + '@playwright/test': ^1.41.1 dependencies: - '@playwright/test': 1.40.0 - '@synthetixio/synpress-core': 0.0.0-devtest-20231206214259(playwright-core@1.40.0)(typescript@5.3.2) + '@playwright/test': 1.41.1 + '@synthetixio/synpress-core': 0.0.1-alpha.0(playwright-core@1.41.1)(typescript@5.3.2) '@viem/anvil': 0.0.6 fs-extra: 11.1.1 zod: 3.22.4 @@ -1459,14 +1452,14 @@ packages: - utf-8-validate dev: false - /@synthetixio/synpress-metamask@0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2): - resolution: {integrity: sha512-ltEGW51ksVOvvubAzLDFQVbDE1pJzhD4k4GF8EX91MFqN45PJfElqX2AStJkGvaqgF7oRJr9CT0wAVBHfzOnvw==} + /@synthetixio/synpress-metamask@0.0.1-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2): + resolution: {integrity: sha512-gdTeb5K5v0rCpzxm4A3LSu7K/Qst8RDrnsV0RPIBRkSnL6wOIkx3Nyj/DNKSKt3WSrtMeFICscCcJVJbrZWD3A==} peerDependencies: - '@playwright/test': 1.40.0 + '@playwright/test': ^1.41.1 dependencies: - '@playwright/test': 1.40.0 - '@synthetixio/synpress-core': 0.0.0-devtest-20231206214259(playwright-core@1.40.0)(typescript@5.3.2) - '@synthetixio/synpress-fixtures': 0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2) + '@playwright/test': 1.41.1 + '@synthetixio/synpress-core': 0.0.1-alpha.0(playwright-core@1.41.1)(typescript@5.3.2) + '@synthetixio/synpress-fixtures': 0.0.1-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2) zod: 3.22.4 transitivePeerDependencies: - '@swc/core' @@ -1480,16 +1473,16 @@ packages: - utf-8-validate dev: false - /@synthetixio/synpress@0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2): - resolution: {integrity: sha512-WKTVDPpXDNU8Y/cF0y6T4ePNFU93VShsJ8ITzAlFK+ULAagwJNJaYZ/Ww0RoFEwPVQIW2EQhPA/uz44C8WuUbg==} + /@synthetixio/synpress@4.0.0-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2): + resolution: {integrity: sha512-wgMVMjNIlJVB/4rqcH5iiFotxTFJpVwbGIjrtmxVo0iiXo9GgSP5DRtImCMrLOfchJN+7G2J7lblnYUe1ajPrw==} hasBin: true peerDependencies: - '@playwright/test': 1.40.0 + '@playwright/test': ^1.41.1 dependencies: - '@playwright/test': 1.40.0 - '@synthetixio/synpress-core': 0.0.0-devtest-20231206214259(playwright-core@1.40.0)(typescript@5.3.2) - '@synthetixio/synpress-fixtures': 0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2) - '@synthetixio/synpress-metamask': 0.0.0-devtest-20231206214259(@playwright/test@1.40.0)(playwright-core@1.40.0)(typescript@5.3.2) + '@playwright/test': 1.41.1 + '@synthetixio/synpress-core': 0.0.1-alpha.0(playwright-core@1.41.1)(typescript@5.3.2) + '@synthetixio/synpress-fixtures': 0.0.1-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2) + '@synthetixio/synpress-metamask': 0.0.1-alpha.0(@playwright/test@1.41.1)(playwright-core@1.41.1)(typescript@5.3.2) transitivePeerDependencies: - '@swc/core' - bufferutil @@ -4357,28 +4350,12 @@ packages: pathe: 1.1.1 dev: true - /playwright-core@1.40.0: - resolution: {integrity: sha512-fvKewVJpGeca8t0ipM56jkVSU6Eo0RmFvQ/MaCQNDYm+sdvKkMBBWTE1FdeMqIdumRaXXjZChWHvIzCGM/tA/Q==} - engines: {node: '>=16'} - hasBin: true - dev: false - /playwright-core@1.41.1: resolution: {integrity: sha512-/KPO5DzXSMlxSX77wy+HihKGOunh3hqndhqeo/nMxfigiKzogn8kfL0ZBDu0L1RKgan5XHCPmn6zXd2NUJgjhg==} engines: {node: '>=16'} hasBin: true dev: false - /playwright@1.40.0: - resolution: {integrity: sha512-gyHAgQjiDf1m34Xpwzaqb76KgfzYrhK7iih+2IzcOCoZWr/8ZqmdBw+t0RU85ZmfJMgtgAiNtBQ/KS2325INXw==} - engines: {node: '>=16'} - hasBin: true - dependencies: - playwright-core: 1.40.0 - optionalDependencies: - fsevents: 2.3.2 - dev: false - /playwright@1.41.1: resolution: {integrity: sha512-gdZAWG97oUnbBdRL3GuBvX3nDDmUOuqzV/D24dytqlKt+eI5KbwusluZRGljx1YoJKZ2NRPaeWiFTeGZO7SosQ==} engines: {node: '>=16'} diff --git a/release/CHANGELOG.md b/release/CHANGELOG.md new file mode 100644 index 000000000..9d5206a22 --- /dev/null +++ b/release/CHANGELOG.md @@ -0,0 +1,7 @@ +# @synthetixio/synpress + +## 4.0.0-alpha.0 + +### Major Changes + +- Initial Alpha Release diff --git a/release/package.json b/release/package.json index 276cb695d..46ff1e3c1 100644 --- a/release/package.json +++ b/release/package.json @@ -1,6 +1,6 @@ { "name": "@synthetixio/synpress", - "version": "3.0.0", + "version": "4.0.0-alpha.0", "type": "module", "exports": { "types": "./types/index.d.ts", @@ -26,14 +26,14 @@ "types:check": "tsc --noEmit" }, "dependencies": { - "@synthetixio/synpress-core": "workspace:*", - "@synthetixio/synpress-fixtures": "workspace:*", - "@synthetixio/synpress-metamask": "workspace:*" + "@synthetixio/synpress-core": "0.0.1-alpha.0", + "@synthetixio/synpress-fixtures": "0.0.1-alpha.0", + "@synthetixio/synpress-metamask": "0.0.1-alpha.0" }, "devDependencies": { + "@synthetixio/synpress-tsconfig": "0.0.1-alpha.0", "@types/node": "^20.8.0", "rimraf": "^5.0.1", - "tsconfig": "workspace:*", "tsup": "^7.2.0", "typescript": "^5.2.2" }, diff --git a/release/tsconfig.json b/release/tsconfig.json index 228a21766..8ad5db0e8 100644 --- a/release/tsconfig.json +++ b/release/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "tsconfig/base.json", + "extends": "@synthetixio/synpress-tsconfig/base.json", "compilerOptions": { "rootDir": "src", "outDir": "types", diff --git a/vercel.json b/vercel.json new file mode 100644 index 000000000..bd6fd8faa --- /dev/null +++ b/vercel.json @@ -0,0 +1,3 @@ +{ + "cleanUrls": true +} diff --git a/wallets/metamask/CHANGELOG.md b/wallets/metamask/CHANGELOG.md new file mode 100644 index 000000000..6f1527340 --- /dev/null +++ b/wallets/metamask/CHANGELOG.md @@ -0,0 +1,7 @@ +# @synthetixio/synpress-metamask + +## 0.0.1-alpha.0 + +### Patch Changes + +- Initial Alpha Release diff --git a/wallets/metamask/package.json b/wallets/metamask/package.json index 2318d48fa..443d2fcde 100644 --- a/wallets/metamask/package.json +++ b/wallets/metamask/package.json @@ -1,6 +1,6 @@ { "name": "@synthetixio/synpress-metamask", - "version": "0.0.0", + "version": "0.0.1-alpha.0", "type": "module", "exports": { "types": "./types/index.d.ts", @@ -30,15 +30,15 @@ "types:check": "tsc --noEmit" }, "dependencies": { - "@synthetixio/synpress-core": "workspace:*", - "@synthetixio/synpress-fixtures": "workspace:*", + "@synthetixio/synpress-core": "0.0.1-alpha.0", + "@synthetixio/synpress-fixtures": "0.0.1-alpha.0", "zod": "^3.22.4" }, "devDependencies": { + "@synthetixio/synpress-tsconfig": "0.0.1-alpha.0", "@types/node": "^20.8.0", "@vitest/coverage-v8": "1.0.0-beta.0", "rimraf": "^5.0.1", - "tsconfig": "workspace:*", "tsup": "^7.2.0", "typescript": "^5.2.2", "vitest": "^0.34.6" diff --git a/wallets/metamask/src/metamask.ts b/wallets/metamask/src/metamask.ts index d85728d4e..e52b2ab0f 100644 --- a/wallets/metamask/src/metamask.ts +++ b/wallets/metamask/src/metamask.ts @@ -265,34 +265,34 @@ export class MetaMask { * Approves a permission request to spend tokens. * * ::: warning - * This function does not work with the NFTs approvals. + * For NFT approvals, use `confirmTransaction` method. * ::: * * @param options - The permission options. * @param options.spendLimit - The spend limit to use for the permission. * @param options.gasSetting - The gas setting to use for the approval transaction. */ - async approvePermission(options?: { spendLimit?: 'max' | number; gasSetting?: GasSetting }) { + async approveTokenPermission(options?: { spendLimit?: 'max' | number; gasSetting?: GasSetting }) { if (!this.extensionId) { throw NO_EXTENSION_ID_ERROR } - await this.notificationPage.approvePermission(this.extensionId, options) + await this.notificationPage.approveTokenPermission(this.extensionId, options) } /** * Rejects a permission request to spend tokens. * * ::: warning - * This function does not work with the NFTs approvals. + * For NFT approvals, use `confirmTransaction` method. * ::: */ - async rejectPermission() { + async rejectTokenPermission() { if (!this.extensionId) { throw NO_EXTENSION_ID_ERROR } - await this.notificationPage.rejectPermission(this.extensionId) + await this.notificationPage.rejectTokenPermission(this.extensionId) } /** diff --git a/wallets/metamask/src/pages/NotificationPage/actions/transaction.ts b/wallets/metamask/src/pages/NotificationPage/actions/transaction.ts index 3573bafbf..acce2b7cb 100644 --- a/wallets/metamask/src/pages/NotificationPage/actions/transaction.ts +++ b/wallets/metamask/src/pages/NotificationPage/actions/transaction.ts @@ -32,10 +32,31 @@ export type GasSetting = z.input const confirmTransaction = async (notificationPage: Page, options: GasSetting) => { const gasSetting = GasSetting.parse(options) + const handleNftSetApprovalForAll = async (page: Page) => { + try { + const nftApproveButtonLocator = page.locator( + Selectors.TransactionPage.nftApproveAllConfirmationPopup.approveButton + ) + const isNfTPopupHidden = await waitFor(() => nftApproveButtonLocator.isHidden(), 3_000, false) + + if (!isNfTPopupHidden) { + await nftApproveButtonLocator.click() + } + } catch (e) { + if (page.isClosed()) { + return + } + + throw new Error(`Failed to handle NFT setApprovalForAll popup: ${e}`) + } + } + // By default, the `site` gas setting is used. if (gasSetting === 'site') { await notificationPage.locator(Selectors.ActionFooter.confirmActionButton).click() + await handleNftSetApprovalForAll(notificationPage) + return } @@ -119,6 +140,8 @@ const confirmTransaction = async (notificationPage: Page, options: GasSetting) = await waitFor(waitForAction, 3_000, true) await notificationPage.locator(Selectors.ActionFooter.confirmActionButton).click() + + await handleNftSetApprovalForAll(notificationPage) } const confirmTransactionAndWaitForMining = async (walletPage: Page, notificationPage: Page, options: GasSetting) => { diff --git a/wallets/metamask/src/pages/NotificationPage/page.ts b/wallets/metamask/src/pages/NotificationPage/page.ts index 1e9ed7934..33ee8bfbb 100644 --- a/wallets/metamask/src/pages/NotificationPage/page.ts +++ b/wallets/metamask/src/pages/NotificationPage/page.ts @@ -108,7 +108,10 @@ export class NotificationPage { await transaction.confirmAndWaitForMining(this.page, notificationPage, options?.gasSetting ?? 'site') } - async approvePermission(extensionId: string, options?: { spendLimit?: 'max' | number; gasSetting?: GasSetting }) { + async approveTokenPermission( + extensionId: string, + options?: { spendLimit?: 'max' | number; gasSetting?: GasSetting } + ) { const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) if (options?.spendLimit !== undefined) { @@ -118,7 +121,7 @@ export class NotificationPage { await approvePermission.approve(notificationPage, options?.gasSetting ?? 'site') } - async rejectPermission(extensionId: string) { + async rejectTokenPermission(extensionId: string) { const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) await approvePermission.reject(notificationPage) diff --git a/wallets/metamask/src/pages/NotificationPage/selectors/transactionPage.ts b/wallets/metamask/src/pages/NotificationPage/selectors/transactionPage.ts index e8fea7a0c..2daa5ba45 100644 --- a/wallets/metamask/src/pages/NotificationPage/selectors/transactionPage.ts +++ b/wallets/metamask/src/pages/NotificationPage/selectors/transactionPage.ts @@ -35,6 +35,11 @@ const editGasFeeMenu = { advancedGasFeeMenu } +const nftApproveAllConfirmationPopup = { + approveButton: '.set-approval-for-all-warning__content button.set-approval-for-all-warning__footer__approve-button' +} + export default { - editGasFeeMenu + editGasFeeMenu, + nftApproveAllConfirmationPopup } diff --git a/wallets/metamask/test/e2e/metamask/approvePermission.spec.ts b/wallets/metamask/test/e2e/metamask/approvePermission.spec.ts index b4609cbe3..99ceef382 100644 --- a/wallets/metamask/test/e2e/metamask/approvePermission.spec.ts +++ b/wallets/metamask/test/e2e/metamask/approvePermission.spec.ts @@ -23,7 +23,7 @@ describe('with default gas setting', () => { await page.locator('#approveTokens').click() - await metamask.approvePermission() + await metamask.approveTokenPermission() }) test('should approve tokens with the `max` limit', async ({ page, metamask, deployToken }) => { @@ -31,7 +31,7 @@ describe('with default gas setting', () => { await page.locator('#approveTokens').click() - await metamask.approvePermission({ spendLimit: 'max' }) + await metamask.approveTokenPermission({ spendLimit: 'max' }) }) test('should approve tokens with the custom limit', async ({ page, metamask, deployToken }) => { @@ -39,7 +39,7 @@ describe('with default gas setting', () => { await page.locator('#approveTokens').click() - await metamask.approvePermission({ spendLimit: 420 }) + await metamask.approveTokenPermission({ spendLimit: 420 }) }) }) @@ -49,7 +49,7 @@ describe('with custom gas setting', () => { await page.locator('#approveTokens').click() - await metamask.approvePermission({ + await metamask.approveTokenPermission({ gasSetting: 'site' }) }) @@ -63,7 +63,7 @@ describe('with custom gas setting', () => { await page.locator('#approveTokens').click() - await metamask.approvePermission({ + await metamask.approveTokenPermission({ spendLimit: 'max', gasSetting: { maxBaseFee: 250, @@ -81,7 +81,7 @@ describe('with custom gas setting', () => { await page.locator('#approveTokens').click() - await metamask.approvePermission({ + await metamask.approveTokenPermission({ spendLimit: 420, gasSetting: { maxBaseFee: 250, diff --git a/wallets/metamask/test/e2e/metamask/confirmTransaction.spec.ts b/wallets/metamask/test/e2e/metamask/confirmTransaction.spec.ts index 88044a3f0..b000a0403 100644 --- a/wallets/metamask/test/e2e/metamask/confirmTransaction.spec.ts +++ b/wallets/metamask/test/e2e/metamask/confirmTransaction.spec.ts @@ -3,6 +3,7 @@ import { testWithMetaMask } from '../testWithMetaMask' const test = testWithMetaMask.extend<{ connectAndTriggerEIP1559Transaction: () => Promise + connectDeployAndMintNft: () => Promise }>({ connectAndTriggerEIP1559Transaction: async ({ page, connectToAnvil }, use) => { await use(async () => { @@ -10,6 +11,17 @@ const test = testWithMetaMask.extend<{ await page.locator('#sendEIP1559Button').click() }) + }, + connectDeployAndMintNft: async ({ page, connectToAnvil, metamask }, use) => { + await use(async () => { + await connectToAnvil() + + await page.locator('#deployNFTsButton').click() + await metamask.confirmTransaction() + + await page.locator('#mintButton').click() + await metamask.confirmTransaction() + }) } }) @@ -40,6 +52,64 @@ describe('with default gas setting', () => { await metamask.confirmTransaction() }) + + describe('NFTs', () => { + test('should confirm `watch NFT` request', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#watchNFTButton').click() + + await metamask.confirmTransaction() + }) + + test('should confirm `watch all NFTs` request', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#watchNFTsButton').click() + + await metamask.confirmTransaction() + }) + + test('should confirm `approve` transaction', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#approveButton').click() + + await metamask.confirmTransaction() + + await expect(page.locator('#nftsStatus')).toHaveText('Approve completed') + }) + + test('should confirm `set approval for all` transaction', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#setApprovalForAllButton').click() + + await metamask.confirmTransaction() + + await expect(page.locator('#nftsStatus')).toHaveText('Set Approval For All completed') + }) + + test('should confirm `revoke` transaction', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#revokeButton').click() + + await metamask.confirmTransaction() + + await expect(page.locator('#nftsStatus')).toHaveText('Revoke completed') + }) + + test('should confirm `transfer from` transaction', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#transferFromButton').click() + + await metamask.confirmTransaction() + + await expect(page.locator('#nftsStatus')).toHaveText('Transfer From completed') + }) + }) }) describe('with custom gas setting', () => { @@ -163,5 +233,20 @@ describe('with custom gas setting', () => { } }) }) + + test('should confirm `set approval for all` transaction', async ({ page, metamask, connectDeployAndMintNft }) => { + await connectDeployAndMintNft() + + await page.locator('#setApprovalForAllButton').click() + + await metamask.confirmTransaction({ + gasSetting: { + maxBaseFee: 250, + priorityFee: 150 + } + }) + + await expect(page.locator('#nftsStatus')).toHaveText('Set Approval For All completed') + }) }) }) diff --git a/wallets/metamask/test/e2e/metamask/rejectPermission.spec.ts b/wallets/metamask/test/e2e/metamask/rejectPermission.spec.ts index 0aa0fad0f..25f31d7de 100644 --- a/wallets/metamask/test/e2e/metamask/rejectPermission.spec.ts +++ b/wallets/metamask/test/e2e/metamask/rejectPermission.spec.ts @@ -14,5 +14,5 @@ test('should reject approve request', async ({ page, metamask, connectToAnvil }) await page.locator('#approveTokens').click() - await metamask.rejectPermission() + await metamask.rejectTokenPermission() }) diff --git a/wallets/metamask/tsconfig.build.json b/wallets/metamask/tsconfig.build.json index 97afa3ef9..9af73f809 100644 --- a/wallets/metamask/tsconfig.build.json +++ b/wallets/metamask/tsconfig.build.json @@ -1,5 +1,5 @@ { - "extends": "tsconfig/base.json", + "extends": "@synthetixio/synpress-tsconfig/base.json", "compilerOptions": { "rootDir": "src", "outDir": "types",