Skip to content

Commit

Permalink
add stabilization part to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
musienko-maxim committed Nov 11, 2024
1 parent 43ed4e1 commit e783e47
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN

suiteSetup(function (): void {
kubernetesCommandLineToolsExecutor.loginToOcp();
kubernetesCommandLineToolsExecutor.namespace = BASE_TEST_CONSTANTS.TEST_NAMESPACE;
});

suiteSetup('Login', async function (): Promise<void> {
Expand All @@ -57,13 +58,13 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN
? BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + '/dashboard/#/' + 'https://github.com/testsfactory/parentDevfile'
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + '/dashboard/#/' + FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL;
await dashboard.waitPage();
await testWorkspaceUtil.switchOffTrustDialogWithJavaScript();
await browserTabsUtil.navigateTo(factoryUrl);
await createWorkspace.performTrustAuthorPopup();
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
// add 10 sec timeout for waiting for finishing animation of all IDE parts (Welcome parts. bottom widgets. etc.)
// using 10 sec easier than performing of finishing animation a all elements
// using 10 sec easier than performing of finishing animation of all elements
await driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_WAIT_FOR_URL);
await projectAndFileTests.performTrustAuthorDialog();
});
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/utils/workspace/ITestWorkspaceUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ export interface ITestWorkspaceUtil {
* Similar with 'force' deleting
*/
deleteAllWorkspaces(): Promise<void>;

/**
* set user preferences for Che "security.workspace.trust.enabled": false using JS.
*/
switchOffTrustDialogWithJavaScript(): Promise<void>;
}
27 changes: 27 additions & 0 deletions tests/e2e/utils/workspace/TestWorkspaceUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import axios, { AxiosResponse } from 'axios';
import { ITestWorkspaceUtil } from './ITestWorkspaceUtil';
import { ApiUrlResolver } from './ApiUrlResolver';
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
import {string} from "yaml/dist/schema/common/string";

@injectable()
export class TestWorkspaceUtil implements ITestWorkspaceUtil {
Expand Down Expand Up @@ -172,4 +173,30 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
await this.deleteWorkspaceByName(response.data.items[i].metadata.name);
}
}

/**
* set user preferences for Che "security.workspace.trust.enabled": false using JS. in background mode
*/
async switchOffTrustDialogWithJavaScript(): Promise<void> {
const javaScriptExecCode: string = '(async function importData() {\n' +
' const stub = "{\\"vscode-web-db\\":{\\"vscode-userdata-store\\":{\\"/User/settings.json\\":{\\"type\\":\\"Uint8Array\\",\\"value\\":\\"%7B%0A%20%20%20%20%22security.workspace.trust.enabled%22%3A%20false%0A%7D\\"}}}}";\n' +
' for (const [dbName, dbData] of Object.entries(JSON.parse(stub))) {\n' +
' const req = indexedDB.open(dbName);\n' +
' req.onupgradeneeded = ({ target: { result: db } }) =>\n' +
' Object.keys(dbData).forEach((name) => db.createObjectStore(name));\n' +
' await new Promise((r) => (req.onsuccess = r));\n' +
' for (const [storeName, storeData] of Object.entries(dbData)) {\n' +
' const transaction = req.result.transaction(storeName, "readwrite");\n' +
' const store = transaction.objectStore(storeName);\n' +
' store.clear();\n' +
' for (const [key, { type, value }] of Object.entries(storeData)) {\n' +
' const str = decodeURIComponent(value);\n' +
' store.put(type === "String" ? str : new TextEncoder().encode(str), key);\n' +
' }\n' +
' await new Promise((r) => (transaction.oncomplete = r));\n' +
' }\n' +
' }\n' +
'})().then(() => {});'
await this.driverHelper.getDriver().executeScript(javaScriptExecCode);
}
}

0 comments on commit e783e47

Please sign in to comment.