Skip to content

Commit

Permalink
test(e2e): clear setting input and wait for output update
Browse files Browse the repository at this point in the history
Signed-off-by: Zacharias Fragkiadakis <zacfragkiadakis@gmail.com>
  • Loading branch information
QZera committed Dec 31, 2024
1 parent 9fca347 commit b3c27f2
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/e2e/specs/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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')
})
})
})
Expand Down Expand Up @@ -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}"`,
},
)
}

0 comments on commit b3c27f2

Please sign in to comment.