|
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,39 @@ try { |
94 | 94 | }, |
95 | 95 | async hasExpectedLog(workbench: Workbench, expectedLog: RegExp | string) { |
96 | 96 | const bottomBar = workbench.getBottomBar() |
| 97 | + await bottomBar.toggle(true) |
| 98 | + await clickGlobalAction(bottomBar, bottomBar.locators.maximize) |
| 99 | + |
97 | 100 | const outputView = await bottomBar.openOutputView() |
98 | 101 | await outputView.selectChannel('WebdriverIO') |
99 | 102 | const logs = await outputView.getText() |
100 | 103 |
|
101 | 104 | const regexp = typeof expectedLog === 'string' ? new RegExp(expectedLog) : expectedLog |
102 | 105 |
|
103 | 106 | const pass = logs.some((log) => regexp.test(log)) |
| 107 | + |
| 108 | + await bottomBar.toggle(true) |
| 109 | + await clickGlobalAction(bottomBar, bottomBar.locators.restore) |
104 | 110 | const message = pass ? 'The log outputs include expected text.' : 'The expected text is not included' |
105 | | - return { pass, message } |
| 111 | + return { pass, message: () => message } |
106 | 112 | }, |
107 | 113 | }) |
108 | 114 | } |
109 | 115 | } catch (error) { |
110 | 116 | console.warn('Failed to extend expect:', error) |
111 | 117 | } |
| 118 | + |
| 119 | +async function clickGlobalAction(bottomBar: BottomBarPanel, label: string) { |
| 120 | + await bottomBar.toggle(true) |
| 121 | + let action |
| 122 | + try { |
| 123 | + action = await bottomBar.elem |
| 124 | + .$(bottomBar.locators.globalActions) |
| 125 | + .$(`.//a[contains(@aria-label, '${label}') and @role='checkbox']`) |
| 126 | + } catch { |
| 127 | + // the panel is already maximized |
| 128 | + } |
| 129 | + if (action) { |
| 130 | + await action.click() |
| 131 | + } |
| 132 | +} |
0 commit comments