UNPKG

@theia-extension-tester/tests

Version:

Tests for theia-extension-tester package.

59 lines 2.66 kB
"use strict"; 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.getProjectPath = exports.deleteFiles = exports.getExplorerSection = void 0; const page_objects_1 = require("@theia-extension-tester/page-objects"); const path = require("path"); function getExplorerSection() { return __awaiter(this, void 0, void 0, function* () { const control = yield new page_objects_1.Workbench().getActivityBar().getViewControl('Explorer'); const sideBar = yield control.openView(); for (const section of yield sideBar.getContent().getSections()) { const title = (yield section.getTitle()).toLowerCase(); if (section instanceof page_objects_1.DefaultTreeSection && (title.includes('workspace') || title.includes('projects'))) { return section; } } throw new Error('Could not find file section.'); }); } exports.getExplorerSection = getExplorerSection; function deleteFiles(...files) { return __awaiter(this, void 0, void 0, function* () { const tree = yield getExplorerSection(); for (const file of files) { if (path.extname(file).length > 0) { if (yield tree.existsFile(file, 0)) { yield tree.deleteFile(file).catch((e) => { console.error(e); }); } } else { if (yield tree.existsFolder(file, 0)) { yield tree.deleteFolder(file).catch((e) => { console.error(e); }); } } } }); } exports.deleteFiles = deleteFiles; function getProjectPath() { const project = process.env['THEIA_EXPECTED_WORKBENCH_PATH']; if (project) { return project; } throw new Error('THEIA_EXPECTED_WORKBENCH_PATH is undefined'); } exports.getProjectPath = getProjectPath; //# sourceMappingURL=File.js.map