Skip to content

Commit ded37e7

Browse files
authored
feat: BottomBarPanel support for custom tabs (#1697)
1 parent 93f55f0 commit ded37e7

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

docs/BottomBarPanel.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ const outputView = await bottomBar.openOutputView();
3232
const debugConsoleView = await bottomBar.openDebugConsoleView();
3333
const terminalView = await bottomBar.openTerminalView();
3434
```
35+
36+
#### Open custom panel
37+
38+
```typescript
39+
await bottomBar.openTab("name");
40+
```

packages/page-objects/src/components/bottomBar/BottomBarPanel.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ export class BottomBarPanel extends AbstractElement {
104104
await this.resize(BottomBarPanel.locators.BottomBarPanel.restore);
105105
}
106106

107-
private async openTab(title: string) {
107+
/**
108+
* Opens (or focuses) a tab in the bottom bar panel by its title.
109+
*
110+
* @param title The exact name of the tab to be opened or focused.
111+
* @returns A promise that resolves when the tab is opened or focused.
112+
*/
113+
public async openTab(title: string) {
108114
await this.toggle(true);
109115
const tabContainer = await this.findElement(BottomBarPanel.locators.BottomBarPanel.tabContainer);
110116
try {

tests/test-project/src/test/bottomBar/bottomBarPanel.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
*/
1717

1818
import { expect } from 'chai';
19-
import { BottomBarPanel, WebElement, Workbench, ViewControl, ActivityBar } from 'vscode-extension-tester';
19+
import path from 'path';
20+
import { BottomBarPanel, WebElement, Workbench, ViewControl, ActivityBar, WebviewView, By, VSBrowser } from 'vscode-extension-tester';
2021

2122
describe('BottomBarPanel', function () {
2223
let panel: BottomBarPanel;
2324

2425
before(async function () {
26+
const browser = VSBrowser.instance;
27+
await browser.openResources(path.resolve(__dirname, '..', '..', '..', 'resources', 'debug-project'));
28+
2529
panel = new BottomBarPanel();
2630
await (await new Workbench().openNotificationsCenter()).clearAllNotifications();
2731
await ((await new ActivityBar().getViewControl('Explorer')) as ViewControl).closeView();
@@ -76,6 +80,16 @@ describe('BottomBarPanel', function () {
7680
const view = await panel.openTerminalView();
7781
expect(await view.isDisplayed()).is.true;
7882
});
83+
84+
it('can switch tabs using openTab', async function () {
85+
panel = new BottomBarPanel();
86+
await panel.openTab('My Panel');
87+
const webviewView = new WebviewView();
88+
await webviewView.switchToFrame(5000);
89+
const element = await webviewView.findWebElement(By.css('h1'));
90+
expect(await element.getText()).has.string('Shopping List');
91+
await webviewView.switchBack();
92+
});
7993
});
8094

8195
async function getHeight(element: WebElement): Promise<number> {

tests/test-project/src/test/webview/webviewView.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ describe('WebviewViews', function () {
4949
let webviewView: InstanceType<typeof WebviewView>;
5050

5151
before(async function () {
52+
this.timeout(10000);
5253
await new Workbench().executeCommand(param.command);
54+
await new Promise((res) => setTimeout(res, 2000));
5355
webviewView = new WebviewView();
54-
await webviewView.switchToFrame(1000);
56+
await webviewView.switchToFrame(5000);
5557
});
5658

5759
after(async function () {

0 commit comments

Comments
 (0)