Skip to content

Commit

Permalink
Support trust author popup in E2E tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dmytro Nochevnov <[email protected]>
  • Loading branch information
dmytro-ndp committed Aug 14, 2024
1 parent 245bb11 commit 5029254
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../utils/
import { ShellExecutor } from '../utils/ShellExecutor';
import { UserPreferences } from '../pageobjects/dashboard/UserPreferences';
import { WebTerminalPage } from '../pageobjects/webterminal/WebTerminalPage';
import { TrustAuthorPopup } from '../pageobjects/dashboard/TrustAuthorPopup';

const e2eContainer: Container = new Container({ defaultScope: 'Transient', skipBaseClassChecks: true });

Expand Down Expand Up @@ -90,6 +91,8 @@ e2eContainer.bind<WebTerminalPage>(CLASSES.WebTerminalPage).to(WebTerminalPage);
e2eContainer.bind<UserPreferences>(CLASSES.UserPreferences).to(UserPreferences);
e2eContainer.bind<Generator>(EXTERNAL_CLASSES.Generator).to(Generator);
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
e2eContainer.bind<TrustAuthorPopup>(CLASSES.TrustAuthorPopup).to(TrustAuthorPopup);

if (BASE_TEST_CONSTANTS.TS_PLATFORM === Platform.OPENSHIFT) {
if (OAUTH_CONSTANTS.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH) {
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/configs/inversify.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const CLASSES: any = {
ContainerTerminal: 'ContainerTerminal',
UserPreferences: 'UserPreferences',
WebTerminalPage: 'WebTerminalPage',
RevokeOauthPage: 'RevokeOauthPage'
RevokeOauthPage: 'RevokeOauthPage',
TrustAuthorPopup: 'TrustAuthorPopup'
};

const EXTERNAL_CLASSES: any = {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/constants/CHROME_DRIVER_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ export const CHROME_DRIVER_CONSTANTS: {
/**
* run browser with proxy settings
*/
TS_SELENIUM_PROXY_SERVER: process.env.TS_SELENIUM_PROXY_SERVER || '',
TS_SELENIUM_PROXY_SERVER: process.env.TS_SELENIUM_PROXY_SERVER || ''
};
11 changes: 6 additions & 5 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ export * from './configs/mocharc';
export * from './driver/ChromeDriver';
export * from './driver/IDriver';
export * from './utils/BrowserTabsUtil';
export * from './utils/DevWorkspaceConfigurationHelper';
export * from './utils/DevfilesRegistryHelper';
export * from './utils/DevWorkspaceConfigurationHelper';
export * from './utils/DriverHelper';
export * from './utils/IContextParams';
export * from './utils/IKubernetesCommandLineToolsExecutor';
export * from './utils/KubernetesCommandLineToolsExecutor';
export * from './utils/Logger';
export * from './utils/ScreenCatcher';
export * from './utils/ShellExecutor';
export * from './utils/StringUtil';
export * from './utils/request-handlers/CheApiRequestHandler';
export * from './utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler';
export * from './utils/request-handlers/headers/IAuthorizationHeaderHandler';
export * from './utils/ScreenCatcher';
export * from './utils/ShellExecutor';
export * from './utils/StringUtil';
export * from './utils/workspace/ApiUrlResolver';
export * from './utils/workspace/ITestWorkspaceUtil';
export * from './utils/workspace/TestWorkspaceUtil';
export * from './utils/workspace/WorkspaceStatus';
export * from './pageobjects/dashboard/CreateWorkspace';
export * from './pageobjects/dashboard/Dashboard';
export * from './pageobjects/dashboard/TrustAuthorPopup';
export * from './pageobjects/dashboard/UserPreferences';
export * from './pageobjects/dashboard/Workspaces';
export * from './pageobjects/dashboard/workspace-details/WorkspaceDetails';
export * from './pageobjects/dashboard/Workspaces';
export * from './pageobjects/git-providers/OauthPage';
export * from './pageobjects/ide/CheCodeLocatorLoader';
export * from './pageobjects/login/interfaces/ICheLoginPage';
Expand Down
18 changes: 17 additions & 1 deletion tests/e2e/pageobjects/dashboard/CreateWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { By, Key } from 'selenium-webdriver';
import { Logger } from '../../utils/Logger';
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { TrustAuthorPopup } from './TrustAuthorPopup';

@injectable()
export class CreateWorkspace {
Expand All @@ -26,7 +27,10 @@ export class CreateWorkspace {

constructor(
@inject(CLASSES.DriverHelper)
private readonly driverHelper: DriverHelper
private readonly driverHelper: DriverHelper,

@inject(CLASSES.TrustAuthorPopup)
private readonly trustAuthorPopup: TrustAuthorPopup
) {}

async waitTitleContains(expectedText: string, timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Expand Down Expand Up @@ -84,6 +88,8 @@ export class CreateWorkspace {
}

await this.driverHelper.waitAndClick(CreateWorkspace.CREATE_AND_OPEN_BUTTON, timeout);

await this.performTrustAuthorPopup();
}

async clickOnEditorsDropdownListButton(sampleName: string, timeout: number): Promise<void> {
Expand All @@ -93,6 +99,16 @@ export class CreateWorkspace {
await this.driverHelper.waitAndClick(editorDropdownListLocator, timeout);
}

async performTrustAuthorPopup(): Promise<void> {
Logger.debug();

try {
await this.trustAuthorPopup.clickContinue();
} catch (e) {
Logger.info('Trust author popup was not shown');
}
}

private getEditorsDropdownListLocator(sampleName: string): By {
return By.xpath(`//div[text()=\'${sampleName}\']//parent::article//button`);
}
Expand Down

0 comments on commit 5029254

Please sign in to comment.