Skip to content

Commit cc4286d

Browse files
authored
Make plugin scaffolding testing more resilient (#2102)
1 parent f51805b commit cc4286d

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

test/ui/contentCreatorUiTest.ts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ describe("Content Creator UI Tests", function () {
300300
}
301301

302302
// Using execFile for safer execution without shell, ensuring SonarCloud compliance.
303-
function scaffoldCollection(collectionPath: string) {
303+
async function scaffoldCollection(collectionPath: string): Promise<void> {
304304
const safePath = path.resolve(collectionPath);
305305

306306
const ansibleCreatorPath = findExecutable("ansible-creator");
@@ -346,16 +346,38 @@ describe("Content Creator UI Tests", function () {
346346
Lookup: 2,
347347
} as { [key: string]: number };
348348

349+
console.log(`Executing command: ${command}`);
349350
await workbenchExecuteCommand(command);
350-
await waitForCondition({
351-
condition: async () => {
352-
return await new EditorView().openEditor(editorTitle);
353-
},
354-
message: `Timed out waiting for ${editorTitle} to open`,
355-
});
351+
352+
console.log(`Waiting for editor "${editorTitle}" to open...`);
353+
354+
try {
355+
await waitForCondition({
356+
condition: async () => {
357+
try {
358+
const result = await new EditorView().openEditor(editorTitle);
359+
console.log(`Successfully opened editor with default parameters`);
360+
return result;
361+
} catch {
362+
return false;
363+
}
364+
},
365+
message: `Timed out waiting for ${editorTitle} to open.`,
366+
timeout: 20000, // Longer timeout
367+
});
368+
} catch (error) {
369+
console.log(
370+
`Default approach failed after timeout: ${(error as Error).message}`,
371+
);
372+
}
373+
374+
console.log(
375+
`Editor "${editorTitle}" opened successfully, getting webview...`,
376+
);
356377
const webview = await getWebviewByLocator(
357378
By.xpath("//vscode-textfield[@id='path-url']"),
358379
);
380+
console.log(`Webview obtained successfully for "${editorTitle}"`);
359381

360382
const collectionPathUrlTextField = await webview.findWebElement(
361383
By.xpath("//vscode-textfield[@id='path-url']"),
@@ -416,7 +438,7 @@ describe("Content Creator UI Tests", function () {
416438
).to.be.true;
417439
await createButton.click();
418440
if (verifyPath) {
419-
scaffoldCollection(collectionPath);
441+
await scaffoldCollection(collectionPath);
420442
await createButton.click();
421443
// This sleep is hard to get rid of because scaffold collection takes time
422444
// need to look at ways to determine when the collection is ready

0 commit comments

Comments
 (0)