From e30168c55afa07f519e72a0a298aa75a636367a0 Mon Sep 17 00:00:00 2001 From: Priya Patel Date: Fri, 3 Apr 2026 11:49:45 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20DC=20e2e=20tests=20(#3216?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 fixed DC e2e tests * chore: 🤖 addressed feedback --- e2e-tests/desktop/fixtures/electronTest.js | 12 ++++++++++++ e2e-tests/desktop/tests/sessions.spec.js | 8 ++++++-- e2e-tests/desktop/tests/targets.spec.js | 12 ++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/e2e-tests/desktop/fixtures/electronTest.js b/e2e-tests/desktop/fixtures/electronTest.js index 5b42be9f7..181381ead 100644 --- a/e2e-tests/desktop/fixtures/electronTest.js +++ b/e2e-tests/desktop/fixtures/electronTest.js @@ -137,4 +137,16 @@ export const electronTest = test.extend({ await use(page); }, + // Get terminal WebContentsView when it's created + terminalView: async ({ electronApp }, use) => { + const getTerminalView = async () => { + const windows = await electronApp.windows(); + // terminal view is loaded at - serve://boundary/terminal + const terminal = windows.find((window) => + window.url().includes('terminal'), + ); + return terminal; + }; + await use(getTerminalView); + }, }); diff --git a/e2e-tests/desktop/tests/sessions.spec.js b/e2e-tests/desktop/tests/sessions.spec.js index dc4d99bbf..06b4f8d67 100644 --- a/e2e-tests/desktop/tests/sessions.spec.js +++ b/e2e-tests/desktop/tests/sessions.spec.js @@ -211,7 +211,7 @@ test.describe('Filtering sessions tests', () => { ).toBeVisible(); }); - test('Filters by status', async ({ authedPage, tesseract }) => { + test('Filters by status', async ({ authedPage, tesseract, terminalView }) => { await authedPage .getByRole('row', { name: sshTarget.name }) .getByRole('link') @@ -219,7 +219,11 @@ test.describe('Filtering sessions tests', () => { .click(); await authedPage.getByRole('tab', { name: 'Shell' }).click(); await expect(async () => { - const screenshot = await authedPage.locator('.xterm-screen').screenshot(); + const terminal = await terminalView(); + if (!terminal) { + throw new Error('Terminal view not found'); + } + const screenshot = await terminal.locator('.xterm-screen').screenshot(); const result = await tesseract.recognize(screenshot); expect(result.data.text).toMatch(textToMatch); }).toPass(); diff --git a/e2e-tests/desktop/tests/targets.spec.js b/e2e-tests/desktop/tests/targets.spec.js index 83f6578c7..ec9dab9b6 100644 --- a/e2e-tests/desktop/tests/targets.spec.js +++ b/e2e-tests/desktop/tests/targets.spec.js @@ -254,7 +254,11 @@ test.describe('Targets tests', () => { }); }); - test('Connects to an SSH target', async ({ authedPage, tesseract }) => { + test('Connects to an SSH target', async ({ + authedPage, + tesseract, + terminalView, + }) => { await authedPage.getByRole('link', { name: sshTarget.name }).click(); await authedPage.getByRole('button', { name: 'Connect' }).click(); @@ -265,7 +269,11 @@ test.describe('Targets tests', () => { await authedPage.getByRole('tab', { name: 'Shell' }).click(); await expect(async () => { - const screenshot = await authedPage.locator('.xterm-screen').screenshot(); + const terminal = await terminalView(); + if (!terminal) { + throw new Error('Terminal view not found'); + } + const screenshot = await terminal.locator('.xterm-screen').screenshot(); const result = await tesseract.recognize(screenshot); expect(result.data.text).toMatch(textToMatch); }).toPass();