Skip to content

Commit 1c718cb

Browse files
authored
fix: InputBox.selectQuickPick is not working properly for File/Folder picker (#1914)
1 parent 347eaad commit 1c718cb

File tree

2 files changed

+36
-1
lines changed
  • packages/page-objects/src/components/workbench/input
  • tests/test-project/src/test/workbench

2 files changed

+36
-1
lines changed

packages/page-objects/src/components/workbench/input/Input.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import { AbstractElement } from '../../AbstractElement';
1919
import { Key, WebElement } from 'selenium-webdriver';
2020
import { NullAttributeError, QuickOpenBox } from '../../..';
21+
import { sep } from 'path';
2122

2223
/**
2324
* Abstract page object for input fields
@@ -224,7 +225,16 @@ export abstract class Input extends AbstractElement {
224225
private async resetPosition(): Promise<void> {
225226
const text = await this.getText();
226227
await this.clear();
227-
await this.setText(text);
228+
229+
// handle path as path, not as text - use platform-specific separator
230+
const hasTrailingSeparator = text.endsWith(sep);
231+
if (hasTrailingSeparator) {
232+
await this.setText(text.slice(0, -1));
233+
const input = await this.findElement(Input.locators.Input.inputBox).findElement(Input.locators.Input.input);
234+
await input.sendKeys(sep);
235+
} else {
236+
await this.setText(text);
237+
}
228238
}
229239
}
230240

tests/test-project/src/test/workbench/input.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,31 @@ describe('InputBox', () => {
196196
});
197197
});
198198

199+
describe('InputBox - works for path', () => {
200+
let input: InputBox;
201+
202+
before(async function () {
203+
this.timeout(10000);
204+
await new Workbench().executeCommand('File: Open Folder...');
205+
input = await InputBox.create();
206+
});
207+
208+
after(async () => {
209+
await new EditorView().closeAllEditors();
210+
});
211+
212+
it('findQuickPick works', async function () {
213+
const quickpick = await input.findQuickPick('test-folder');
214+
expect(quickpick).to.not.be.undefined;
215+
});
216+
217+
it('selectQuickPick works', async function () {
218+
await input.selectQuickPick('test-folder');
219+
const quickpick2 = await input.findQuickPick('foolder');
220+
expect(quickpick2).to.not.be.undefined;
221+
});
222+
});
223+
199224
describe('Multiple selection input', () => {
200225
let input: InputBox;
201226

0 commit comments

Comments
 (0)