@theia-extension-tester/che-browser
Version:
Eclipse Che browser helper implementation.
71 lines • 3.67 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheTheiaBrowser = void 0;
const theia_browser_1 = require("@theia-extension-tester/theia-browser");
const theia_element_1 = require("@theia-extension-tester/theia-element");
const extension_tester_page_objects_1 = require("extension-tester-page-objects");
class CheTheiaBrowser extends theia_browser_1.TheiaBrowser {
isAttachedToFrame() {
return this.mainWindowHandle !== undefined;
}
attachToFrame(timeout) {
return __awaiter(this, void 0, void 0, function* () {
console.log('Attaching to Eclipse Che editor...');
yield this.driver.wait(extension_tester_page_objects_1.until.ableToSwitchToFrame(theia_element_1.TheiaElement.locators.widgets.editorFrame.locator), timeout);
console.log('Successfully attached to Eclipse Che.');
this.mainWindowHandle = yield this.driver.getWindowHandle();
});
}
closeCurrentBrowserTab(timeout) {
const _super = Object.create(null, {
closeCurrentBrowserTab: { get: () => super.closeCurrentBrowserTab }
});
return __awaiter(this, void 0, void 0, function* () {
const newWindowHandle = yield _super.closeCurrentBrowserTab.call(this, timeout);
if (this.mainWindowHandle === newWindowHandle) {
yield this.attachToFrame(this.timeouts.defaultTimeout(timeout));
}
return newWindowHandle;
});
}
waitForWorkbench(timeout) {
const _super = Object.create(null, {
waitForWorkbench: { get: () => super.waitForWorkbench }
});
return __awaiter(this, void 0, void 0, function* () {
console.log('Loading Che-Theia workbench...');
timeout = this.timeouts.pageLoadTimeout(timeout);
if (this.isAttachedToFrame() === false) {
yield this.attachToFrame(timeout);
}
try {
console.log('Waiting for workbench to be ready...');
yield _super.waitForWorkbench.call(this, timeout);
yield this.driver.wait(() => __awaiter(this, void 0, void 0, function* () {
const chevron = new theia_element_1.TheiaElement(theia_element_1.TheiaElement.locators.dashboard.cheChevron);
try {
return (yield chevron.getLocation()).x < 5;
}
catch (_a) {
return false;
}
}), timeout, 'Yellow chevron on top left is not on x = 0.');
console.log('Workbench is ready.');
}
catch (e) {
throw new Error(`${e} - Could not load Eclipse Che workbench. Increase timeout in browser.waitForWorkbench(timeout?: number).`);
}
});
}
}
exports.CheTheiaBrowser = CheTheiaBrowser;
//# sourceMappingURL=CheTheiaBrowser.js.map