From e0cee85ad4d5cfe40cfaae2a711601ca777b61fa Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Thu, 7 Oct 2021 13:28:51 -0700 Subject: [PATCH 1/3] =?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 2/3] =?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 --- .../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 3/3] 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