Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions tests/e2e/specs/restart-tests/RestartFromLocalDevfile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { DriverHelper } from '../../utils/DriverHelper';
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
import { RestartWorkspaceDialog } from '../../pageobjects/ide/RestartWorkspaceDialog';
import { By } from 'selenium-webdriver';
import { By, error } from 'selenium-webdriver';
import { registerRunningWorkspace } from '../MochaHooks';

suite(`Test case with empty workspace (per-user storage) ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
Expand Down Expand Up @@ -112,8 +112,28 @@ suite(`Test case with empty workspace (per-user storage) ${BASE_TEST_CONSTANTS.T

test('Restart workspace from local devfile with bad image', async function (): Promise<void> {
await restartWorkspaceDialog.restartFromLocalDevfile(projectName);

Logger.info('Waiting for "Restart Workspace" confirmation popup');
await restartWorkspaceDialog.confirmRestartWorkspace();
try {
await restartWorkspaceDialog.confirmRestartWorkspace();
} catch (err) {
if (err instanceof error.UnexpectedAlertOpenError) {
let alertText: string = '';
try {
alertText = await driverHelper.getDriver().switchTo().alert().getText();
} catch (alertErr) {
// alert already auto-dismissed by Chrome
}
if (alertText === '') {
Logger.info('UnexpectedAlertOpenError with empty text caught, retrying confirmRestartWorkspace');
await restartWorkspaceDialog.confirmRestartWorkspace();
} else {
throw new error.UnexpectedAlertOpenError(`unexpected alert with text: "${alertText}"`);
}
} else {
throw err;
}
}
});

test('Wait for workspace start failure and restart', async function (): Promise<void> {
Expand Down Expand Up @@ -281,8 +301,28 @@ suite(`Test case with pvc-fail workspace (bad image restart) ${BASE_TEST_CONSTAN

test('Restart workspace from local devfile with bad image', async function (): Promise<void> {
await restartWorkspaceDialog.restartFromLocalDevfile(projectName);

Logger.info('Waiting for "Restart Workspace" confirmation popup');
await restartWorkspaceDialog.confirmRestartWorkspace();
try {
await restartWorkspaceDialog.confirmRestartWorkspace();
} catch (err) {
if (err instanceof error.UnexpectedAlertOpenError) {
let alertText: string = '';
try {
alertText = await driverHelper.getDriver().switchTo().alert().getText();
} catch (alertErr) {
// alert already auto-dismissed by Chrome
}
if (alertText === '') {
Logger.info('UnexpectedAlertOpenError with empty text caught, retrying confirmRestartWorkspace');
await restartWorkspaceDialog.confirmRestartWorkspace();
} else {
throw new error.UnexpectedAlertOpenError(`unexpected alert with text: "${alertText}"`);
}
} else {
throw err;
}
}
});

test('Wait for workspace start failure and restart with default devfile', async function (): Promise<void> {
Expand Down
Loading