Skip to content

Commit 4787042

Browse files
Stabilize workspace with parent test (#23242)
* stabilize workspace with parent test
1 parent 064b37c commit 4787042

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
2525
import { DriverHelper } from '../../utils/DriverHelper';
2626
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
2727
import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
28-
import { CreateWorkspace } from '../../pageobjects/dashboard/CreateWorkspace';
2928

3029
suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
3130
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
@@ -39,8 +38,6 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN
3938
CLASSES.KubernetesCommandLineToolsExecutor
4039
);
4140
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
42-
const createWorkspace: CreateWorkspace = e2eContainer.get(CLASSES.CreateWorkspace);
43-
4441
let podName: string = '';
4542

4643
suiteSetup(function (): void {
@@ -57,13 +54,13 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN
5754
? BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + '/dashboard/#/' + 'https://github.com/testsfactory/parentDevfile'
5855
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + '/dashboard/#/' + FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL;
5956
await dashboard.waitPage();
57+
await testWorkspaceUtil.switchOffTrustDialogWithJavaScript();
6058
await browserTabsUtil.navigateTo(factoryUrl);
61-
await createWorkspace.performTrustAuthorPopup();
6259
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
6360
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
6461
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
6562
// add 10 sec timeout for waiting for finishing animation of all IDE parts (Welcome parts. bottom widgets. etc.)
66-
// using 10 sec easier than performing of finishing animation a all elements
63+
// using 10 sec easier than performing of finishing animation of all elements
6764
await driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_WAIT_FOR_URL);
6865
await projectAndFileTests.performTrustAuthorDialog();
6966
});

tests/e2e/utils/workspace/ITestWorkspaceUtil.ts

+5
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ export interface ITestWorkspaceUtil {
4040
* Similar with 'force' deleting
4141
*/
4242
deleteAllWorkspaces(): Promise<void>;
43+
44+
/**
45+
* set user preferences for Che "security.workspace.trust.enabled": false using JS.
46+
*/
47+
switchOffTrustDialogWithJavaScript(): Promise<void>;
4348
}

tests/e2e/utils/workspace/TestWorkspaceUtil.ts

+27
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,31 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
172172
await this.deleteWorkspaceByName(response.data.items[i].metadata.name);
173173
}
174174
}
175+
176+
/**
177+
* set user preferences for Che "security.workspace.trust.enabled": false using JS. in background mode
178+
*/
179+
async switchOffTrustDialogWithJavaScript(): Promise<void> {
180+
const javaScriptExecCode: string =
181+
'(async function importData() {\n' +
182+
' 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' +
183+
' for (const [dbName, dbData] of Object.entries(JSON.parse(stub))) {\n' +
184+
' const req = indexedDB.open(dbName);\n' +
185+
' req.onupgradeneeded = ({ target: { result: db } }) =>\n' +
186+
' Object.keys(dbData).forEach((name) => db.createObjectStore(name));\n' +
187+
' await new Promise((r) => (req.onsuccess = r));\n' +
188+
' for (const [storeName, storeData] of Object.entries(dbData)) {\n' +
189+
' const transaction = req.result.transaction(storeName, "readwrite");\n' +
190+
' const store = transaction.objectStore(storeName);\n' +
191+
' store.clear();\n' +
192+
' for (const [key, { type, value }] of Object.entries(storeData)) {\n' +
193+
' const str = decodeURIComponent(value);\n' +
194+
' store.put(type === "String" ? str : new TextEncoder().encode(str), key);\n' +
195+
' }\n' +
196+
' await new Promise((r) => (transaction.oncomplete = r));\n' +
197+
' }\n' +
198+
' }\n' +
199+
'})().then(() => {});';
200+
await this.driverHelper.getDriver().executeScript(javaScriptExecCode);
201+
}
175202
}

0 commit comments

Comments
 (0)