diff --git a/ui/desktop/README.md b/ui/desktop/README.md index f80ab75d2..1bc69d290 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 + +**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.* + +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..6c6c7a3d3 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 && yarn run e2e:dev", + "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,