Skip to content

Commit 07ad092

Browse files
committed
fix: flaky ubuntu
1 parent e6139cd commit 07ad092

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

test/ui/suite/commands.ui.test.ts

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,62 +75,55 @@ async function readSerializedData(): Promise<SerializedData | undefined> {
7575
* Opens the sample file, using the file picker when needed.
7676
*/
7777
async function openSampleFile(): Promise<TextEditor> {
78-
// Fast path: the tab is already open.
78+
const editorView = new EditorView();
7979
try {
80-
return (await new EditorView().openEditor(SAMPLE_FILE_BASENAME)) as TextEditor;
80+
return (await editorView.openEditor(SAMPLE_FILE_BASENAME)) as TextEditor;
8181
} catch {
82-
// Tab not open yet. Try the code CLI first; if that doesn't work
83-
// (common on Linux CI where the CLI can't reach the chromedriver-
84-
// managed VS Code instance), fall back to Quick Open via the
85-
// command palette.
82+
// Try the code CLI first; it may not be available on all CI environments.
8683
try {
8784
await VSBrowser.instance.openResources(SAMPLE_FILE);
8885
} catch {
89-
/* ignore – we'll fall through to Quick Open */
86+
/* ignore */
9087
}
91-
92-
let found = await waitForCondition(
88+
await waitForCondition(
9389
async () => {
9490
try {
95-
await new EditorView().openEditor(SAMPLE_FILE_BASENAME);
91+
await editorView.openEditor(SAMPLE_FILE_BASENAME);
9692
return true;
9793
} catch {
9894
return false;
9995
}
10096
},
101-
10_000,
97+
20_000,
10298
500,
10399
);
104100

105-
if (!found) {
106-
// Quick Open fallback: open the command palette, clear the ">"
107-
// prefix so it becomes a file search, type the filename, and
108-
// confirm.
101+
// If the tab still isn't open, fall back to Quick Open (Ctrl+P / Cmd+P).
102+
try {
103+
return (await editorView.openEditor(SAMPLE_FILE_BASENAME)) as TextEditor;
104+
} catch {
105+
const driver = VSBrowser.instance.driver;
106+
const modifier = process.platform === "darwin" ? Key.META : Key.CONTROL;
107+
await driver.actions({ bridge: true }).keyDown(modifier).sendKeys("p").keyUp(modifier).perform();
108+
await driver.sleep(2_000);
109+
const input = await InputBox.create();
110+
await input.setText(SAMPLE_FILE_BASENAME);
111+
await driver.sleep(2_000);
112+
await input.confirm();
109113
await waitForCondition(
110114
async () => {
111115
try {
112-
const prompt = await new Workbench().openCommandPrompt();
113-
await prompt.setText(SAMPLE_FILE_BASENAME);
114-
await VSBrowser.instance.driver.sleep(1_000);
115-
await prompt.confirm();
116-
await VSBrowser.instance.driver.sleep(500);
117-
await new EditorView().openEditor(SAMPLE_FILE_BASENAME);
116+
await editorView.openEditor(SAMPLE_FILE_BASENAME);
118117
return true;
119118
} catch {
120-
try {
121-
await VSBrowser.instance.driver.actions({ bridge: true }).sendKeys(Key.ESCAPE).perform();
122-
} catch {
123-
/* ignore */
124-
}
125119
return false;
126120
}
127121
},
128122
20_000,
129-
2_000,
123+
500,
130124
);
125+
return (await editorView.openEditor(SAMPLE_FILE_BASENAME)) as TextEditor;
131126
}
132-
133-
return (await new EditorView().openEditor(SAMPLE_FILE_BASENAME)) as TextEditor;
134127
}
135128
}
136129

0 commit comments

Comments
 (0)