Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up and update 'Factory' E2E flow components #22623

Merged
merged 10 commits into from
Nov 2, 2023
4 changes: 3 additions & 1 deletion tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { BASE_TEST_CONSTANTS } from './BASE_TEST_CONSTANTS';
export enum GitProviderType {
GITHUB = 'github',
GITLAB = 'gitlab',
BITBUCKET = 'bitbucket',
BITBUCKET_SERVER_OAUTH1 = 'bitbucket-server-oauth1',
BITBUCKET_SERVER_OAUTH2 = 'bitbucket-server-oauth2',
BITBUCKET_CLOUD_OAUTH2 = 'bitbucket-org',
AZURE_DEVOPS = 'azure-devops'
}

Expand Down
27 changes: 24 additions & 3 deletions tests/e2e/pageobjects/git-providers/OauthPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class OauthPage {
private readonly driverHelper: DriverHelper
) {
switch (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER) {
case GitProviderType.BITBUCKET:
case GitProviderType.BITBUCKET_SERVER_OAUTH1:
{
OauthPage.LOGIN_FORM = By.id('j_username');
OauthPage.PASSWORD_FORM = By.id('j_password');
Expand All @@ -39,6 +39,24 @@ export class OauthPage {
OauthPage.DENY_ACCESS_BUTTON = By.id('deny');
}
break;
case GitProviderType.BITBUCKET_SERVER_OAUTH2:
{
OauthPage.LOGIN_FORM = By.id('j_username');
OauthPage.PASSWORD_FORM = By.id('j_password');
OauthPage.APPROVE_BUTTON = By.xpath('//span[text()="Allow"]');
OauthPage.SUBMIT_BUTTON = By.id('submit');
OauthPage.DENY_ACCESS_BUTTON = By.xpath('//span[text()="Deny"]');
}
break;
case GitProviderType.BITBUCKET_CLOUD_OAUTH2:
{
OauthPage.LOGIN_FORM = By.id('username');
OauthPage.PASSWORD_FORM = By.id('password');
OauthPage.SUBMIT_BUTTON = By.id('login-submit');
OauthPage.APPROVE_BUTTON = By.xpath('//button[@value="approve"]');
OauthPage.DENY_ACCESS_BUTTON = By.xpath('//button[@value="deny"]');
}
break;
case GitProviderType.GITLAB:
{
OauthPage.LOGIN_FORM = By.id('user_login');
Expand Down Expand Up @@ -69,7 +87,7 @@ export class OauthPage {
break;
default: {
throw new Error(
`Invalid git provider. The value should be ${GitProviderType.GITHUB}, ${GitProviderType.GITLAB}, ${GitProviderType.AZURE_DEVOPS} or ${GitProviderType.BITBUCKET}`
`Invalid git provider. The value should be ${GitProviderType.GITHUB}, ${GitProviderType.GITLAB}, ${GitProviderType.AZURE_DEVOPS}, ${GitProviderType.BITBUCKET_SERVER_OAUTH1}, ${GitProviderType.BITBUCKET_SERVER_OAUTH2} or ${GitProviderType.BITBUCKET_CLOUD_OAUTH2}`
);
}
}
Expand Down Expand Up @@ -140,7 +158,10 @@ export class OauthPage {

await this.waitLoginPage();
await this.enterUserName(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_USERNAME);
if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.AZURE_DEVOPS) {
if (
FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.AZURE_DEVOPS ||
FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.BITBUCKET_CLOUD_OAUTH2
) {
await this.clickOnSubmitButton();
}
await this.enterPassword(OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_PASSWORD);
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ export class CheCodeLocatorLoader extends LocatorLoader {
button: By.xpath('//div[@class="monaco-dialog-box"]//a[@class="monaco-button monaco-text-button"]')
},
ScmView: {
actionConstructor: (title: string): By => By.xpath(`.//a[@title="${title}"]`)
actionConstructor: (title: string): By => By.xpath(`.//a[@title='${title}']`)
}
},
extras: {
ExtensionsViewSection: {
requireReloadButton: By.xpath('//a[text()="Reload Required"]')
},
TreeItem: {
projectFolderItem: By.xpath('.//div[contains(@class, "rootfolder-icon projects-name-dir")]')
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ suite(
});

if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) {
test(`Check that workspace cannot be created without OAuth for ${isPrivateRepo} repo`, async function (): Promise<void> {
test(`Check that workspace cannot be created without PAT/OAuth for ${isPrivateRepo} repo`, async function (): Promise<void> {
await dashboard.waitLoader();
const loaderAlert: string = await dashboard.getLoaderAlert();
expect(loaderAlert).to.contain('Cause: Could not reach devfile at');
Expand Down
55 changes: 27 additions & 28 deletions tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
EditorView,
InputBox,
Locators,
ModalDialog,
NewScmView,
SingleScmProvider,
TextEditor,
Expand Down Expand Up @@ -57,6 +56,7 @@ suite(

let projectSection: ViewSection;
let scmProvider: SingleScmProvider;
let rest: SingleScmProvider[];
let scmContextMenu: ContextMenu;

// test specific data
Expand All @@ -78,13 +78,11 @@ suite(
await browserTabsUtil.navigateTo(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_URL());
});

if (OAUTH_CONSTANTS.TS_SELENIUM_GIT_PROVIDER_OAUTH) {
test(`Authorize with a ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function (): Promise<void> {
await oauthPage.login();
await oauthPage.waitOauthPage();
await oauthPage.denyAccess();
});
}
test(`Authorize with a ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function (): Promise<void> {
await oauthPage.login();
await oauthPage.waitOauthPage();
await oauthPage.denyAccess();
});

test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
Expand All @@ -102,29 +100,31 @@ suite(
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
});

test('Check if a project folder has been created', async function (): Promise<void> {
testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported').not
.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});

if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) {
test('Check that project can not be cloned', async function (): Promise<void> {
await driverHelper.waitVisibility(webCheCodeLocators.Dialog.message);
const workspaceDoesNotExistDialog: ModalDialog = new ModalDialog();
const message: string = await workspaceDoesNotExistDialog.getMessage();
expect(message).contains('space does not exist');
test('Check that a project folder has not been cloned', async function (): Promise<void> {
testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL);
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.multiProviderItem);
await projectAndFileTests.performTrustAuthorDialog();
const isProjectFolderUnable: string = await driverHelper.waitAndGetElementAttribute(
(webCheCodeLocators.TreeItem as any).projectFolderItem,
'aria-label'
);
expect(isProjectFolderUnable).to.contain(
'/projects/' + testRepoProjectName + ' • Unable to resolve workspace folder (Unable to resolve nonexistent file'
);
});
} else {
test('Check if a project folder has been created', async function (): Promise<void> {
testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported')
.not.undefined;
});

test('Check that project files were not imported', async function (): Promise<void> {
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were found').to.be.undefined;
test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});
} else {

test('Check if the project files were imported', async function (): Promise<void> {
expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not
.undefined;
Expand All @@ -148,7 +148,6 @@ suite(
await sourceControl.openView();
const scmView: NewScmView = new NewScmView();
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.inputField);
let rest: SingleScmProvider[];
[scmProvider, ...rest] = await scmView.getProviders();
Logger.debug(`scmView.getProviders: "${JSON.stringify(scmProvider)}, ${rest}"`);
});
Expand Down
6 changes: 0 additions & 6 deletions tests/e2e/tests-library/ProjectAndFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ export class ProjectAndFileTests {
Logger.debug();
// sometimes the trust dialog does not appear at first time, for avoiding this problem we send click event for activating
const workbench: Workbench = new Workbench();
await workbench.click();

await this.driverHelper.waitAndClick(
this.cheCodeLocatorLoader.webCheCodeLocators.WelcomeContent.button,
TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT
);

try {
await workbench.click();
Expand Down
Loading