From b3c27f2926a2ae75eed7970f711d63b3b105aa6b Mon Sep 17 00:00:00 2001 From: Zacharias Fragkiadakis Date: Tue, 31 Dec 2024 12:55:01 +0200 Subject: [PATCH] test(e2e): clear setting input and wait for output update Signed-off-by: Zacharias Fragkiadakis --- test/e2e/specs/settings.spec.ts | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/test/e2e/specs/settings.spec.ts b/test/e2e/specs/settings.spec.ts index aef35cfb..573190ac 100644 --- a/test/e2e/specs/settings.spec.ts +++ b/test/e2e/specs/settings.spec.ts @@ -1,5 +1,5 @@ import { browser } from '@wdio/globals' -import type { Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' +import type { OutputView, Setting, SettingsEditor, Workbench } from 'wdio-vscode-service' import isEqual from 'lodash/isEqual' import { Key } from 'webdriverio' import { $ } from 'zx' @@ -111,14 +111,12 @@ describe('Settings', () => { await setTextSettingValue(pathToNodeHomeSetting, '/tmp') // Assert that the error message is displayed in the output console - await browser.waitUntil( - async () => { - const joinedText = (await outputView.getText()).join('') + await expectOutputToContain(outputView, '✗ Error: Radicle profile not found in') - return joinedText.includes('✗ Error: Radicle profile not found in') - }, - { timeoutMsg: 'expected the error message to be displayed in the output console' }, - ) + await outputView.clearText() + await clearTextSetting(pathToNodeHomeSetting) + + await expectOutputToContain(outputView, 'Using already unsealed Radicle identity') }) }) }) @@ -186,3 +184,20 @@ async function clearInput(input: WebdriverIO.Element) { await browser.keys([Key.Ctrl, 'a']) await browser.keys(Key.Backspace) } + +async function expectOutputToContain(outputView: OutputView, expected: string) { + await browser.waitUntil( + async () => { + /** + * The text in the output console is split by newlines, which can be affected by the size + * of the window. To avoid this, we join the text into a single string. + */ + const joinedText = (await outputView.getText()).join('') + + return joinedText.includes(expected) + }, + { + timeoutMsg: `expected the output text to contain "${expected}"`, + }, + ) +}