|
1 | 1 | import type { MatcherContext } from 'expect' |
2 | | -import type { TreeItem, Workbench } from 'wdio-vscode-service' |
| 2 | +import type { BottomBarPanel, TreeItem, Workbench } from 'wdio-vscode-service' |
3 | 3 | import type { STATUS } from '../helpers/index.ts' |
4 | 4 |
|
5 | 5 | export interface ExpectedTreeItem { |
@@ -94,18 +94,36 @@ try { |
94 | 94 | }, |
95 | 95 | async hasExpectedLog(workbench: Workbench, expectedLog: RegExp | string) { |
96 | 96 | const bottomBar = workbench.getBottomBar() |
| 97 | + |
97 | 98 | const outputView = await bottomBar.openOutputView() |
98 | 99 | await outputView.selectChannel('WebdriverIO') |
| 100 | + await clickGlobalAction(bottomBar, bottomBar.locators.maximize) |
99 | 101 | const logs = await outputView.getText() |
100 | 102 |
|
101 | 103 | const regexp = typeof expectedLog === 'string' ? new RegExp(expectedLog) : expectedLog |
102 | 104 |
|
103 | 105 | const pass = logs.some((log) => regexp.test(log)) |
| 106 | + |
| 107 | + await clickGlobalAction(bottomBar, bottomBar.locators.restore) |
104 | 108 | const message = pass ? 'The log outputs include expected text.' : 'The expected text is not included' |
105 | | - return { pass, message } |
| 109 | + return { pass, message: () => message } |
106 | 110 | }, |
107 | 111 | }) |
108 | 112 | } |
109 | 113 | } catch (error) { |
110 | 114 | console.warn('Failed to extend expect:', error) |
111 | 115 | } |
| 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