Skip to content

Commit

Permalink
remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
shwet2407 committed Oct 3, 2024
1 parent d08d602 commit d4c0b97
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
31 changes: 1 addition & 30 deletions packages/flex-plugin-e2e-tests/src/utils/pages/view/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,7 @@ export abstract class Base {
*/
protected async goto({ baseUrl, path }: { baseUrl: string; path?: string }): Promise<void> {
const fullPath = path ? `${baseUrl}/${path}` : baseUrl;
let attempts = 0;
const maxAttempts = 3;

while (attempts < maxAttempts) {
try {
await this.page.goto(fullPath, {
waitUntil: 'load',
timeout: Base.DEFAULT_PAGE_LOAD_TIMEOUT,
});

logger.info('Page loaded successfully');
return; // Exit the function if the page loaded successfully
} catch (error) {
// eslint-disable-next-line no-plusplus
attempts++;
if (error instanceof Error) {
logger.error(`Attempt ${attempts} failed. Error: ${error.message}`);
} else {
logger.error(`Attempt ${attempts} failed. Unknown error: ${error}`);
}

if (attempts < maxAttempts) {
logger.info(`Retrying... Reloading the page (Attempt ${attempts})`);
await this.page.reload({ waitUntil: 'load' });
} else {
logger.error('Maximum attempts reached. Failed to load the page.');
throw new Error(`Failed to load page after ${maxAttempts} attempts.`);
}
}
}
await this.page.goto(fullPath, { waitUntil: 'load', timeout: Base.DEFAULT_PAGE_LOAD_TIMEOUT });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/flex-plugin-e2e-tests/src/utils/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const retryOnError = async (
await method(attempts === 1); // Attempt the main operation
break; // If operation succeeds, exit the loop
} catch (error) {
logger.info('Shwet', error);
logger.info('Error occured', error);
if (attempts === maxRetries) {
await onError(error); // Handle error if all retries fail
await onFinally(); // cleanup
Expand Down

0 comments on commit d4c0b97

Please sign in to comment.