Skip to content

Commit

Permalink
Fix 'RefusedOAuthFactory' for private factory flow
Browse files Browse the repository at this point in the history
  • Loading branch information
artaleks9 committed Oct 23, 2023
1 parent 6f14637 commit 9f72a20
Showing 1 changed file with 27 additions and 28 deletions.
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 @@ -53,6 +52,7 @@ suite(

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

// test specific data
Expand All @@ -72,13 +72,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 @@ -96,29 +94,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 @@ -142,7 +142,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

0 comments on commit 9f72a20

Please sign in to comment.