From 4d7c269d627136b3200b29d5463be776801a68f1 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 21 Oct 2021 17:01:41 -0700 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20storybook/compo?= =?UTF-8?q?nents=20unmet=20peer=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix storybook/components unmet peer dependency --- addons/rose/package.json | 1 + yarn.lock | 42 ++++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/addons/rose/package.json b/addons/rose/package.json index 7e167be63..7cb043175 100644 --- a/addons/rose/package.json +++ b/addons/rose/package.json @@ -50,6 +50,7 @@ "@storybook/addons": "^6.3.9", "@storybook/api": "^6.3.12", "@storybook/cli": "^6.3.10", + "@storybook/components": "^6.3.12", "@storybook/ember": "^6.3.8", "@storybook/ember-cli-storybook": "^0.4.0", "babel-eslint": "^10.1.0", diff --git a/yarn.lock b/yarn.lock index d9cd99d55..cabf52ea1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3514,6 +3514,36 @@ ts-dedent "^2.0.0" util-deprecate "^1.0.2" +"@storybook/components@^6.3.12": + version "6.3.12" + resolved "https://registry.yarnpkg.com/@storybook/components/-/components-6.3.12.tgz#0c7967c60354c84afa20dfab4753105e49b1927d" + integrity sha512-kdQt8toUjynYAxDLrJzuG7YSNL6as1wJoyzNUaCfG06YPhvIAlKo7le9tS2mThVFN5e9nbKrW3N1V1sp6ypZXQ== + dependencies: + "@popperjs/core" "^2.6.0" + "@storybook/client-logger" "6.3.12" + "@storybook/csf" "0.0.1" + "@storybook/theming" "6.3.12" + "@types/color-convert" "^2.0.0" + "@types/overlayscrollbars" "^1.12.0" + "@types/react-syntax-highlighter" "11.0.5" + color-convert "^2.0.1" + core-js "^3.8.2" + fast-deep-equal "^3.1.3" + global "^4.4.0" + lodash "^4.17.20" + markdown-to-jsx "^7.1.3" + memoizerific "^1.11.3" + overlayscrollbars "^1.13.1" + polished "^4.0.5" + prop-types "^15.7.2" + react-colorful "^5.1.2" + react-popper-tooltip "^3.1.1" + react-syntax-highlighter "^13.5.3" + react-textarea-autosize "^8.3.0" + regenerator-runtime "^0.13.7" + ts-dedent "^2.0.0" + util-deprecate "^1.0.2" + "@storybook/core-client@6.3.8": version "6.3.8" resolved "https://registry.yarnpkg.com/@storybook/core-client/-/core-client-6.3.8.tgz#9223b9f22ab86d205dac605bcef15ba0f0068e15" @@ -7514,9 +7544,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.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== + version "1.0.30001270" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001270.tgz#cc9c37a4ec5c1a8d616fc7bace902bb053b0cdea" + integrity sha512-TcIC7AyNWXhcOmv2KftOl1ShFAaHQYcB/EPL/hEyMrcS7ZX0/DvV1aoy6BzV0+16wTpoAyTMGDNAJfSqS/rz7A== capture-exit@^2.0.0: version "2.0.0" @@ -7774,9 +7804,9 @@ clean-css-promise@^0.1.0: pinkie-promise "^2.0.0" clean-css@^3.4.5, clean-css@^4.1.11, clean-css@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.3.tgz#507b5de7d97b48ee53d84adb0160ff6216380f78" - integrity sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA== + version "4.2.4" + resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.4.tgz#733bf46eba4e607c6891ea57c24a989356831178" + integrity sha512-EJUDT7nDVFDvaQgAo2G/PJvxmp1o/c6iXLbswsBbUFXi1Nr+AjA2cKmfbKDMjMvzEe75g3P6JkaDDAKk96A85A== dependencies: source-map "~0.6.0" From dbadbff1b9d4b6fee68694e48b69c8f9b00ba0f0 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 22 Oct 2021 08:43:03 -0700 Subject: [PATCH 2/3] Add login test helper. Use the new login test helper in targets test --- ui/desktop/tests/end2end/targets.spec.js | 29 ++++++++---------------- ui/desktop/tests/end2end/test-helpers.js | 29 ++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index e71211cf1..9bb4d0b31 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -25,33 +25,22 @@ test.afterEach(async () => { electronApp = null; // Not sure we should do this. }); -test.describe('Targets end to end test suite', async () => { +test.describe.only('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('[name=host]'); - await boundaryWindow.fill('[name=host]', originValue); - - // Click the submit button - await boundaryWindow.waitForSelector('button[type="submit"]'); - await helpers.click(boundaryWindow, 'button[type="submit"]'); - - // Fill user & password - await boundaryWindow.fill('[name="identification"]', authLoginNameValue); - await boundaryWindow.fill('[name="password"]', authLoginPasswordValue); - - // Click submit - await boundaryWindow.waitForSelector('button[type="submit"]'); - await helpers.click(boundaryWindow, 'button[type="submit"]'); + // Perform the login + await helpers.login( + boundaryWindow, + 'http://localhost:9200', + 'admin', + 'password' + ); // Check we are in Targets await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index ba7e739fd..da35f237e 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -46,9 +46,34 @@ exports.returnExecutablePath = (platform, arch) => { /** * Performs a click with a workarouind due to an error with plain playwright click. * More info about the issue here: https://github.com/microsoft/playwright/issues/1808 - * @param {*} appWindow The current electron window. - * @param {*} selector The DOM element selector. + * @param {object} appWindow The electron window to perform the action. + * @param {string} selector The DOM element selector. */ exports.click = async (appWindow, selector) => { await appWindow.$eval(selector, (element) => element.click()); }; + +/** + * Performs login on the app window provided with the credentials provided. + * @param {object} appWindow The electron window to perform the action. + * @param {string} origin URL origin to set. + * @param {string} username Username to login. + * @param {string} password Password to login. + */ +exports.login = async (appWindow, origin, username, password) => { + // Fill the origin input + await appWindow.waitForSelector('[name=host]'); + await appWindow.fill('[name=host]', origin); + + // Click the set origin submit button + await appWindow.waitForSelector('button[type="submit"]'); + await this.click(appWindow, 'button[type="submit"]'); + + // Fill user & password + await appWindow.fill('[name="identification"]', username); + await appWindow.fill('[name="password"]', password); + + // Click submit + await appWindow.waitForSelector('button[type="submit"]'); + await this.click(appWindow, 'button[type="submit"]'); +}; From fd13808cc95e224d0eac8403c25059665c04784e Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 22 Oct 2021 09:11:10 -0700 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20login=20test?= =?UTF-8?q?=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add login test helper and use such helper in the tests --- .../tests/end2end/authentication.spec.js | 68 ++++++------------- ui/desktop/tests/end2end/targets.spec.js | 15 ++-- 2 files changed, 32 insertions(+), 51 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index 93540c0f7..3ba899d13 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -4,12 +4,19 @@ const { _electron: electron } = require('playwright'); const helpers = require('./test-helpers'); let electronApp = null; +// Subdirectory within tests/end2end/screenshots where the screenshots of this test suite will be stored. const screenshotsDirectory = 'authentication/'; +// Path where the Boundary Desktop client binary is generated const executablePath = helpers.returnExecutablePath( process.platform, process.arch ); +// Set login variables +const originValue = 'http://localhost:9200'; +const loginUsername = 'admin'; +const loginPassword = 'password'; + test.beforeEach(async () => { electronApp = await electron.launch({ executablePath: executablePath, @@ -34,29 +41,15 @@ test.describe('Authentication end to end test suite', async () => { 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('[name=host]'); - await boundaryWindow.fill('[name=host]', originValue); - // Take screenshot - await boundaryWindow.screenshot({ - path: helpers.generateScreenshotPath( - screenshotsDirectory, - 'fillOrigin' - ), - fullPage: true, - }); + // Perform login + await helpers.login( + boundaryWindow, + originValue, + loginUsername, + loginPassword + ); - // Click the submit button - await boundaryWindow.waitForSelector('button[type="submit"]'); - await helpers.click(boundaryWindow, 'button[type="submit"]'); - - // Fill user & password - await boundaryWindow.fill('[name="identification"]', authLoginNameValue); - await boundaryWindow.fill('[name="password"]', authLoginPasswordValue); // Take screenshot await boundaryWindow.screenshot({ path: helpers.generateScreenshotPath( @@ -126,32 +119,13 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.evaluate(() => window.localStorage.setItem('desktop:origin', null) ); - const originValue = 'http://localhost:9200'; - const authLoginNameValue = 'admin'; - const authLoginPasswordValue = '123456'; - - // Fill the origin input - await boundaryWindow.fill('[name=host]', originValue); - // Take screenshot - await boundaryWindow.screenshot({ - path: helpers.generateScreenshotPath( - screenshotsDirectory, - 'fillOrigin' - ), - fullPage: true, - }); - - // Click the submit button - await boundaryWindow.waitForSelector('button[type="submit"]'); - await helpers.click(boundaryWindow, 'button[type="submit"]'); - - // Fill user & password - await boundaryWindow.fill('[name="identification"]', authLoginNameValue); - await boundaryWindow.fill('[name="password"]', authLoginPasswordValue); - - // Click submit - await boundaryWindow.waitForSelector('button[type="submit"]'); - await helpers.click(boundaryWindow, 'button[type="submit"]'); + // Perform login + await helpers.login( + boundaryWindow, + originValue, + loginUsername, + '123456789' + ); // Wait for the notification await boundaryWindow.waitForSelector('.rose-notification-body'); diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index 9bb4d0b31..3baa15199 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -4,12 +4,19 @@ const { _electron: electron } = require('playwright'); const helpers = require('./test-helpers'); let electronApp = null; +// Subdirectory within tests/end2end/screenshots where the screenshots of this test suite will be stored. const screenshotsDirectory = 'targets/'; +// Path where the Boundary Desktop client binary is generated const executablePath = helpers.returnExecutablePath( process.platform, process.arch ); +// Set login variables +const originValue = 'http://localhost:9200'; +const loginUsername = 'admin'; +const loginPassword = 'password'; + test.beforeEach(async () => { electronApp = await electron.launch({ executablePath: executablePath, @@ -25,7 +32,7 @@ test.afterEach(async () => { electronApp = null; // Not sure we should do this. }); -test.describe.only('Targets end to end test suite', async () => { +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. @@ -37,9 +44,9 @@ test.describe.only('Targets end to end test suite', async () => { // Perform the login await helpers.login( boundaryWindow, - 'http://localhost:9200', - 'admin', - 'password' + originValue, + loginUsername, + loginPassword ); // Check we are in Targets