From 53b5411bc3cf13546f4122ea7449df6b69098698 Mon Sep 17 00:00:00 2001 From: MaZ Date: Fri, 20 Oct 2023 17:59:55 +0200 Subject: [PATCH] add clipboard permission --- web-frontend/cypress.config.ts | 6 ++- .../cypress/e2e/acceptance/home/send.cy.tsx | 37 +++++++------------ web-frontend/package-lock.json | 13 +++++++ web-frontend/package.json | 1 + 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/web-frontend/cypress.config.ts b/web-frontend/cypress.config.ts index 19e7993c9..b086f43cb 100644 --- a/web-frontend/cypress.config.ts +++ b/web-frontend/cypress.config.ts @@ -45,7 +45,11 @@ export default defineConfig({ return compareSnapshotsPlugin; }, }, - + env: { + browserPermissions: { + clipboard: 'allow', + }, + }, e2e: { // macbook-15 default viewportWidth: 1440, diff --git a/web-frontend/cypress/e2e/acceptance/home/send.cy.tsx b/web-frontend/cypress/e2e/acceptance/home/send.cy.tsx index f95c2cb3c..56a6ab84a 100644 --- a/web-frontend/cypress/e2e/acceptance/home/send.cy.tsx +++ b/web-frontend/cypress/e2e/acceptance/home/send.cy.tsx @@ -84,29 +84,18 @@ describe('E2E | Acceptance | Home', () => { cy.get('[data-testid="receive-coins"]').should('be.visible'); }); - // it('should copy wallet address when clipboard field is clicked', () => { - // // we are adding the permission to chrome on the fly - // cy.wrap( - // Cypress.automation('remote:debugger:protocol', { - // command: 'Browser.grantPermissions', - // params: { - // permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'], - // origin: window.location.origin, - // }, - // }), - // ); - - // const account = mockedAccounts.at(2); - - // cy.visit('/'); - - // cy.get('[data-testid="account-2"]').click(); - // cy.url().should('eq', `${baseUrl}/Mario/home`); - - // compareSnapshot(cy, 'wallet-home'); - - // cy.get('[data-testid="clipboard-field"]').click(); - // cy.assertValueCopiedFromClipboard(account.address); - // }); + it('should copy wallet address when clipboard field is clicked', () => { + const account = mockedAccounts.at(2); + + cy.visit('/'); + + cy.get('[data-testid="account-2"]').click(); + cy.url().should('eq', `${baseUrl}/Mario/home`); + + compareSnapshot(cy, 'wallet-home'); + + cy.get('[data-testid="clipboard-field"]').click(); + cy.assertValueCopiedFromClipboard(account.address); + }); }); }); diff --git a/web-frontend/package-lock.json b/web-frontend/package-lock.json index 6062692d6..f8b649fc3 100644 --- a/web-frontend/package-lock.json +++ b/web-frontend/package-lock.json @@ -40,6 +40,7 @@ "autoprefixer": "^10.4.14", "babel-jest": "^29.5.0", "cypress": "^13.3.1", + "cypress-browser-permissions": "^1.1.0", "cypress-image-diff-js": "^1.31.0", "eslint": "^8.38.0", "eslint-plugin-html": "^7.1.0", @@ -6504,6 +6505,18 @@ "node": "^16.0.0 || ^18.0.0 || >=20.0.0" } }, + "node_modules/cypress-browser-permissions": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cypress-browser-permissions/-/cypress-browser-permissions-1.1.0.tgz", + "integrity": "sha512-/pLwCWIXqcmWga3LQmLUDplGCT+e490H8CeqztIXwy8bsMCK4EHTuoRgTcNwYGipdb00omgTfby7jIDPp2a01Q==", + "dev": true, + "dependencies": { + "lodash": "4.17.21" + }, + "peerDependencies": { + "cypress": ">= 4" + } + }, "node_modules/cypress-image-diff-js": { "version": "1.31.0", "resolved": "https://registry.npmjs.org/cypress-image-diff-js/-/cypress-image-diff-js-1.31.0.tgz", diff --git a/web-frontend/package.json b/web-frontend/package.json index c344bc8b3..018e24f0a 100644 --- a/web-frontend/package.json +++ b/web-frontend/package.json @@ -57,6 +57,7 @@ "autoprefixer": "^10.4.14", "babel-jest": "^29.5.0", "cypress": "^13.3.1", + "cypress-browser-permissions": "^1.1.0", "cypress-image-diff-js": "^1.31.0", "eslint": "^8.38.0", "eslint-plugin-html": "^7.1.0",