Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retry after waiting for workbench restore #195300

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 26 additions & 8 deletions test/automation/src/quickaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,33 +174,51 @@ export class QuickAccess {
const keepOpen = options?.keepOpen;
const exactLabelMatch = options?.exactLabelMatch;

const openCommandPalletteAndTypeCommand = async (): Promise<string> => {
const openCommandPalletteAndTypeCommand = async (): Promise<boolean> => {
// open commands picker
await this.openQuickAccessWithRetry(QuickAccessKind.Commands, `>${commandId}`);

// wait for best choice to be focused
await this.quickInput.waitForQuickInputElementFocused();

// Retry for as long as the command not found
return await this.quickInput.waitForQuickInputElementText();
const text = await this.quickInput.waitForQuickInputElementText();

if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) {
return false;
}

return true;
};

let text = await openCommandPalletteAndTypeCommand();
let hasCommandFound = await openCommandPalletteAndTypeCommand();

if (!hasCommandFound) {

if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) {
this.code.logger.log(`QuickAccess: No matching commands, will retry...`);
await this.quickInput.closeQuickInput();

// Wait for workbench to be restored
await this.code.whenWorkbenchRestored();

// Retry after workbench is restored
text = await openCommandPalletteAndTypeCommand();
if (text === 'No matching commands' || (exactLabelMatch && text !== commandId)) {
throw new Error(`Command: ${commandId} Not found`);
let retries = 0;
while (++retries < 5) {
hasCommandFound = await openCommandPalletteAndTypeCommand();
if (hasCommandFound) {
break;
} else {
this.code.logger.log(`QuickAccess: No matching commands, will retry...`);
await this.quickInput.closeQuickInput();
await this.code.wait(1000);
}
}

if (!hasCommandFound) {
throw new Error(`QuickAccess.runCommand(commandId: ${commandId}) failed to find command.`);
}
}


// wait and click on best choice
await this.quickInput.selectQuickInputElement(0, keepOpen);
}
Expand Down