From 94431c9dbadad896a0e2205feb362693e3615c10 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Tue, 12 Oct 2021 08:44:38 -0700 Subject: [PATCH 1/3] Add documentation to readme. Add function to determinate where to execute Boundary Binary during tests --- ui/desktop/README.md | 16 +++++++++++ ui/desktop/package.json | 3 ++- .../tests/end2end/authentication.spec.js | 27 +++++++++++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ui/desktop/README.md b/ui/desktop/README.md index f80ab75d2..b8fd2d534 100644 --- a/ui/desktop/README.md +++ b/ui/desktop/README.md @@ -156,6 +156,22 @@ We rely on `ember-a11y-testing` to validate accessibility in acceptance tests. If you write acceptance tests, please ensure at least one validation per route using `await a11yAudit();`. +### Running end to end Tests + +Just tested with Mac x64 and M1 arm64 + +*Be aware this is a temporary process that can suffer changes and eventually will be automated.* + +This process will explain how to run end to end test in your local environment. The process will assume next: +- You already run the Boundary UI [installation process](https://github.com/hashicorp/boundary-ui#installation). +- You have Boundary installed, see [the installation guide](https://learn.hashicorp.com/tutorials/boundary/getting-started-install?in=boundary/getting-started). + +Steps: +- Open a terminal and run `$ boundary dev`. +- Open another terminal and navigate to `$ boundary-ui/ui/desktop` folder. +- Run `$ yarn run e2e` and tests will start run. +- You can check the screenshots the tests take: `desktop/tests/end2end/screenshots`. + ### Deploying TBD diff --git a/ui/desktop/package.json b/ui/desktop/package.json index 7a670f752..48de22e53 100755 --- a/ui/desktop/package.json +++ b/ui/desktop/package.json @@ -37,7 +37,8 @@ "pretest": "yarn clean:coverage", "test": "npm-run-all lint test:*", "test:ember": "cross-env COVERAGE=true ember exam --random", - "e2e": "npx playwright test --headed", + "e2e": "yarn run build && npx playwright test --headed", + "e2e:dev": "npx playwright test --headed", "postinstall": "cd electron-app && yarn install", "posttest": "ember coverage-merge && yarn clean:coverage" }, diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index ad561b13a..553a4b5cd 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -10,10 +10,33 @@ const generateScreenshotPath = (fileName) => { return path.join(screenshotPath, fileName).concat(screenshotFormat); }; +// Todo: move this function to a test helpers file so it could be used by other tests. +// Returns the executable path for the Boundary binary the test suite will run. +const returnExecutablePath = (platform, arch) => { + try { + // Just mac + if (platform === 'darwin') { + if (arch === 'x64') { + // Intel chips + return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary'; + } else if (arch === 'arm64') { + // M1 chips + return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary'; + } else { + throw new Error('The test suite is not compatible with your arch.'); + } + } else { + throw new Error('The test suite is not compatible with your Platform.'); + } + } catch (error) { + console.error(error); + } +}; +const executablePath = returnExecutablePath(process.platform, process.arch); + test.beforeEach(async () => { electronApp = await electron.launch({ - executablePath: - 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary', + executablePath: executablePath, env: { NODE_ENV: 'test', BYPASS_APP_UPDATER: true, From 9bfe3a97fb3ee610a30f01eb508b58e020ed22c8 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Tue, 12 Oct 2021 09:00:12 -0700 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20Add=20temporar?= =?UTF-8?q?y=20process=20to=20run=20e2e=20test=20suite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add documentation to temporary process to run the end to end test suite. --- ui/desktop/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/desktop/README.md b/ui/desktop/README.md index b8fd2d534..1bc69d290 100644 --- a/ui/desktop/README.md +++ b/ui/desktop/README.md @@ -158,7 +158,7 @@ route using `await a11yAudit();`. ### Running end to end Tests -Just tested with Mac x64 and M1 arm64 +**The end-to-end test suite is supported for Mac, x64 and arm64 (M1) chips.** *Be aware this is a temporary process that can suffer changes and eventually will be automated.* From 944ccfb1b9753592e4637affddfa3ef8656a0811 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Wed, 13 Oct 2021 10:42:20 -0700 Subject: [PATCH 3/3] Simplify e2e yarn scripts --- ui/desktop/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/desktop/package.json b/ui/desktop/package.json index 48de22e53..6c6c7a3d3 100755 --- a/ui/desktop/package.json +++ b/ui/desktop/package.json @@ -37,7 +37,7 @@ "pretest": "yarn clean:coverage", "test": "npm-run-all lint test:*", "test:ember": "cross-env COVERAGE=true ember exam --random", - "e2e": "yarn run build && npx playwright test --headed", + "e2e": "yarn run build && yarn run e2e:dev", "e2e:dev": "npx playwright test --headed", "postinstall": "cd electron-app && yarn install", "posttest": "ember coverage-merge && yarn clean:coverage"