Skip to content

Commit

Permalink
issue-742: Clicks not being intercepted in SideBarView and BottomBarP…
Browse files Browse the repository at this point in the history
…annel (#1001)

Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek authored Nov 15, 2023
1 parent b8ae73a commit 7be6f19
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 32 deletions.
1 change: 1 addition & 0 deletions locators/lib/1.37.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const bottomBar = {
collapseAll: By.className('collapse-all'),
markerRow: By.className('monaco-list-row'),
rowLabel: 'aria-label',
label: By.className('monaco-highlighted-label'),
markerTwistie: By.className('monaco-tl-twistie'),
changeCount: By.className('monaco-count-badge')
},
Expand Down
27 changes: 19 additions & 8 deletions page-objects/src/components/bottomBar/ProblemsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,19 @@ export class ProblemsView extends AbstractElement {
}

/**
* Page object for marker in problems view
* Page object for a Marker in Problems view
*/
export class Marker extends ElementWithContexMenu {

constructor(element: WebElement, view: ProblemsView) {
super(element, view);
}

/**
* Get the type of the marker
* Possible types are: File, Error, Warning
* Get the type of the marker. Possible types are:
* - File
* - Error
* - Warning
* @returns Promise resolving to a MarkerType
*/
async getType(): Promise<MarkerType> {
Expand All @@ -108,16 +111,24 @@ export class Marker extends ElementWithContexMenu {
}

/**
* Get the full text of the marker
* @returns Promise resolving to marker text
* Get the full text of the Marker row
* @returns Promise resolving to a Marker row text
*/
async getText(): Promise<string> {
return await this.getAttribute(ProblemsView.locators.ProblemsView.rowLabel);
}

/**
* Expand/Collapse the marker if possible
* @param expand true to expand, false to collapse
* Get the Marker label text
* @returns Promise resolving to a Marker label
*/
async getLabel(): Promise<string> {
return await (await this.findElement(ProblemsView.locators.ProblemsView.label)).getText();
}

/**
* Expand/Collapse the Marker if possible
* @param expand True to expand, False to collapse
* @returns Promise resolving when the expand/collapse twistie is clicked
*/
async toggleExpand(expand: boolean): Promise<void> {
Expand All @@ -142,4 +153,4 @@ export enum MarkerType {
Error = 'error',
Warning = 'warning',
Any = 'any'
}
}
1 change: 1 addition & 0 deletions page-objects/src/locators/locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface Locators {
collapseAll: By
markerRow: By
rowLabel: string
label: By
markerTwistie: By
changeCount: By
}
Expand Down
36 changes: 23 additions & 13 deletions test/test-project/src/test/bottomBar/problemsView-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import * as path from 'path';
import { TextEditor, EditorView, ProblemsView, BottomBarPanel, MarkerType, VSBrowser } from "vscode-extension-tester";
import { expect } from 'chai';

describe('ProblemsView', () => {
describe('ProblemsView', function () {
let editor: TextEditor;
let view: ProblemsView;
let bar: BottomBarPanel;

before(async function() {
before(async function () {
this.timeout(25000);
await VSBrowser.instance.openResources(path.resolve(__dirname, '..', '..', '..', '..', 'resources', 'test-file.ts'));

Expand All @@ -20,7 +20,7 @@ import { expect } from 'chai';
await view.getDriver().wait(() => { return problemsExist(view); }, 15000);
});

after(async () => {
after(async function () {
await view.clearFilter();
await editor.clearText();
if (await editor.isDirty()) {
Expand All @@ -30,55 +30,65 @@ import { expect } from 'chai';
await bar.toggle(false);
});

it('get all markers works', async () => {
it('get all markers works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.Any);
expect(markers.length).greaterThan(1);
});

it('get warnings works', async () => {
it('get warnings works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.Warning);
expect(markers).empty;
});

it('get errors works', async () => {
it('get errors works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.Error);
expect(markers.length).equals(1);
});

it('get files works', async () => {
it('get files works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.File);
expect(markers.length).equals(1);
});

it('filtering works', async () => {
it('filtering works', async function () {
await view.setFilter('aaaa');
await view.getDriver().sleep(500);
const markers = await view.getAllVisibleMarkers(MarkerType.Any);
expect(markers.length).equals(2);
});

describe('Marker', () => {
it('getType works', async () => {
describe('Marker', function () {
it('getType works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.Error);
expect(await markers[0].getType()).equals(MarkerType.Error);
});

it('getText works', async () => {
it('getText works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.File);
expect(await markers[0].getText()).has.string('test-file.ts');
});

it('toggleExpand works', async () => {
it('toggleExpand works', async function () {
const marker = (await view.getAllVisibleMarkers(MarkerType.File))[0];
await marker.toggleExpand(false);
let markers = await view.getAllVisibleMarkers(MarkerType.Any);
expect(markers.length).equals(1);


await marker.toggleExpand(true);
markers = await view.getAllVisibleMarkers(MarkerType.Any);
expect(markers.length).equals(2);
});

it('click works', async function () {
const markers = await view.getAllVisibleMarkers(MarkerType.File);
for (const marker of markers) {
if(await marker.getLabel() === 'test-file.ts') {
await marker.click();
}
}
const anyMarkers = await view.getAllVisibleMarkers(MarkerType.Any);
expect(anyMarkers.length).equals(1);
});
});
});

Expand Down
32 changes: 21 additions & 11 deletions wiki/ProblemsView.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,64 @@
![problems](https://user-images.githubusercontent.com/4181232/56641152-fe49ce00-6674-11e9-9a5d-096a61c0b835.png)

#### Lookup

```typescript
import { BottomBarPanel, ProblemsView } from 'vscode-extension-tester';
...
const problemsView = await new BottomBarPanel().openProblemsView();
```

#### Set Filter
#### Set a Filter

Fill in a string into the filter box.

```typescript
await problemsView.setFilter('**/filter/glob*');
```

#### Collapse All Markers

```typescript
await problemsView.collapseAll();
```

#### Get Handles to All Markers

```typescript
import { MarkerType } from 'vscode-extension-tester';
...
// get all markers regardless of type
const markers = await problemsView.getAllMarkers(MarkerType.Any);
const markers = await problemsView.getAllVisibleMarkers(MarkerType.Any);
// get all error markers
const errors = await problemsView.getAllMarkers(MarkerType.Error);
const errors = await problemsView.getAllVisibleMarkers(MarkerType.Error);
// get all warning markers
const errors = await problemsView.getAllMarkers(MarkerType.Warning);
const errors = await problemsView.getAllVisibleMarkers(MarkerType.Warning);
// get all file markers
const errors = await problemsView.getAllMarkers(MarkerType.File);
const errors = await problemsView.getAllVisibleMarkers(MarkerType.File);
```

### Marker
Markers represent items displayed in the problems view.

Markers represent items displayed in the problems view. Each row corresponds to one Marker item.

#### Retrieval
``` typescript
const markers = await problemsView.getAllMarkers(MarkerType.Any);

```typescript
const markers = await problemsView.getAllVisibleMarkers(MarkerType.Any);
const marker = markers[0];
```

#### Actions
``` typescript

```typescript
// get the marker type
const type = await marker.getType();
// get the text of the marker
// get the text of the marker row
const text = await marker.getText();
// get the label of the marker
const text = await marker.getLabel();
// expand the marker if available
await marker.toggleExpand(true);
// collapse
await marker.toggleExpand(false);
```
```

0 comments on commit 7be6f19

Please sign in to comment.