From c21e7b9f208ab59d0ee7e145930bcbcf3b99af31 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 14 Oct 2021 13:53:09 -0700 Subject: [PATCH 01/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20storybook/api?= =?UTF-8?q?=20unmet=20peer=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/rose/package.json | 1 + yarn.lock | 149 +++++++++++++++++++++++++++++---------- 2 files changed, 114 insertions(+), 36 deletions(-) diff --git a/addons/rose/package.json b/addons/rose/package.json index b9f7a7908..6015a8a51 100644 --- a/addons/rose/package.json +++ b/addons/rose/package.json @@ -48,6 +48,7 @@ "@storybook/addon-docs": "^6.3.8", "@storybook/addon-knobs": "^6.3.1", "@storybook/addons": "^6.3.9", + "@storybook/api": "^6.3.12", "@storybook/cli": "^6.3.10", "@storybook/ember": "^6.3.8", "@storybook/ember-cli-storybook": "^0.4.0", diff --git a/yarn.lock b/yarn.lock index fbc233db6..42ce135bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2816,9 +2816,9 @@ fastq "^1.6.0" "@npmcli/ci-detect@^1.0.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@npmcli/ci-detect/-/ci-detect-1.3.0.tgz#6c1d2c625fb6ef1b9dea85ad0a5afcbef85ef22a" - integrity sha512-oN3y7FAROHhrAt7Rr7PnTSwrHrZVRTS2ZbyxeQwSSYD0ifwM3YNgQqbaRmjcWoPyq77MjchusjJDspbzMmip1Q== + version "1.4.0" + resolved "https://registry.yarnpkg.com/@npmcli/ci-detect/-/ci-detect-1.4.0.tgz#18478bbaa900c37bfbd8a2006a6262c62e8b0fe1" + integrity sha512-3BGrt6FLjqM6br5AhWRKTr3u5GIVkjRYeAFrMp3HjnfICrg4xOrVRwFavKT6tsp++bq5dluL5t8ME/Nha/6c1Q== "@npmcli/move-file@^1.0.1": version "1.1.2" @@ -3159,6 +3159,32 @@ ts-dedent "^2.0.0" util-deprecate "^1.0.2" +"@storybook/api@^6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/api/-/api-6.3.12.tgz#2845c20464d5348d676d09665e8ab527825ed7b5" + integrity sha512-LScRXUeCWEW/OP+jiooNMQICVdusv7azTmULxtm72fhkXFRiQs2CdRNTiqNg46JLLC9z95f1W+pGK66X6HiiQA== + dependencies: + "@reach/router" "^1.3.4" + "@storybook/channels" "6.3.12" + "@storybook/client-logger" "6.3.12" + "@storybook/core-events" "6.3.12" + "@storybook/csf" "0.0.1" + "@storybook/router" "6.3.12" + "@storybook/semver" "^7.3.2" + "@storybook/theming" "6.3.12" + "@types/reach__router" "^1.3.7" + core-js "^3.8.2" + fast-deep-equal "^3.1.3" + global "^4.4.0" + lodash "^4.17.20" + memoizerific "^1.11.3" + qs "^6.10.0" + regenerator-runtime "^0.13.7" + store2 "^2.12.0" + telejson "^5.3.2" + ts-dedent "^2.0.0" + util-deprecate "^1.0.2" + "@storybook/builder-webpack4@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/builder-webpack4/-/builder-webpack4-6.3.8.tgz#9ffe866fbd50a94b3cf3ecde1fe4d5f29dd337e8" @@ -3270,6 +3296,15 @@ ts-dedent "^2.0.0" util-deprecate "^1.0.2" +"@storybook/channels@6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/channels/-/channels-6.3.12.tgz#aa0d793895a8b211f0ad3459c61c1bcafd0093c7" + integrity sha512-l4sA+g1PdUV8YCbgs47fIKREdEQAKNdQIZw0b7BfTvY9t0x5yfBywgQhYON/lIeiNGz2OlIuD+VUtqYfCtNSyw== + dependencies: + core-js "^3.8.2" + ts-dedent "^2.0.0" + util-deprecate "^1.0.2" + "@storybook/channels@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/channels/-/channels-6.3.8.tgz#1ae91e1f3c47b215b39c1c31b2a58b7ffafdff35" @@ -3376,6 +3411,14 @@ core-js "^3.8.2" global "^4.4.0" +"@storybook/client-logger@6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/client-logger/-/client-logger-6.3.12.tgz#6585c98923b49fcb25dbceeeb96ef2a83e28e0f4" + integrity sha512-zNDsamZvHnuqLznDdP9dUeGgQ9TyFh4ray3t1VGO7ZqWVZ2xtVCCXjDvMnOXI2ifMpX5UsrOvshIPeE9fMBmiQ== + dependencies: + core-js "^3.8.2" + global "^4.4.0" + "@storybook/client-logger@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/client-logger/-/client-logger-6.3.8.tgz#042b81c45f73066e4f6c32942c72f4aca0ae6646" @@ -3555,6 +3598,13 @@ dependencies: core-js "^3.8.2" +"@storybook/core-events@6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/core-events/-/core-events-6.3.12.tgz#73f6271d485ef2576234e578bb07705b92805290" + integrity sha512-SXfD7xUUMazaeFkB92qOTUV8Y/RghE4SkEYe5slAdjeocSaH7Nz2WV0rqNEgChg0AQc+JUI66no8L9g0+lw4Gw== + dependencies: + core-js "^3.8.2" + "@storybook/core-events@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/core-events/-/core-events-6.3.8.tgz#4c9a3deb9334b10116befbf2db5534d1319d2f39" @@ -3780,6 +3830,22 @@ qs "^6.10.0" ts-dedent "^2.0.0" +"@storybook/router@6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/router/-/router-6.3.12.tgz#0d572ec795f588ca886f39cb9b27b94ff3683f84" + integrity sha512-G/pNGCnrJRetCwyEZulHPT+YOcqEj/vkPVDTUfii2qgqukup6K0cjwgd7IukAURnAnnzTi1gmgFuEKUi8GE/KA== + dependencies: + "@reach/router" "^1.3.4" + "@storybook/client-logger" "6.3.12" + "@types/reach__router" "^1.3.7" + core-js "^3.8.2" + fast-deep-equal "^3.1.3" + global "^4.4.0" + lodash "^4.17.20" + memoizerific "^1.11.3" + qs "^6.10.0" + ts-dedent "^2.0.0" + "@storybook/router@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/router/-/router-6.3.8.tgz#16f6c73a760918adb146e456c5b98614cb747f79" @@ -3854,6 +3920,24 @@ resolve-from "^5.0.0" ts-dedent "^2.0.0" +"@storybook/theming@6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-6.3.12.tgz#5bddf9bd90a60709b5ab238ecdb7d9055dd7862e" + integrity sha512-wOJdTEa/VFyFB2UyoqyYGaZdym6EN7RALuQOAMT6zHA282FBmKw8nL5DETHEbctpnHdcrMC/391teK4nNSrdOA== + dependencies: + "@emotion/core" "^10.1.1" + "@emotion/is-prop-valid" "^0.8.6" + "@emotion/styled" "^10.0.27" + "@storybook/client-logger" "6.3.12" + core-js "^3.8.2" + deep-object-diff "^1.1.0" + emotion-theming "^10.0.27" + global "^4.4.0" + memoizerific "^1.11.3" + polished "^4.0.5" + resolve-from "^5.0.0" + ts-dedent "^2.0.0" + "@storybook/theming@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-6.3.8.tgz#3af76408aa8a4f13e217cf407e63a03db217eedc" @@ -7087,15 +7171,15 @@ browserify-zlib@^0.2.0: pako "~1.0.5" browserslist@4.14.2, browserslist@^3.2.6, browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.16.5, browserslist@^4.16.6, browserslist@^4.16.7, browserslist@^4.17.3: - version "4.17.3" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.3.tgz#2844cd6eebe14d12384b0122d217550160d2d624" - integrity sha512-59IqHJV5VGdcJZ+GZ2hU5n4Kv3YiASzW6Xk5g9tf5a/MAzGeFwgGWU39fVzNIOVcgB3+Gp+kiQu0HEfTVU/3VQ== + version "4.17.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.4.tgz#72e2508af2a403aec0a49847ef31bd823c57ead4" + integrity sha512-Zg7RpbZpIJRW3am9Lyckue7PLytvVxxhJj1CaJVlCWENsGEAOlnlt8X0ZxGRPp7Bt9o8tIRM5SEXy4BCPMJjLQ== dependencies: - caniuse-lite "^1.0.30001264" - electron-to-chromium "^1.3.857" + caniuse-lite "^1.0.30001265" + electron-to-chromium "^1.3.867" escalade "^3.1.1" - node-releases "^1.1.77" - picocolors "^0.2.1" + node-releases "^2.0.0" + picocolors "^1.0.0" bser@2.1.1: version "2.1.1" @@ -7429,12 +7513,10 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001157, caniuse-lite@^1.0.30001264: - version "1.0.30001260" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001260.tgz#e3be3f34ddad735ca4a2736fa9e768ef34316270" - integrity sha512-Fhjc/k8725ItmrvW5QomzxLeojewxvqiYCKeFcfFEhut28IVLdpHU19dneOmltZQIE5HNbawj1HYD+1f2bM1Dg== - dependencies: - nanocolors "^0.1.0" +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001157, caniuse-lite@^1.0.30001265: + version "1.0.30001267" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001267.tgz#b1cf2937175afc0570e4615fc2d2f9069fa0ed30" + integrity sha512-r1mjTzAuJ9W8cPBGbbus8E0SKcUP7gn03R14Wk8FlAlqhH9hroy9nLqmpuXlfKEw/oILW+FGz47ipXV2O7x8lg== capture-exit@^2.0.0: version "2.0.0" @@ -9299,10 +9381,10 @@ electron-rebuild@^2.0.3: tar "^6.0.5" yargs "^16.0.0" -electron-to-chromium@^1.3.857: - version "1.3.867" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.867.tgz#7cb484db4b57c28da0b65c51e434c3a1f3f9aa0d" - integrity sha512-WbTXOv7hsLhjJyl7jBfDkioaY++iVVZomZ4dU6TMe/SzucV6mUAs2VZn/AehBwuZMiNEQDaPuTGn22YK5o+aDw== +electron-to-chromium@^1.3.867: + version "1.3.868" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.868.tgz#ed835023b57ecf0ba63dfe7d50e16b53758ab1da" + integrity sha512-kZYCHqwJ1ctGrYDlOcWQH+/AftAm/KD4lEnLDNwS0kKwx1x6dU4zv+GuDjsPPOGn/2TjnKBaZjDyjXaoix0q/A== element-resize-detector@^1.2.2: version "1.2.3" @@ -16655,11 +16737,6 @@ nan@^2.12.1: resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== -nanocolors@^0.1.0: - version "0.1.12" - resolved "https://registry.yarnpkg.com/nanocolors/-/nanocolors-0.1.12.tgz#8577482c58cbd7b5bb1681db4cf48f11a87fd5f6" - integrity sha512-2nMHqg1x5PU+unxX7PGY7AuYxl2qDx7PSrTRjizr8sxdd3l/3hBuWWaki62qmtYm2U5i4Z5E7GbjlyDFhs9/EQ== - nanoid@3.1.20: version "3.1.20" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788" @@ -16883,10 +16960,10 @@ node-pre-gyp@^0.11.0: semver "^5.3.0" tar "^4" -node-releases@^1.1.77: - version "1.1.77" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.77.tgz#50b0cfede855dd374e7585bf228ff34e57c1c32e" - integrity sha512-rB1DUFUNAN4Gn9keO2K1efO35IDK7yKHCdCaIMvFO7yUYmmZYeDjnGKle26G4rwj+LKRQpjyUUvMkPglwGCYNQ== +node-releases@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.0.tgz#67dc74903100a7deb044037b8a2e5f453bb05400" + integrity sha512-aA87l0flFYMzCHpTM3DERFSYxc6lv/BltdbRTOMZuxZ0cwZCD3mejE5n9vLhSJCN++/eOqr77G1IO5uXxlQYWA== node-uuid@~1.4.7: version "1.4.8" @@ -18104,10 +18181,10 @@ pend@~1.2.0: resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= -picocolors@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f" - integrity sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA== +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3: version "2.3.0" @@ -18852,9 +18929,9 @@ qunit@^2.17.1: tiny-glob "0.2.9" qw@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/qw/-/qw-1.0.1.tgz#efbfdc740f9ad054304426acb183412cc8b996d4" - integrity sha1-77/cdA+a0FQwRCassYNBLMi5ltQ= + version "1.0.2" + resolved "https://registry.yarnpkg.com/qw/-/qw-1.0.2.tgz#0c31a6f810320a91c58b05198679427103b03c4a" + integrity sha512-1PhZ/iLKwlVNq45dnerTMKFjMof49uqli7/0QsvPNbX5OJ3IZ8msa9lUpvPheVdP+IYYPrf6cOaVil7S35joVA== ramda@^0.21.0: version "0.21.0" From 82c7638277e3dd2975f0543e3b9561425c7c8185 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 7 Oct 2021 13:28:51 -0700 Subject: [PATCH 02/12] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20connect=20to?= =?UTF-8?q?=20target=20e2e=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First iteration of connect to target end to end test --- ui/desktop/tests/end2end/targets.spec.js | 128 +++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 ui/desktop/tests/end2end/targets.spec.js diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js new file mode 100644 index 000000000..4e05aeed2 --- /dev/null +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -0,0 +1,128 @@ +/* eslint-disable no-undef */ +const { test, expect } = require('@playwright/test'); +const { _electron: electron } = require('playwright'); +const path = require('path'); + +let electronApp = null; +const returnScreenshotPath = (fileName) => { + const screenshotPath = 'tests/end2end/screenshots/targets/'; + const screenshotFormat = '.png'; + return path.join(screenshotPath, fileName).concat(screenshotFormat); +}; + +test.beforeEach(async () => { + electronApp = await electron.launch({ + executablePath: + 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary', + env: { + NODE_ENV: 'test', + BYPASS_APP_UPDATER: true, + }, + }); +}); + +test.afterEach(async () => { + electronApp.close(); + electronApp = null; // Not sure we should do this. +}); + +test.describe('Targets end to end test suite', async () => { + test('Connects to a target', async () => { + const boundaryWindow = await electronApp.firstWindow(); // The window that contains the app. + // Override local storage origin + await boundaryWindow.evaluate(() => + window.localStorage.setItem('desktop:origin', null) + ); + + const originValue = 'http://localhost:9200'; + const authLoginNameValue = 'admin'; + const authLoginPasswordValue = 'password'; + + // Fill the origin input + await boundaryWindow.waitForSelector('.ember-text-field'); + await boundaryWindow.fill('.ember-text-field', originValue); + + // Click the submit button + // Due to an error with await boundaryWindow.click('button[type="submit"]'); we are using a workaround. + // More info about it here: https://github.com/microsoft/playwright/issues/1808 + await boundaryWindow.waitForSelector('button[type="submit"]'); + await boundaryWindow.$eval('button[type="submit"]', (element) => + element.click() + ); + // Fill user & password + await boundaryWindow.fill('[name="identification"]', authLoginNameValue); + await boundaryWindow.fill('[name="password"]', authLoginPasswordValue); + + // Click submit + await boundaryWindow.waitForSelector('button[type="submit"]'); + await boundaryWindow.$eval('button[type="submit"]', (element) => + element.click() + ); + // Check we are in Targets + await boundaryWindow.waitForSelector('h2 >> text=Targets'); + expect(await boundaryWindow.innerText('h2 >> text=Targets')).toEqual( + 'Targets ' + ); + + // Click connect to a target + await boundaryWindow.waitForSelector('table.rose-table'); + await boundaryWindow.$eval( + 'table.rose-table >> tbody >> tr >> nth=0 >> button >> text=Connect', + (element) => element.click() + ); + + // The target popup opens + await boundaryWindow.waitForSelector('section.dialog-detail'); + // Take screenshot + await boundaryWindow.screenshot({ + path: returnScreenshotPath('targetConnectionDetails'), + fullPage: true, + }); + // Click copyable in popup + // TODO: read clipboard value. Running into issues reading clipboard, so will take a shortcut for now + await boundaryWindow.$eval( + 'section.dialog-detail >> div.rose-dialog-body >> button', + (element) => element.click() + ); + // Temporary: persist proxy from target + const persistedProxy = await boundaryWindow.innerText( + 'section.dialog-detail >> div.rose-dialog-body >> span.copyable-content' + ); + + // Click close popup + await boundaryWindow.$eval( + 'section.dialog-detail >> footer >> button', + (element) => element.click() + ); + + // On left nav menu, click Sessions + await boundaryWindow.waitForSelector('section.rose-layout-global >> aside'); + await boundaryWindow.$eval( + 'section.rose-layout-global >> aside >> nav >> a >> text=Sessions', + (element) => element.click() + ); + + // Take screenshot + await boundaryWindow.screenshot({ + path: returnScreenshotPath('sessions'), + fullPage: true, + }); + + // Check the right session has status pending. + await boundaryWindow.waitForSelector( + 'main >> div.rose-layout-page-body >> table.rose-table' + ); + // Select Proxy + const currentProxy = await boundaryWindow.innerText( + 'div.rose-layout-page-body >> table >> tbody >> tr >> nth=0 >> td >> nth=1 >> .copyable-content' + ); + const currentStatus = await boundaryWindow.innerText( + 'div.rose-layout-page-body >> table >> tbody >> tr >> nth=0 >> td >> nth=3 >> .rose-badge-body' + ); + + expect(await persistedProxy).toEqual(await currentProxy); + expect(await currentStatus).toEqual('pending'); + // TODO: before closing the app we should terminate sessions. + // TODO: add test to check if sessions are not terminated we promp the confirmation dialog + }); +}); From 9ad765327dfb65a62304a3b6877fab9bbb70540b Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Wed, 13 Oct 2021 07:50:54 -0700 Subject: [PATCH 03/12] Rename function --- ui/desktop/tests/end2end/targets.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index 4e05aeed2..340a94d33 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -4,7 +4,7 @@ const { _electron: electron } = require('playwright'); const path = require('path'); let electronApp = null; -const returnScreenshotPath = (fileName) => { +const generateScreenshotPath = (fileName) => { const screenshotPath = 'tests/end2end/screenshots/targets/'; const screenshotFormat = '.png'; return path.join(screenshotPath, fileName).concat(screenshotFormat); @@ -75,7 +75,7 @@ test.describe('Targets end to end test suite', async () => { await boundaryWindow.waitForSelector('section.dialog-detail'); // Take screenshot await boundaryWindow.screenshot({ - path: returnScreenshotPath('targetConnectionDetails'), + path: generateScreenshotPath('targetConnectionDetails'), fullPage: true, }); // Click copyable in popup @@ -104,7 +104,7 @@ test.describe('Targets end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: returnScreenshotPath('sessions'), + path: generateScreenshotPath('sessions'), fullPage: true, }); From 960e91c8e545f3fdd484002aa85f14216d142445 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 14 Oct 2021 10:35:28 -0700 Subject: [PATCH 04/12] Change the way we check we are in targets section. Now we check the url rather than the h2 title --- ui/desktop/tests/end2end/authentication.spec.js | 11 ++++++----- ui/desktop/tests/end2end/targets.spec.js | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index 553a4b5cd..9986b0773 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -10,7 +10,7 @@ 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. +// 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 { @@ -91,11 +91,12 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.$eval('button[type="submit"]', (element) => element.click() ); + // Check we are in Targets - await boundaryWindow.waitForSelector('h2 >> text=Targets'); - expect(await boundaryWindow.innerText('h2 >> text=Targets')).toEqual( - 'Targets ' - ); + await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); + const windowUrl = new URL(await boundaryWindow.url()); + expect(windowUrl.hash).toEqual('#/scopes/global/projects/targets'); + // Take screenshot await boundaryWindow.screenshot({ path: generateScreenshotPath('afterLogin'), diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index 340a94d33..56411e15c 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -58,11 +58,11 @@ test.describe('Targets end to end test suite', async () => { await boundaryWindow.$eval('button[type="submit"]', (element) => element.click() ); + // Check we are in Targets - await boundaryWindow.waitForSelector('h2 >> text=Targets'); - expect(await boundaryWindow.innerText('h2 >> text=Targets')).toEqual( - 'Targets ' - ); + await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); + const windowUrl = new URL(await boundaryWindow.url()); + expect(windowUrl.hash).toEqual('#/scopes/global/projects/targets'); // Click connect to a target await boundaryWindow.waitForSelector('table.rose-table'); From 20172626cb9de556690f244ae3b4536f64c0352b Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 15 Oct 2021 08:54:08 -0700 Subject: [PATCH 05/12] Change selector for origin input field --- ui/desktop/tests/end2end/authentication.spec.js | 10 +++++----- ui/desktop/tests/end2end/targets.spec.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index 9986b0773..f3547656b 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -62,8 +62,8 @@ test.describe('Authentication end to end test suite', async () => { const authLoginPasswordValue = 'password'; // Fill the origin input - await boundaryWindow.waitForSelector('.ember-text-field'); - await boundaryWindow.fill('.ember-text-field', originValue); + await boundaryWindow.waitForSelector('[name=host]'); + await boundaryWindow.fill('[name=host]', originValue); // Take screenshot await boundaryWindow.screenshot({ path: generateScreenshotPath('fillOrigin'), @@ -147,7 +147,7 @@ test.describe('Authentication end to end test suite', async () => { const authLoginPasswordValue = '123456'; // Fill the origin input - await boundaryWindow.fill('.ember-text-field', originValue); + await boundaryWindow.fill('[name=host]', originValue); // Take screenshot await boundaryWindow.screenshot({ path: generateScreenshotPath('fillOrigin'), @@ -206,8 +206,8 @@ test.describe('Authentication end to end test suite', async () => { const originValue = 'http://localhost:9200'; // Fill the origin input - await boundaryWindow.waitForSelector('.ember-text-field'); - await boundaryWindow.fill('.ember-text-field', originValue); + await boundaryWindow.waitForSelector('[name=host]'); + await boundaryWindow.fill('[name=host]', originValue); // Click the submit button // Due to an error with await boundaryWindow.click('button[type="submit"]'); we are using a workaround. diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index 56411e15c..eb048c90c 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -39,8 +39,8 @@ test.describe('Targets end to end test suite', async () => { const authLoginPasswordValue = 'password'; // Fill the origin input - await boundaryWindow.waitForSelector('.ember-text-field'); - await boundaryWindow.fill('.ember-text-field', originValue); + await boundaryWindow.waitForSelector('[name=host]'); + await boundaryWindow.fill('[name=host]', originValue); // Click the submit button // Due to an error with await boundaryWindow.click('button[type="submit"]'); we are using a workaround. From e0cee85ad4d5cfe40cfaae2a711601ca777b61fa Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 7 Oct 2021 13:28:51 -0700 Subject: [PATCH 06/12] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20connect=20to?= =?UTF-8?q?=20target=20e2e=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First iteration of connect to target end to end test --- ui/desktop/tests/end2end/targets.spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index eb048c90c..12ca2779b 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -75,7 +75,11 @@ test.describe('Targets end to end test suite', async () => { await boundaryWindow.waitForSelector('section.dialog-detail'); // Take screenshot await boundaryWindow.screenshot({ +<<<<<<< HEAD path: generateScreenshotPath('targetConnectionDetails'), +======= + path: returnScreenshotPath('targetConnectionDetails'), +>>>>>>> 5f79634d (test: 💍 Add connect to target e2e test) fullPage: true, }); // Click copyable in popup @@ -104,7 +108,11 @@ test.describe('Targets end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ +<<<<<<< HEAD path: generateScreenshotPath('sessions'), +======= + path: returnScreenshotPath('sessions'), +>>>>>>> 5f79634d (test: 💍 Add connect to target e2e test) fullPage: true, }); From fe48e0eba2d854bc11a81e4be7f189489e8649e3 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Wed, 13 Oct 2021 14:07:37 -0700 Subject: [PATCH 07/12] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Create=20gener?= =?UTF-8?q?ateScreenshotPath=20as=20test=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create generateScreenshotPath as test helper --- .../tests/end2end/authentication.spec.js | 25 +++++++++---------- ui/desktop/tests/end2end/targets.spec.js | 23 ++++++----------- ui/desktop/tests/end2end/test-helpers.js | 18 +++++++++++++ 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 ui/desktop/tests/end2end/test-helpers.js diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index f3547656b..c7a02fbcd 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -1,14 +1,10 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const path = require('path'); +const { generateScreenshotPath } = require('./test-helpers'); let electronApp = null; -const generateScreenshotPath = (fileName) => { - const screenshotPath = 'tests/end2end/screenshots/authentication/'; - const screenshotFormat = '.png'; - return path.join(screenshotPath, fileName).concat(screenshotFormat); -}; +const screenshotsDirectory = 'authentication/'; // 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. @@ -66,7 +62,7 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.fill('[name=host]', originValue); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('fillOrigin'), + path: generateScreenshotPath(screenshotsDirectory, 'fillOrigin'), fullPage: true, }); @@ -82,7 +78,7 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.fill('[name="password"]', authLoginPasswordValue); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('fillUserPassword'), + path: generateScreenshotPath(screenshotsDirectory, 'fillUserPassword'), fullPage: true, }); @@ -99,7 +95,7 @@ test.describe('Authentication end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('afterLogin'), + path: generateScreenshotPath(screenshotsDirectory, 'afterLogin'), fullPage: true, }); @@ -114,7 +110,7 @@ test.describe('Authentication end to end test suite', async () => { expect(await boundaryWindow.isVisible('details')); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('userDropdown'), + path: generateScreenshotPath(screenshotsDirectory, 'userDropdown'), fullPage: true, }); @@ -131,7 +127,7 @@ test.describe('Authentication end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('afterLogout'), + path: generateScreenshotPath(screenshotsDirectory, 'afterLogout'), fullPage: true, }); }); @@ -150,7 +146,7 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.fill('[name=host]', originValue); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('fillOrigin'), + path: generateScreenshotPath(screenshotsDirectory, 'fillOrigin'), fullPage: true, }); @@ -180,7 +176,10 @@ test.describe('Authentication end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath('notificationFailed'), + path: generateScreenshotPath( + screenshotsDirectory, + 'notificationFailed' + ), fullPage: true, }); }); diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index 12ca2779b..d30084031 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -1,14 +1,10 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const path = require('path'); +const { generateScreenshotPath } = require('./test-helpers'); let electronApp = null; -const generateScreenshotPath = (fileName) => { - const screenshotPath = 'tests/end2end/screenshots/targets/'; - const screenshotFormat = '.png'; - return path.join(screenshotPath, fileName).concat(screenshotFormat); -}; +const screenshotsDirectory = 'targets/'; test.beforeEach(async () => { electronApp = await electron.launch({ @@ -75,11 +71,10 @@ test.describe('Targets end to end test suite', async () => { await boundaryWindow.waitForSelector('section.dialog-detail'); // Take screenshot await boundaryWindow.screenshot({ -<<<<<<< HEAD - path: generateScreenshotPath('targetConnectionDetails'), -======= - path: returnScreenshotPath('targetConnectionDetails'), ->>>>>>> 5f79634d (test: 💍 Add connect to target e2e test) + path: generateScreenshotPath( + screenshotsDirectory, + 'targetConnectionDetails' + ), fullPage: true, }); // Click copyable in popup @@ -108,11 +103,7 @@ test.describe('Targets end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ -<<<<<<< HEAD - path: generateScreenshotPath('sessions'), -======= - path: returnScreenshotPath('sessions'), ->>>>>>> 5f79634d (test: 💍 Add connect to target e2e test) + path: generateScreenshotPath(screenshotsDirectory, 'sessions'), fullPage: true, }); diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js new file mode 100644 index 000000000..2b0de5c8c --- /dev/null +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -0,0 +1,18 @@ +/* eslint-disable no-undef */ +const path = require('path'); + +/** + * + * @param {string} screenshotTestDirectory screenshot directory for the specific test suite + * @param {string} fileName The file name. + * @returns A full path where to save the screenshot. + */ +exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { + const screenshotFormat = '.png'; + const screenshotsRootPath = path.join(__dirname, '/screenshots/'); + const screenshotPath = path.join( + screenshotsRootPath, + screenshotTestDirectory + ); + return path.join(screenshotPath, fileName).concat(screenshotFormat); +}; From af2e111dcd8172b2b1e85b0613015dc8bffdf66e Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 15 Oct 2021 09:35:28 -0700 Subject: [PATCH 08/12] Delete trailing slashes from path --- ui/desktop/tests/end2end/test-helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 2b0de5c8c..8c43b84f4 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -9,7 +9,7 @@ const path = require('path'); */ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { const screenshotFormat = '.png'; - const screenshotsRootPath = path.join(__dirname, '/screenshots/'); + const screenshotsRootPath = path.join(__dirname, 'screenshots'); const screenshotPath = path.join( screenshotsRootPath, screenshotTestDirectory From 360022217830478bc7487005aefd567a30d4a981 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Wed, 13 Oct 2021 14:07:37 -0700 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Create=20gener?= =?UTF-8?q?ateScreenshotPath=20as=20test=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create generateScreenshotPath as test helper --- ui/desktop/tests/end2end/test-helpers.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 8c43b84f4..892c0773b 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -9,7 +9,11 @@ const path = require('path'); */ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { const screenshotFormat = '.png'; +<<<<<<< HEAD const screenshotsRootPath = path.join(__dirname, 'screenshots'); +======= + const screenshotsRootPath = path.join(__dirname, '/screenshots/'); +>>>>>>> 8c489b81 (refactor: 💡 Create generateScreenshotPath as test helper) const screenshotPath = path.join( screenshotsRootPath, screenshotTestDirectory From 5dd59a6c14a936826a478a756f4814e279512d83 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 14 Oct 2021 11:24:03 -0700 Subject: [PATCH 10/12] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Move=20returnE?= =?UTF-8?q?xecutablePath=20to=20e2e=20test=20helpers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move returnExecutablePath to end to end test helpers file. Now the two test files are importing the function from the test helpers file. --- .../tests/end2end/authentication.spec.js | 28 +++--------------- ui/desktop/tests/end2end/targets.spec.js | 9 ++++-- ui/desktop/tests/end2end/test-helpers.js | 29 +++++++++++++++++++ 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index c7a02fbcd..71667b0de 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -1,33 +1,13 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const { generateScreenshotPath } = require('./test-helpers'); +const { + generateScreenshotPath, + returnExecutablePath, +} = require('./test-helpers'); let electronApp = null; const screenshotsDirectory = 'authentication/'; - -// 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 () => { diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index d30084031..2ee467d17 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -1,15 +1,18 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const { generateScreenshotPath } = require('./test-helpers'); +const { + generateScreenshotPath, + returnExecutablePath, +} = require('./test-helpers'); let electronApp = null; const screenshotsDirectory = 'targets/'; +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, diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 892c0773b..e99b95dc7 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -20,3 +20,32 @@ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { ); return path.join(screenshotPath, fileName).concat(screenshotFormat); }; + +/** + * + * @param {string} platform The operating system. + * @param {string} arch The CPU architecture. + * @returns A full path where the Desktop Client executable is located. + */ +exports.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 or Architecture.' + ); + } + } catch (error) { + console.error(error); + } +}; From a07e3f4e41b2846291198b7e7dc23a0acfb639de Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 15 Oct 2021 10:20:16 -0700 Subject: [PATCH 11/12] Forgot to commit change --- ui/desktop/tests/end2end/test-helpers.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index e99b95dc7..80282aaf6 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -9,11 +9,7 @@ const path = require('path'); */ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { const screenshotFormat = '.png'; -<<<<<<< HEAD const screenshotsRootPath = path.join(__dirname, 'screenshots'); -======= - const screenshotsRootPath = path.join(__dirname, '/screenshots/'); ->>>>>>> 8c489b81 (refactor: 💡 Create generateScreenshotPath as test helper) const screenshotPath = path.join( screenshotsRootPath, screenshotTestDirectory From 6bcbf2b2ba3fb35380990adefa58d2b64a1e7097 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 15 Oct 2021 13:40:14 -0700 Subject: [PATCH 12/12] Simplify conditionals with a switch --- ui/desktop/tests/end2end/test-helpers.js | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 80282aaf6..ff6902143 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -25,21 +25,18 @@ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { */ exports.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 or Architecture.' - ); + switch (platform) { + case 'darwin': + switch (arch) { + case 'x64': // Intel chips + return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary'; + case 'arm64': // M1 chips + return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary'; + default: + throw new Error('The test suite is not compatible with your arch.'); + } + default: + throw new Error('The test suite is not compatible with your platform.'); } } catch (error) { console.error(error);