Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
12 changes: 12 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,8 @@ 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_CONFIG_USER_NAME: string;
TS_GIT_CONFIG_USER_EMAIL: string;
TS_SELENIUM_FACTORY_URL(): string;
} = {
/**
Expand Down Expand Up @@ -69,6 +71,16 @@ 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_CONFIG_USER_NAME: process.env.TS_GIT_CONFIG_USER_NAME || 'user',

/**
* git config user email
*/
TS_GIT_CONFIG_USER_EMAIL: process.env.TS_GIT_CONFIG_USER_EMAIL || 'user@user.com',
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved

/**
* full factory URL
*/
Expand Down
32 changes: 32 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,35 @@ export class UserPreferences {
await this.driverHelper.waitAndClick(UserPreferences.GIT_CONFIG_PAGE);
}

async enterGitConfigUserName(userName: string): Promise<void> {
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
Logger.debug(`"${userName}"`);

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

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

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 openSshKeyTab(): Promise<void> {
Logger.debug();

Expand Down
82 changes: 36 additions & 46 deletions tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
InputBox,
Key,
Locators,
ModalDialog,
NewScmView,
SingleScmProvider,
ViewControl,
Expand All @@ -34,12 +33,14 @@ import { DriverHelper } from '../../utils/DriverHelper';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
import { Logger } from '../../utils/Logger';
import { LoginTests } from '../../tests-library/LoginTests';
import { FACTORY_TEST_CONSTANTS, GitProviderType } from '../../constants/FACTORY_TEST_CONSTANTS';
import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { UserPreferences } from '../../pageobjects/dashboard/UserPreferences';
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace';
import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton';
import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';

suite(
`Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository without PAT/OAuth setup ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
Expand All @@ -55,6 +56,7 @@ suite(
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace);
const viewsMoreActionsButton: ViewsMoreActionsButton = e2eContainer.get(CLASSES.ViewsMoreActionsButton);
const userPreferences: UserPreferences = e2eContainer.get(CLASSES.UserPreferences);

let projectSection: ViewSection;
let scmProvider: SingleScmProvider;
Expand All @@ -65,15 +67,23 @@ suite(
const timeToRefresh: number = 1500;
const changesToCommit: string = new Date().getTime().toString();
const fileToChange: string = 'Date.txt';
const pushItemLabel: string = 'Push';
const commitChangesButtonLabel: string = `Commit Changes on "${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}"`;
const refreshButtonLabel: string = 'Refresh';
const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME;
const pushItemLabel: string = 'Push';
let testRepoProjectName: string;
const isPrivateRepo: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO ? 'private' : 'public';

async function setupGitConfig(userName: string, userEmail: string): Promise<void> {
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
await userPreferences.openUserPreferencesPage();
await userPreferences.openGitConfigPage();
await userPreferences.enterGitConfigUserName(userName);
await userPreferences.enterGitConfigUserEmail(userEmail);
await userPreferences.clickOnGitConfigSaveButton();
// await userPreferences.waitGitConfigSaveButtonIsDisabled();// TODO: restore this line after the bug is fixed
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
}

suiteSetup('Login', async function (): Promise<void> {
await loginTests.loginIntoChe();
await setupGitConfig(FACTORY_TEST_CONSTANTS.TS_GIT_CONFIG_USER_NAME, FACTORY_TEST_CONSTANTS.TS_GIT_CONFIG_USER_EMAIL);
});

test(`Navigate to the ${isPrivateRepo} repository factory URL`, async function (): Promise<void> {
Expand Down Expand Up @@ -123,6 +133,7 @@ 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;
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not
.undefined;
});
Expand Down Expand Up @@ -202,60 +213,39 @@ suite(
});

test('Push the changes', async function (): Promise<void> {
await driverHelper.waitVisibility(
webCheCodeLocators.ScmView.actionConstructor(
`Push 1 commits to origin/${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}`
)
);
await driverHelper.waitVisibility(webCheCodeLocators.Notification.action);
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
Logger.debug('scmProvider.openMoreActions');
scmContextMenu = await scmProvider.openMoreActions();
await driverHelper.waitVisibility(webCheCodeLocators.ContextMenu.itemConstructor(pushItemLabel));
Logger.debug(`scmContextMenu.select: "${pushItemLabel}"`);
await scmContextMenu.select(pushItemLabel);
});

if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.GITHUB) {
test('Decline GitHub Extension', async function (): Promise<void> {
await driverHelper.waitVisibility(webCheCodeLocators.Dialog.details);
const gitHaExtensionDialog: ModalDialog = new ModalDialog();
await gitHaExtensionDialog.pushButton('Cancel');
});
}
// wait for user name input to appear and create InputBox with waiting
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
Logger.debug('Waiting for username input to appear');
const inputUsername: InputBox = await InputBox.create(TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT);
Logger.debug(`Setting username: "${OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_USERNAME}"`);
await inputUsername.setText(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_USERNAME);
await inputUsername.confirm();

test('Insert git credentials which were asked after push', async function (): Promise<void> {
try {
await driverHelper.waitVisibility(webCheCodeLocators.InputBox.message);
} catch (e) {
Logger.info(`Workspace did not ask credentials before push - ${e};
Known issue for github.com - https://issues.redhat.com/browse/CRW-4066, please check if not other git provider. `);
expect(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER).eqls(GitProviderType.GITHUB);
}
const input: InputBox = new InputBox();
await input.setText(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_USERNAME);
await input.confirm();
await driverHelper.wait(timeToRefresh);
await input.setText(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_PASSWORD);
await input.confirm();
await driverHelper.wait(timeToRefresh);
// wait for password input to appear after username confirmation
Logger.debug('Waiting for password input to appear');
const inputPassword: InputBox = await InputBox.create(TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT);
Logger.debug('Setting password');
await inputPassword.setText(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_PASSWORD);
await inputPassword.confirm();
});

test('Check if the changes were pushed', async function (): Promise<void> {
try {
Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`);
await driverHelper.waitAndClick(webCheCodeLocators.ScmView.actionConstructor(refreshButtonLabel));
} catch (e) {
Logger.info(
'Check you use correct credentials.' +
'For bitbucket.org ensure you use an app password: https://support.atlassian.com/bitbucket-cloud/docs/using-app-passwords/;' +
'For github.com - personal access token instead of password.'
);
}
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more);
await driverHelper.wait(timeToRefresh);
Logger.debug(`wait and click on: "${refreshButtonLabel}"`);
await driverHelper.waitAndClick(webCheCodeLocators.ScmView.actionConstructor(refreshButtonLabel));
const isCommitButtonDisabled: string = await driverHelper.waitAndGetElementAttribute(
webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel),
webCheCodeLocators.Notification.action,
'aria-disabled'
);
expect(isCommitButtonDisabled).to.be.true;
Comment thread
dmytro-ndp marked this conversation as resolved.
Resolved
expect(isCommitButtonDisabled).to.equal('true');
});
}

Expand Down
Loading