From 9f967f2f7efd1adbb300d8e9a1d59111a01a9748 Mon Sep 17 00:00:00 2001 From: Rabi Siddique <60459172+rabi-siddique@users.noreply.github.com> Date: Thu, 28 Mar 2024 07:33:07 +0500 Subject: [PATCH 1/2] Promote dev into master (#35) * release: v3.8.0 Signed-off-by: toliaqat * release: v3.8.1-beta.0 Signed-off-by: toliaqat * release: v3.8.1-beta.1 Signed-off-by: toliaqat --------- Signed-off-by: toliaqat Co-authored-by: toliaqat --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e2108f95..a2193e9d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agoric/synpress", - "version": "3.7.2-beta.12", + "version": "3.8.1-beta.1", "description": "Synpress is e2e testing framework based around Cypress.io & playwright with included MetaMask support. Test your dapps with ease.", "keywords": [ "Synpress", From 5412d82cde626d03a0d1e9276ec1a1113f2e8b94 Mon Sep 17 00:00:00 2001 From: Rabi Siddique <60459172+rabi-siddique@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:40:41 +0500 Subject: [PATCH 2/2] feat: error handling for better messages and changes for executing script files (#36) * release: v3.8.0 Signed-off-by: toliaqat * release: v3.8.1-beta.0 Signed-off-by: toliaqat * feat: error handling for better messages and changes for executing script files --------- Signed-off-by: toliaqat Co-authored-by: toliaqat --- bin/script.sh | 2 ++ plugins/keplr-plugin.js | 20 ++++++++++++-------- synpress.config.js | 1 + tests/e2e/specs/keplr/keplr-spec.js | 13 +++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100755 bin/script.sh diff --git a/bin/script.sh b/bin/script.sh new file mode 100755 index 000000000..b546ebe1b --- /dev/null +++ b/bin/script.sh @@ -0,0 +1,2 @@ +echo "Hello, stdout!" +echo "Error occurred" >&2 \ No newline at end of file diff --git a/plugins/keplr-plugin.js b/plugins/keplr-plugin.js index 68a4a647a..773948701 100644 --- a/plugins/keplr-plugin.js +++ b/plugins/keplr-plugin.js @@ -1,4 +1,3 @@ -const { exec, execSync } = require('child_process'); const helpers = require('../helpers'); const playwright = require('../commands/playwright-keplr'); const keplr = require('../commands/keplr'); @@ -58,13 +57,18 @@ module.exports = (on, config) => { async execute(command) { return new Promise((resolve, reject) => { - exec(command, (error, stdout, stderr) => { - if (error) { - reject({ error, stdout, stderr }); - } else { - resolve({ stdout, stderr }); - } - }); + const { exec } = require('child_process'); + try { + exec(command, (error, stdout, stderr) => { + if (error) { + reject(error); + } else { + resolve({ stdout, stderr }); + } + }); + } catch (e) { + reject(e); + } }); }, diff --git a/synpress.config.js b/synpress.config.js index f68a6327e..56f99ca6e 100644 --- a/synpress.config.js +++ b/synpress.config.js @@ -20,6 +20,7 @@ module.exports = defineConfig({ fixturesFolder, screenshotsFolder: 'tests/e2e/screenshots', videosFolder: 'tests/e2e/videos', + bashScriptsFolder: process.cwd() +'/bin', chromeWebSecurity: true, viewportWidth: 1920, viewportHeight: 1080, diff --git a/tests/e2e/specs/keplr/keplr-spec.js b/tests/e2e/specs/keplr/keplr-spec.js index 899105be7..ed5513469 100644 --- a/tests/e2e/specs/keplr/keplr-spec.js +++ b/tests/e2e/specs/keplr/keplr-spec.js @@ -2,6 +2,7 @@ describe('Keplr', () => { context('Test commands', () => { + const scriptsFolder = Cypress.config('bashScriptsFolder'); it('Executes a command and verifies stdout and stderr', () => { const command = 'echo "Hello, stdout!" && echo "Error occurred" >&2'; @@ -12,6 +13,18 @@ describe('Keplr', () => { }); }); + it('Executes a commands from a file and verifies stdout and stderr', () => { + const fileName = 'script.sh'; + + cy.execute(`sh ${scriptsFolder}/${fileName}`).then( + ({ stdout, stderr, error }) => { + expect(stdout.trim()).to.equal('Hello, stdout!'); + expect(stderr.trim()).to.equal('Error occurred'); + expect(error).to.be.undefined; + }, + ); + }); + it(`should complete Keplr setup by importing an existing wallet using 24 word phrase`, () => { cy.setupWallet().then(setupFinished => { expect(setupFinished).to.be.true;