Skip to content

Commit b40653e

Browse files
committed
test: update e2e assertions for log outputs
1 parent 1457d6e commit b40653e

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

e2e/assertions/index.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { MatcherContext } from 'expect'
2-
import type { TreeItem, Workbench } from 'wdio-vscode-service'
2+
import type { BottomBarPanel, TreeItem, Workbench } from 'wdio-vscode-service'
33
import type { STATUS } from '../helpers/index.ts'
44

55
export interface ExpectedTreeItem {
@@ -94,18 +94,36 @@ try {
9494
},
9595
async hasExpectedLog(workbench: Workbench, expectedLog: RegExp | string) {
9696
const bottomBar = workbench.getBottomBar()
97+
9798
const outputView = await bottomBar.openOutputView()
9899
await outputView.selectChannel('WebdriverIO')
100+
await clickGlobalAction(bottomBar, bottomBar.locators.maximize)
99101
const logs = await outputView.getText()
100102

101103
const regexp = typeof expectedLog === 'string' ? new RegExp(expectedLog) : expectedLog
102104

103105
const pass = logs.some((log) => regexp.test(log))
106+
107+
await clickGlobalAction(bottomBar, bottomBar.locators.restore)
104108
const message = pass ? 'The log outputs include expected text.' : 'The expected text is not included'
105-
return { pass, message }
109+
return { pass, message: () => message }
106110
},
107111
})
108112
}
109113
} catch (error) {
110114
console.warn('Failed to extend expect:', error)
111115
}
116+
117+
async function clickGlobalAction(bottomBar: BottomBarPanel, label: string) {
118+
let action
119+
try {
120+
action = (await bottomBar.elem
121+
.$(bottomBar.locators.globalActions)
122+
.$(`.//a[contains(@aria-label, '${label}') and @role='checkbox']`)) as WebdriverIO.Element
123+
} catch {
124+
// the panel is already maximized
125+
}
126+
if (action) {
127+
await action.click({})
128+
}
129+
}

0 commit comments

Comments
 (0)