From 4db7dc89c752ade053fe18f2255e5a8f03632ca8 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Wed, 13 Oct 2021 14:07:37 -0700 Subject: [PATCH 1/6] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Create=20generat?= =?UTF-8?q?eScreenshotPath=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/targets.spec.js | 7 +++++++ ui/desktop/tests/end2end/test-helpers.js | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index 2ee467d17..e3d59c558 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -1,6 +1,7 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); +<<<<<<< HEAD const { generateScreenshotPath, returnExecutablePath, @@ -9,6 +10,12 @@ const { let electronApp = null; const screenshotsDirectory = 'targets/'; const executablePath = returnExecutablePath(process.platform, process.arch); +======= +const { generateScreenshotPath } = require('./test-helpers'); + +let electronApp = null; +const screenshotsDirectory = 'targets/'; +>>>>>>> 8c489b81 (refactor: 💡 Create generateScreenshotPath as test helper) test.beforeEach(async () => { electronApp = await electron.launch({ diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index ff6902143..ffd01eae8 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -9,13 +9,18 @@ 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 ); return path.join(screenshotPath, fileName).concat(screenshotFormat); }; +<<<<<<< HEAD /** * @@ -42,3 +47,5 @@ exports.returnExecutablePath = (platform, arch) => { console.error(error); } }; +======= +>>>>>>> 8c489b81 (refactor: 💡 Create generateScreenshotPath as test helper) From c056b271764f9eb203a2a0c9845c78ea29e7fa1b Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 14 Oct 2021 11:24:03 -0700 Subject: [PATCH 2/6] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Move=20returnExe?= =?UTF-8?q?cutablePath=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. --- ui/desktop/tests/end2end/targets.spec.js | 7 ------- ui/desktop/tests/end2end/test-helpers.js | 7 ------- 2 files changed, 14 deletions(-) diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index e3d59c558..2ee467d17 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -1,7 +1,6 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -<<<<<<< HEAD const { generateScreenshotPath, returnExecutablePath, @@ -10,12 +9,6 @@ const { let electronApp = null; const screenshotsDirectory = 'targets/'; const executablePath = returnExecutablePath(process.platform, process.arch); -======= -const { generateScreenshotPath } = require('./test-helpers'); - -let electronApp = null; -const screenshotsDirectory = 'targets/'; ->>>>>>> 8c489b81 (refactor: 💡 Create generateScreenshotPath as test helper) test.beforeEach(async () => { electronApp = await electron.launch({ diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index ffd01eae8..ff6902143 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -9,18 +9,13 @@ 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 ); return path.join(screenshotPath, fileName).concat(screenshotFormat); }; -<<<<<<< HEAD /** * @@ -47,5 +42,3 @@ exports.returnExecutablePath = (platform, arch) => { console.error(error); } }; -======= ->>>>>>> 8c489b81 (refactor: 💡 Create generateScreenshotPath as test helper) From 9e6b051353561a7f47fc752657d77834ad111685 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 14 Oct 2021 13:33:52 -0700 Subject: [PATCH 3/6] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Add=20a=20custom?= =?UTF-8?q?=20click=20for=20test=20helpers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a custom click function, it does a workaround for an issue within playwright. That function has been created in test helpers file --- .../tests/end2end/authentication.spec.js | 31 ++++++---------- ui/desktop/tests/end2end/targets.spec.js | 36 +++++++++---------- ui/desktop/tests/end2end/test-helpers.js | 11 ++++++ 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index 71667b0de..b61909b92 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -4,6 +4,7 @@ const { _electron: electron } = require('playwright'); const { generateScreenshotPath, returnExecutablePath, + customClick, } = require('./test-helpers'); let electronApp = null; @@ -29,6 +30,7 @@ test.describe('Authentication end to end test suite', async () => { test.describe('user/password authentication test suite', async () => { test('Authenticates using user and password method and deauthenticates ', 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) @@ -47,12 +49,9 @@ test.describe('Authentication end to end test suite', async () => { }); // 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() - ); + await customClick(boundaryWindow, 'button[type="submit"]'); + // Fill user & password await boundaryWindow.fill('[name="identification"]', authLoginNameValue); await boundaryWindow.fill('[name="password"]', authLoginPasswordValue); @@ -64,9 +63,7 @@ test.describe('Authentication end to end test suite', async () => { // Click submit await boundaryWindow.waitForSelector('button[type="submit"]'); - await boundaryWindow.$eval('button[type="submit"]', (element) => - element.click() - ); + await customClick(boundaryWindow, 'button[type="submit"]'); // Check we are in Targets await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); @@ -96,14 +93,13 @@ test.describe('Authentication end to end test suite', async () => { // Clicks Deauthenticate await boundaryWindow.waitForSelector('text="Deauthenticate"'); - await boundaryWindow.$eval('text="Deauthenticate"', (element) => - element.click() - ); + await customClick(boundaryWindow, 'text="Deauthenticate"'); // Makes sure we are log out await boundaryWindow.waitForSelector('main >> div.branded-card'); expect(await boundaryWindow.isVisible('h2 >> text=Authenticate')); - // ToDo: create an assertion checking localstorage ember_simple_auth-session key + // TODO: create an assertion checking localstorage ember_simple_auth-session key + // TODO: try to check we are log out by url // Take screenshot await boundaryWindow.screenshot({ @@ -131,21 +127,16 @@ test.describe('Authentication end to end test suite', async () => { }); // 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() - ); + await customClick(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 boundaryWindow.$eval('button[type="submit"]', (element) => - element.click() - ); + await customClick(boundaryWindow, 'button[type="submit"]'); // 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 2ee467d17..f1db328f3 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -4,6 +4,7 @@ const { _electron: electron } = require('playwright'); const { generateScreenshotPath, returnExecutablePath, + customClick, } = require('./test-helpers'); let electronApp = null; @@ -42,21 +43,16 @@ test.describe('Targets end to end test suite', async () => { 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. - // 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() - ); + await customClick(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 boundaryWindow.$eval('button[type="submit"]', (element) => - element.click() - ); + await customClick(boundaryWindow, 'button[type="submit"]'); // Check we are in Targets await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); @@ -65,9 +61,9 @@ test.describe('Targets end to end test suite', async () => { // 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() + await customClick( + boundaryWindow, + 'table.rose-table >> tbody >> tr >> nth=0 >> button >> text=Connect' ); // The target popup opens @@ -82,9 +78,9 @@ test.describe('Targets end to end test suite', async () => { }); // 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() + await customClick( + boundaryWindow, + 'section.dialog-detail >> div.rose-dialog-body >> button' ); // Temporary: persist proxy from target const persistedProxy = await boundaryWindow.innerText( @@ -92,16 +88,16 @@ test.describe('Targets end to end test suite', async () => { ); // Click close popup - await boundaryWindow.$eval( - 'section.dialog-detail >> footer >> button', - (element) => element.click() + await customClick( + boundaryWindow, + 'section.dialog-detail >> footer >> button' ); // 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() + await customClick( + boundaryWindow, + 'section.rose-layout-global >> aside >> nav >> a >> text=Sessions' ); // Take screenshot diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index ff6902143..261e4fd21 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -42,3 +42,14 @@ exports.returnExecutablePath = (platform, arch) => { console.error(error); } }; + +/** + * + * @param {*} appWindow + * @param {*} selector + */ +exports.customClick = async (appWindow, selector) => { + // Due to an error with await appWindow.click('button[type="submit"]'); we are using a workaround. + // More info about it here: https://github.com/microsoft/playwright/issues/1808 + await appWindow.$eval(selector, (element) => element.click()); +}; From 50ef25fda1f287ad25db62a10b5b698a9d87bbc5 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 14 Oct 2021 13:35:41 -0700 Subject: [PATCH 4/6] Enhance function comments --- ui/desktop/tests/end2end/test-helpers.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 261e4fd21..b76f3f812 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -44,12 +44,11 @@ exports.returnExecutablePath = (platform, arch) => { }; /** - * - * @param {*} appWindow - * @param {*} selector + * 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. */ exports.customClick = async (appWindow, selector) => { - // Due to an error with await appWindow.click('button[type="submit"]'); we are using a workaround. - // More info about it here: https://github.com/microsoft/playwright/issues/1808 await appWindow.$eval(selector, (element) => element.click()); }; From a220b2544913313ddab89e79ba46bb35d6f37e3c Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 15 Oct 2021 11:08:25 -0700 Subject: [PATCH 5/6] Missed customClick refactor --- ui/desktop/tests/end2end/authentication.spec.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index b61909b92..2b53b6610 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -78,9 +78,7 @@ test.describe('Authentication end to end test suite', async () => { // Opens user dropdown await boundaryWindow.waitForSelector('.rose-header-utilities'); - await boundaryWindow.$eval('.rose-header-utilities summary', (element) => - element.click() - ); + await customClick(boundaryWindow, '.rose-header-utilities summary'); // User dropdown is visible await boundaryWindow.waitForSelector('details[open]'); @@ -183,15 +181,11 @@ test.describe('Authentication end to end test suite', async () => { // 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() - ); + await customClick(boundaryWindow, 'button[type="submit"]'); // Click tab OIDC await boundaryWindow.waitForSelector('main >> div.branded-card >> nav'); - await boundaryWindow.$eval('a:text("OIDC")', (element) => { - element.click(); - }); + await customClick(boundaryWindow, 'a:text("OIDC")'); await boundaryWindow.pause(); }); From fd43d8ef597cefa93eaa9098d98623e6d19c2219 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Mon, 18 Oct 2021 12:52:39 -0700 Subject: [PATCH 6/6] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Change=20functio?= =?UTF-8?q?n=20name=20and=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/end2end/authentication.spec.js | 59 ++++++++++++------- ui/desktop/tests/end2end/targets.spec.js | 27 ++++----- ui/desktop/tests/end2end/test-helpers.js | 2 +- 3 files changed, 52 insertions(+), 36 deletions(-) diff --git a/ui/desktop/tests/end2end/authentication.spec.js b/ui/desktop/tests/end2end/authentication.spec.js index 2b53b6610..93540c0f7 100644 --- a/ui/desktop/tests/end2end/authentication.spec.js +++ b/ui/desktop/tests/end2end/authentication.spec.js @@ -1,15 +1,14 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const { - generateScreenshotPath, - returnExecutablePath, - customClick, -} = require('./test-helpers'); +const helpers = require('./test-helpers'); let electronApp = null; const screenshotsDirectory = 'authentication/'; -const executablePath = returnExecutablePath(process.platform, process.arch); +const executablePath = helpers.returnExecutablePath( + process.platform, + process.arch +); test.beforeEach(async () => { electronApp = await electron.launch({ @@ -44,26 +43,32 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.fill('[name=host]', originValue); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath(screenshotsDirectory, 'fillOrigin'), + path: helpers.generateScreenshotPath( + screenshotsDirectory, + 'fillOrigin' + ), fullPage: true, }); // Click the submit button await boundaryWindow.waitForSelector('button[type="submit"]'); - await customClick(boundaryWindow, '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: generateScreenshotPath(screenshotsDirectory, 'fillUserPassword'), + path: helpers.generateScreenshotPath( + screenshotsDirectory, + 'fillUserPassword' + ), fullPage: true, }); // Click submit await boundaryWindow.waitForSelector('button[type="submit"]'); - await customClick(boundaryWindow, 'button[type="submit"]'); + await helpers.click(boundaryWindow, 'button[type="submit"]'); // Check we are in Targets await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); @@ -72,26 +77,32 @@ test.describe('Authentication end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath(screenshotsDirectory, 'afterLogin'), + path: helpers.generateScreenshotPath( + screenshotsDirectory, + 'afterLogin' + ), fullPage: true, }); // Opens user dropdown await boundaryWindow.waitForSelector('.rose-header-utilities'); - await customClick(boundaryWindow, '.rose-header-utilities summary'); + await helpers.click(boundaryWindow, '.rose-header-utilities summary'); // User dropdown is visible await boundaryWindow.waitForSelector('details[open]'); expect(await boundaryWindow.isVisible('details')); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath(screenshotsDirectory, 'userDropdown'), + path: helpers.generateScreenshotPath( + screenshotsDirectory, + 'userDropdown' + ), fullPage: true, }); // Clicks Deauthenticate await boundaryWindow.waitForSelector('text="Deauthenticate"'); - await customClick(boundaryWindow, 'text="Deauthenticate"'); + await helpers.click(boundaryWindow, 'text="Deauthenticate"'); // Makes sure we are log out await boundaryWindow.waitForSelector('main >> div.branded-card'); @@ -101,7 +112,10 @@ test.describe('Authentication end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath(screenshotsDirectory, 'afterLogout'), + path: helpers.generateScreenshotPath( + screenshotsDirectory, + 'afterLogout' + ), fullPage: true, }); }); @@ -120,13 +134,16 @@ test.describe('Authentication end to end test suite', async () => { await boundaryWindow.fill('[name=host]', originValue); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath(screenshotsDirectory, 'fillOrigin'), + path: helpers.generateScreenshotPath( + screenshotsDirectory, + 'fillOrigin' + ), fullPage: true, }); // Click the submit button await boundaryWindow.waitForSelector('button[type="submit"]'); - await customClick(boundaryWindow, 'button[type="submit"]'); + await helpers.click(boundaryWindow, 'button[type="submit"]'); // Fill user & password await boundaryWindow.fill('[name="identification"]', authLoginNameValue); @@ -134,7 +151,7 @@ test.describe('Authentication end to end test suite', async () => { // Click submit await boundaryWindow.waitForSelector('button[type="submit"]'); - await customClick(boundaryWindow, 'button[type="submit"]'); + await helpers.click(boundaryWindow, 'button[type="submit"]'); // Wait for the notification await boundaryWindow.waitForSelector('.rose-notification-body'); @@ -145,7 +162,7 @@ test.describe('Authentication end to end test suite', async () => { // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath( + path: helpers.generateScreenshotPath( screenshotsDirectory, 'notificationFailed' ), @@ -181,11 +198,11 @@ test.describe('Authentication end to end test suite', async () => { // 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 customClick(boundaryWindow, 'button[type="submit"]'); + await helpers.click(boundaryWindow, 'button[type="submit"]'); // Click tab OIDC await boundaryWindow.waitForSelector('main >> div.branded-card >> nav'); - await customClick(boundaryWindow, 'a:text("OIDC")'); + await helpers.click(boundaryWindow, 'a:text("OIDC")'); await boundaryWindow.pause(); }); diff --git a/ui/desktop/tests/end2end/targets.spec.js b/ui/desktop/tests/end2end/targets.spec.js index f1db328f3..e71211cf1 100644 --- a/ui/desktop/tests/end2end/targets.spec.js +++ b/ui/desktop/tests/end2end/targets.spec.js @@ -1,15 +1,14 @@ /* eslint-disable no-undef */ const { test, expect } = require('@playwright/test'); const { _electron: electron } = require('playwright'); -const { - generateScreenshotPath, - returnExecutablePath, - customClick, -} = require('./test-helpers'); +const helpers = require('./test-helpers'); let electronApp = null; const screenshotsDirectory = 'targets/'; -const executablePath = returnExecutablePath(process.platform, process.arch); +const executablePath = helpers.returnExecutablePath( + process.platform, + process.arch +); test.beforeEach(async () => { electronApp = await electron.launch({ @@ -44,7 +43,7 @@ test.describe('Targets end to end test suite', async () => { // Click the submit button await boundaryWindow.waitForSelector('button[type="submit"]'); - await customClick(boundaryWindow, 'button[type="submit"]'); + await helpers.click(boundaryWindow, 'button[type="submit"]'); // Fill user & password await boundaryWindow.fill('[name="identification"]', authLoginNameValue); @@ -52,7 +51,7 @@ test.describe('Targets end to end test suite', async () => { // Click submit await boundaryWindow.waitForSelector('button[type="submit"]'); - await customClick(boundaryWindow, 'button[type="submit"]'); + await helpers.click(boundaryWindow, 'button[type="submit"]'); // Check we are in Targets await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets'); @@ -61,7 +60,7 @@ test.describe('Targets end to end test suite', async () => { // Click connect to a target await boundaryWindow.waitForSelector('table.rose-table'); - await customClick( + await helpers.click( boundaryWindow, 'table.rose-table >> tbody >> tr >> nth=0 >> button >> text=Connect' ); @@ -70,7 +69,7 @@ test.describe('Targets end to end test suite', async () => { await boundaryWindow.waitForSelector('section.dialog-detail'); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath( + path: helpers.generateScreenshotPath( screenshotsDirectory, 'targetConnectionDetails' ), @@ -78,7 +77,7 @@ test.describe('Targets end to end test suite', async () => { }); // Click copyable in popup // TODO: read clipboard value. Running into issues reading clipboard, so will take a shortcut for now - await customClick( + await helpers.click( boundaryWindow, 'section.dialog-detail >> div.rose-dialog-body >> button' ); @@ -88,21 +87,21 @@ test.describe('Targets end to end test suite', async () => { ); // Click close popup - await customClick( + await helpers.click( boundaryWindow, 'section.dialog-detail >> footer >> button' ); // On left nav menu, click Sessions await boundaryWindow.waitForSelector('section.rose-layout-global >> aside'); - await customClick( + await helpers.click( boundaryWindow, 'section.rose-layout-global >> aside >> nav >> a >> text=Sessions' ); // Take screenshot await boundaryWindow.screenshot({ - path: generateScreenshotPath(screenshotsDirectory, 'sessions'), + path: helpers.generateScreenshotPath(screenshotsDirectory, 'sessions'), fullPage: true, }); diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index b76f3f812..ba7e739fd 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -49,6 +49,6 @@ exports.returnExecutablePath = (platform, arch) => { * @param {*} appWindow The current electron window. * @param {*} selector The DOM element selector. */ -exports.customClick = async (appWindow, selector) => { +exports.click = async (appWindow, selector) => { await appWindow.$eval(selector, (element) => element.click()); };