@theia-extension-tester/tests
Version:
Tests for theia-extension-tester package.
158 lines • 8.53 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 });
const chai_1 = require("chai");
const page_objects_1 = require("@theia-extension-tester/page-objects");
const path = require("path");
const File_1 = require("./utils/File");
describe.skip('DefaultTreeSection', function () {
this.timeout(60000);
let workbench;
let control;
let section;
const root = 'quarkus-quickstarts';
const FILE_TXT = path.join(root, 'file.txt');
const FILE_ABSOLUTE_TXT = path.join(root, 'file-absolute.txt');
const FOLDER = path.join(root, 'folder');
const FOLDER_ABSOLUTE = path.join(root, 'folder-absolute');
before(function () {
return __awaiter(this, void 0, void 0, function* () {
workbench = new page_objects_1.Workbench();
control = (yield workbench.getActivityBar().getViewControl('Explorer'));
section = yield File_1.getExplorerSection();
yield cleanFiles();
yield new page_objects_1.EditorView().closeAllEditors();
});
});
beforeEach(function () {
return __awaiter(this, void 0, void 0, function* () {
yield section.expand();
});
});
after(function () {
return __awaiter(this, void 0, void 0, function* () {
yield cleanFiles();
yield control.closeView();
yield new page_objects_1.EditorView().closeAllEditors();
});
});
function cleanFiles() {
return __awaiter(this, void 0, void 0, function* () {
yield File_1.deleteFiles(FILE_TXT, FILE_ABSOLUTE_TXT, FOLDER, FOLDER_ABSOLUTE);
});
}
it('getVisibleItems', function () {
return __awaiter(this, void 0, void 0, function* () {
this.retries(3);
const items = yield section.getVisibleItems();
const labels = yield Promise.all(items.map((item) => item.getLabel()));
chai_1.expect(labels).to.include.members(['quarkus-quickstarts', '.theia']);
chai_1.expect(labels).not.to.include(['GreetingMain.java', 'README.md']);
});
});
it('openItem', function () {
return __awaiter(this, void 0, void 0, function* () {
yield section.openItem('quarkus-quickstarts', 'getting-started', 'src', 'main', 'java', 'org', 'acme', 'getting', 'started', 'GreetingService.java');
const tab = yield new page_objects_1.EditorView().getTabByTitle('GreetingService.java');
chai_1.expect(tab).not.to.be.undefined;
});
});
it.skip('findItem', function () {
return __awaiter(this, void 0, void 0, function* () {
const item = yield section.findItem('.theia', 10);
chai_1.expect(yield (item === null || item === void 0 ? void 0 : item.getLabel())).equals('.theia');
});
});
it('findItemByPath', function () {
return __awaiter(this, void 0, void 0, function* () {
const item = yield section.findItemByPath('quarkus-quickstarts', 'getting-started', '.gitignore');
chai_1.expect(yield (item === null || item === void 0 ? void 0 : item.getLabel())).equals('.gitignore');
});
});
for (let i = 1; i <= 2; i++) {
it(`createFolder - level ${i}`, function () {
return __awaiter(this, void 0, void 0, function* () {
const folder = path.join(root, ...new Array(i).fill('folder'));
yield section.createFolder(folder);
chai_1.expect(yield section.existsFolder(folder)).to.be.true;
const folderAbsolute = path.join(root, ...new Array(i).fill('folder-absolute'));
yield section.createFolder(folderAbsolute);
chai_1.expect(yield section.existsFolder(folderAbsolute)).to.be.true;
});
});
}
for (let i = 1; i <= 2; i++) {
it(`createFile - level ${i}`, function () {
return __awaiter(this, void 0, void 0, function* () {
const file = path.join(root, ...new Array(i - 1).fill('folder'), 'file.txt');
yield section.createFile(file);
chai_1.expect(yield section.existsFile(file)).to.be.true;
const fileAbsolute = path.join(root, ...new Array(i - 1).fill('folder-absolute'), 'file-absolute.txt');
yield section.createFile(fileAbsolute);
chai_1.expect(yield section.existsFile(fileAbsolute)).to.be.true;
});
});
}
it('existsFolder', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield section.existsFolder(FOLDER, this.timeout())).to.be.true;
chai_1.expect(yield section.existsFolder(path.join(yield workbench.getOpenFolderPath(), 'folder', 'folder'))).to.be.true;
chai_1.expect(yield section.existsFolder('experiment', 3000)).to.be.false;
chai_1.expect(yield section.existsFolder('experiment', 0)).to.be.false;
chai_1.expect(yield section.existsFolder(FOLDER, this.timeout())).to.be.true;
chai_1.expect(yield section.existsFolder(path.join(FOLDER, 'folder'), this.timeout())).to.be.true;
});
});
it('existsFile', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield section.existsFile(path.join(FOLDER, 'file.txt'), this.timeout())).to.be.true;
chai_1.expect(yield section.existsFile(path.join(yield workbench.getOpenFolderPath(), 'folder', 'file.txt'))).to.be.true;
chai_1.expect(yield section.existsFile('experiment', 3000)).to.be.false;
chai_1.expect(yield section.existsFile('experiment', 0)).to.be.false;
chai_1.expect(yield section.existsFile(FILE_TXT, this.timeout())).to.be.true;
});
});
it('deleteFile', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield section.existsFile(FILE_TXT)).to.be.true;
yield section.deleteFile(FILE_TXT);
chai_1.expect(yield section.existsFile(FILE_TXT, 0)).to.be.false;
const file = path.join(yield workbench.getOpenFolderPath(), 'folder', 'file.txt');
chai_1.expect(yield section.existsFile(file)).to.be.true;
yield section.deleteFile(file);
chai_1.expect(yield section.existsFile(file, 0)).to.be.false;
});
});
it('deleteFolder', function () {
return __awaiter(this, void 0, void 0, function* () {
chai_1.expect(yield section.existsFolder(FOLDER)).to.be.true;
yield section.deleteFolder(FOLDER);
chai_1.expect(yield section.existsFolder('folder', 0)).to.be.false;
const folder = path.join(yield workbench.getOpenFolderPath(), 'folder-absolute', 'folder-absolute');
chai_1.expect(yield section.existsFolder(folder)).to.be.true;
yield section.deleteFolder(folder);
chai_1.expect(yield section.existsFolder(folder, 0)).to.be.false;
});
});
it('openFile', function () {
return __awaiter(this, void 0, void 0, function* () {
const file = path.join(FOLDER_ABSOLUTE, 'file-absolute.txt');
chai_1.expect(yield section.existsFile(file)).to.be.true;
let editor = yield section.openFile(file);
chai_1.expect(yield editor.getFilePath()).equals(path.join(yield workbench.getOpenFolderPath(), file));
const rootFile = FILE_ABSOLUTE_TXT;
chai_1.expect(yield section.existsFile(rootFile)).to.be.true;
editor = (yield section.openFile(rootFile));
chai_1.expect(yield editor.getFilePath()).equals(path.join(yield workbench.getOpenFolderPath(), rootFile));
});
});
});
//# sourceMappingURL=DefaultTreeSection.test.js.map