Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
4 changes: 4 additions & 0 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import { CommandPalette } from '../pageobjects/ide/CommandPalette';
import { ExtensionsView } from '../pageobjects/ide/ExtensionsView';
import { ExplorerView } from '../pageobjects/ide/ExplorerView';
import { NotificationHandler } from '../pageobjects/ide/NotificationHandler';
import { SourceControlModule } from '../pageobjects/ide/SourceControlModule';
import { DialogBoxGitHubExtension } from '../pageobjects/ide/DialogBoxGitHubExtension';

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

Expand Down Expand Up @@ -105,6 +107,8 @@ e2eContainer.bind<CommandPalette>(CLASSES.CommandPalette).to(CommandPalette);
e2eContainer.bind<ExtensionsView>(CLASSES.ExtensionsView).to(ExtensionsView);
e2eContainer.bind<ExplorerView>(CLASSES.ExplorerView).to(ExplorerView);
e2eContainer.bind<NotificationHandler>(CLASSES.NotificationHandler).to(NotificationHandler);
e2eContainer.bind<SourceControlModule>(CLASSES.SourceControlModule).to(SourceControlModule);
e2eContainer.bind<DialogBoxGitHubExtension>(CLASSES.DialogBoxGitHubExtension).to(DialogBoxGitHubExtension);

if (BASE_TEST_CONSTANTS.TS_PLATFORM === Platform.OPENSHIFT) {
if (OAUTH_CONSTANTS.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH) {
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/configs/inversify.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ const CLASSES: any = {
CommandPalette: 'CommandPalette',
ExtensionsView: 'ExtensionsView',
ExplorerView: 'ExplorerView',
NotificationHandler: 'NotificationHandler'
NotificationHandler: 'NotificationHandler',
SourceControlModule: 'SourceControlModule',
DialogBoxGitHubExtension: 'DialogBoxGitHubExtension'
};

const EXTERNAL_CLASSES: any = {
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const FACTORY_TEST_CONSTANTS: {
TS_SELENIUM_FACTORY_GIT_REPO_BRANCH: string;
TS_SELENIUM_SSH_PRIVATE_KEY_PATH: string;
TS_SELENIUM_SSH_PUBLIC_KEY_PATH: string;
TS_GIT_COMMIT_AUTHOR_NAME: string;
TS_GIT_COMMIT_AUTHOR_EMAIL: string;
TS_GIT_PERSONAL_ACCESS_TOKEN: string;
TS_SELENIUM_FACTORY_URL(): string;
} = {
/**
Expand Down Expand Up @@ -69,6 +72,21 @@ export const FACTORY_TEST_CONSTANTS: {
*/
TS_SELENIUM_SSH_PUBLIC_KEY_PATH: process.env.TS_SELENIUM_SSH_PUBLIC_KEY_PATH || 'resources/factory/pub-k.txt',

/**
* git config user name
*/
TS_GIT_COMMIT_AUTHOR_NAME: process.env.TS_GIT_CONFIG_USER_NAME || 'user',

/**
* git config user email
*/
TS_GIT_COMMIT_AUTHOR_EMAIL: process.env.TS_GIT_CONFIG_USER_EMAIL || 'user@user.com',

/**
* personal access token of git provider (or api token if Bitbucket.org)
*/
TS_GIT_PERSONAL_ACCESS_TOKEN: process.env.TS_GIT_PERSONAL_ACCESS_TOKEN || '',

/**
* full factory URL
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ export * from './pageobjects/dashboard/Workspaces';
export * from './pageobjects/git-providers/OauthPage';
export * from './pageobjects/ide/CheCodeLocatorLoader';
export * from './pageobjects/ide/CommandPalette';
export * from './pageobjects/ide/DialogBoxGitHubExtension';
export * from './pageobjects/ide/ExplorerView';
export * from './pageobjects/ide/ExtensionsView';
export * from './pageobjects/ide/NotificationHandler';
export * from './pageobjects/ide/RestrictedModeButton';
export * from './pageobjects/ide/SourceControlModule';
export * from './pageobjects/ide/ViewsMoreActionsButton';
export * from './pageobjects/login/interfaces/ICheLoginPage';
export * from './pageobjects/login/interfaces/IOcpLoginPage';
Expand Down
36 changes: 36 additions & 0 deletions tests/e2e/pageobjects/dashboard/UserPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export class UserPreferences {
private static readonly ADD_NEW_PAT_BUTTON: By = By.xpath('//button[text()="Add Personal Access Token"]');

private static readonly GIT_CONFIG_PAGE: By = By.xpath('//button[text()="Gitconfig"]');
private static readonly GIT_CONFIG_USER_NAME: By = By.id('gitconfig-user-name');
private static readonly GIT_CONFIG_USER_EMAIL: By = By.id('gitconfig-user-email');
private static readonly GIT_CONFIG_SAVE_BUTTON: By = By.css('[data-testid="button-save"]');

private static readonly SSH_KEY_TAB: By = By.xpath('//button[text()="SSH Keys"]');
private static readonly ADD_NEW_SSH_KEY_BUTTON: By = By.xpath('//button[text()="Add SSH Key"]');
Expand Down Expand Up @@ -123,6 +126,39 @@ export class UserPreferences {
await this.driverHelper.waitAndClick(UserPreferences.GIT_CONFIG_PAGE);
}

async enterGitConfigUsernameAndEmail(userName: string, userEmail: string): Promise<void> {
Logger.debug(`"${userName}"`);
Logger.debug(`"${userEmail}"`);

await this.driverHelper.enterValue(UserPreferences.GIT_CONFIG_USER_NAME, userName);
await this.driverHelper.enterValue(UserPreferences.GIT_CONFIG_USER_EMAIL, userEmail);
}

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

await this.driverHelper.waitAndClick(UserPreferences.GIT_CONFIG_SAVE_BUTTON);
}

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

await this.driverHelper.waitAttributeValue(
UserPreferences.GIT_CONFIG_SAVE_BUTTON,
'aria-disabled',
'true',
TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
);
}

async setupGitConfig(userName: string, userEmail: string): Promise<void> {
await this.openUserPreferencesPage();
await this.openGitConfigPage();
await this.enterGitConfigUsernameAndEmail(userName, userEmail);
await this.clickOnGitConfigSaveButton();
// await userPreferences.waitGitConfigSaveButtonIsDisabled();// TODO: restore line after fix https://github.com/eclipse-che/che/issues/23625
}

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

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/pageobjects/git-providers/OauthPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class OauthPage {
{
OauthPage.LOGIN_FORM = By.id('login_field');
OauthPage.PASSWORD_FORM = By.id('password');
OauthPage.APPROVE_BUTTON = By.xpath('//*[@id="js-oauth-authorize-btn"]');
OauthPage.APPROVE_BUTTON = By.xpath('//button[contains(., "Authorize")]');
OauthPage.SUBMIT_BUTTON = By.xpath('//*[@value="Sign in"]');
OauthPage.DENY_ACCESS_BUTTON = By.xpath('//button[contains(., "Cancel")]');
}
Expand Down
56 changes: 56 additions & 0 deletions tests/e2e/pageobjects/ide/DialogBoxGitHubExtension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/** *******************************************************************
* copyright (c) 2025 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { CLASSES } from '../../configs/inversify.types';
import { DriverHelper } from '../../utils/DriverHelper';
import { Logger } from '../../utils/Logger';
import { By, ModalDialog } from 'monaco-page-objects';
import { CheCodeLocatorLoader } from './CheCodeLocatorLoader';

@injectable()
export class DialogBoxGitHubExtension {
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
private static readonly DIALOG_BOX_GITHUB_EXTENSION_LOCATOR: By = By.xpath(
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
'//div[@class="dialog-message-detail" and contains(., "The extension \'GitHub\' wants to sign in using GitHub.")]'
);

constructor(
@inject(CLASSES.DriverHelper)
private readonly driverHelper: DriverHelper,
@inject(CLASSES.CheCodeLocatorLoader)
private readonly cheCodeLocatorLoader: CheCodeLocatorLoader
) {}

/**
* check if the dialog box with the message about the GitHub extension is visible.
* @returns Promise resolving to boolean.
*/
async isDialogBoxGitHubExtensionVisible(): Promise<boolean> {
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
Logger.debug();

const dialogBoxGitHubExtension: boolean = await this.driverHelper.waitVisibilityBoolean(
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
DialogBoxGitHubExtension.DIALOG_BOX_GITHUB_EXTENSION_LOCATOR
);

return dialogBoxGitHubExtension;
}

/**
* close the dialog box with the message about the GitHub extension.
*/
async closeDialogBoxGitHubExtension(): Promise<void> {
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
Logger.debug();

const modalDialog: ModalDialog = new ModalDialog();
await modalDialog.close();
await this.driverHelper.waitDisappearance(this.cheCodeLocatorLoader.webCheCodeLocators.Dialog.constructor);
Logger.debug('Dialog box with the message about the GitHub extension closed');
}
}
35 changes: 35 additions & 0 deletions tests/e2e/pageobjects/ide/SourceControlModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** *******************************************************************
* copyright (c) 2025 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { inject, injectable } from 'inversify';
import 'reflect-metadata';
import { CLASSES } from '../../configs/inversify.types';
import { DriverHelper } from '../../utils/DriverHelper';
import { Logger } from '../../utils/Logger';
import { Key } from 'selenium-webdriver';

@injectable()
export class SourceControlModule {
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
constructor(
@inject(CLASSES.DriverHelper)
readonly driverHelper: DriverHelper
) {}

/**
* type the commit message and press Ctrl+Enter to commit the changes.
* @param textCommit Text to commit.
*/
async typeCommitMessage(textCommit: string): Promise<void> {
Logger.debug(`Type commit text: "Commit ${textCommit}"`);

await this.driverHelper.getDriver().actions().sendKeys(textCommit).perform();
Logger.debug('Press Enter to commit the changes');
await this.driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys(Key.ENTER).keyUp(Key.CONTROL).perform();
}
}
15 changes: 8 additions & 7 deletions tests/e2e/specs/factory/Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace';
import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton';
import { SourceControlModule } from '../../pageobjects/ide/SourceControlModule';

suite(
`Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
Expand All @@ -47,6 +48,7 @@ suite(
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace);
const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton);
const sourceControlModule: SourceControlModule = e2eContainer.get(CLASSES.SourceControlModule);

let projectSection: ViewSection;
let scmProvider: SingleScmProvider;
Expand Down Expand Up @@ -103,8 +105,10 @@ suite(
});

test('Check if the project files were imported', async function (): Promise<void> {
const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME;
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not.undefined;
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME),
'Project files were not imported'
).not.undefined;
});

test('Make changes to the file', async function (): Promise<void> {
Expand Down Expand Up @@ -166,10 +170,7 @@ suite(
.getDriver()
.findElement((webCheCodeLocators.ScmView as any).scmEditor)
.click();
Logger.debug(`Type commit text: "Commit ${changesToCommit}"`);
await driverHelper.getDriver().actions().sendKeys(changesToCommit).perform();
Logger.debug('Press Enter to commit the changes');
await driverHelper.getDriver().actions().keyDown(Key.CONTROL).sendKeys(Key.ENTER).keyUp(Key.CONTROL).perform();
await sourceControlModule.typeCommitMessage(changesToCommit);
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
await driverHelper.wait(timeToRefresh);
Logger.debug(`wait and click on: "${refreshButtonLabel}"`);
Expand Down Expand Up @@ -200,7 +201,7 @@ suite(
webCheCodeLocators.Notification.action,
'aria-disabled'
);
expect(isCommitButtonDisabled).to.equal('true');
expect(isCommitButtonDisabled === 'true').to.be.true;
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
});

suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
Expand Down
Loading