Adding basic PHP Simple deftile test

Signed-off-by: Tibor Dancs <tdancs@redhat.com>
7.20.x
Tibor Dancs 2020-08-04 14:28:17 +02:00
parent 45ba3ac2ba
commit 437b87bda1
No known key found for this signature in database
GPG Key ID: 9B76C30CBD6AADBC
4 changed files with 122 additions and 0 deletions

View File

@ -299,6 +299,34 @@ export class ProjectTree {
throw new error.TimeoutError('Exceeded the maximum number of checking attempts, project has not been imported');
}
async waitProjectImportedNoSubfolder(projectName: string,
attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
visibilityItemPolling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING * 5,
triesPolling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING * 30) {
Logger.debug(`ProjectTree.waitProjectImportedNoSubfolder "${projectName}"`);
const rootItemLocator: By = By.css(this.getTreeItemCssLocator(`${projectName}`));
for (let i = 0; i < attempts; i++) {
const isProjectFolderVisible = await this.driverHelper.waitVisibilityBoolean(rootItemLocator, 1, visibilityItemPolling);
if (!isProjectFolderVisible) {
Logger.trace(`ProjectTree.waitProjectImportedNoSubfolder project not located, reloading page.`);
await this.driverHelper.reloadPage();
await this.driverHelper.wait(triesPolling);
await this.ide.waitAndSwitchToIdeFrame();
await this.ide.waitIde();
await this.openProjectTreeContainer();
continue;
}
return;
}
throw new error.TimeoutError('Exceeded the maximum number of checking attempts, project has not been imported');
}
private async getWorkspacePathEntry(): Promise<string> {
const nodeAttribute: string = 'data-node-id';
const splitDelimeter = ':';

View File

@ -0,0 +1,78 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import 'reflect-metadata';
import * as projectAndFileTests from '../../testsLibrary/ProjectAndFileTests';
import * as workspaceHandling from '../../testsLibrary/WorksapceHandlingTests';
import * as commonLsTests from '../../testsLibrary/LsTests';
import * as codeExecutionTests from '../../testsLibrary/CodeExecutionTests';
import { e2eContainer } from '../../inversify.config';
import { WorkspaceNameHandler, Editor, CLASSES } from '../..';
const editor: Editor = e2eContainer.get(CLASSES.Editor);
const workspaceSampleName: string = 'php-web-simple';
const fileFolderPath: string = `${workspaceSampleName}`;
const tabTitle: string = 'index.php';
// const codeNavigationClassName: string = 'RouterImpl.class';
const depTaskName: string = 'Configure Apache Web Server DocumentRoot';
const buildTaskName: string = 'Start Apache Web Server';
const buildTaskLinkExpectedText: string = 'A process is now listening on port 8080.';
const stack: string = 'PHP Simple';
suite(`${stack} test`, async () => {
suite (`Create ${stack} workspace`, async () => {
workspaceHandling.createAndOpenWorkspace(stack);
projectAndFileTests.waitWorkspaceReadinessNoSubfolder(workspaceSampleName);
});
suite('Test opening file', async () => {
// opening file that soon should give time for LS to initialize
projectAndFileTests.openFile(fileFolderPath, tabTitle);
prepareEditorForLSTests();
});
suite('Configuration of dependencies', async () => {
codeExecutionTests.runTask(depTaskName, 30_000);
});
suite('Language server validation', async () => {
commonLsTests.errorHighlighting(tabTitle, `error_text;`, 14);
commonLsTests.suggestionInvoking(tabTitle, 14, 26, '$test');
commonLsTests.autocomplete(tabTitle, 15, 5, 'phpinfo');
// commonLsTests.codeNavigation(tabTitle, 19, 7, codeNavigationClassName); // there is no codenavigation in the php simple stack (no object oriented code)
});
suite('Validation of project build', async () => {
codeExecutionTests.runTaskWithDialogShellAndOpenLink(buildTaskName, buildTaskLinkExpectedText, 30_000);
});
suite ('Stopping and deleting the workspace', async () => {
let workspaceName = 'not defined';
suiteSetup( async () => {
workspaceName = await WorkspaceNameHandler.getNameFromUrl();
});
test (`Stop worksapce`, async () => {
await workspaceHandling.stopWorkspace(workspaceName);
});
test (`Remove workspace`, async () => {
await workspaceHandling.removeWorkspace(workspaceName);
});
});
});
export function prepareEditorForLSTests() {
test(`Prepare file for LS tests`, async () => {
await editor.moveCursorToLineAndChar(tabTitle, 12, 4);
await editor.performKeyCombination(tabTitle, '\n$test = " test";');
await editor.moveCursorToLineAndChar(tabTitle, 14, 20);
await editor.performKeyCombination(tabTitle, ' . $test;\nphpinfo();');
});
}

View File

@ -26,6 +26,17 @@ export function waitWorkspaceReadiness(sampleName : string, folder: string) {
});
}
export function waitWorkspaceReadinessNoSubfolder(sampleName : string) {
test('Wait for workspace readiness', async () => {
await ide.waitAndSwitchToIdeFrame();
await ide.waitPreloaderVisible();
await ide.waitPreloaderAbsent();
await ide.waitIde();
await projectTree.openProjectTreeContainer();
await projectTree.waitProjectImportedNoSubfolder(sampleName);
});
}
export function openFile(filePath: string, fileName: string) {
test('Expand project and open file in editor', async () => {
await projectTree.expandPathAndOpenFileInAssociatedWorkspace(filePath, fileName);

View File

@ -11,15 +11,20 @@
import { CLASSES, Dashboard } from '..';
import { e2eContainer } from '../inversify.config';
import { GetStarted } from '../pageobjects/dashboard/GetStarted';
import { Logger } from '../utils/Logger';
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
const getStarted: GetStarted = e2eContainer.get(CLASSES.GetStarted);
export function createAndOpenWorkspace(stack: string) {
test(`Open 'New Workspace' page`, async () => {
Logger.trace(`WorkspaceHandlingTests.createAndOpenWorkspace wait for dashboard`);
await dashboard.waitPage();
Logger.trace(`WorkspaceHandlingTests.createAndOpenWorkspace click get started button`);
await dashboard.clickGetStartedButton();
Logger.trace(`WorkspaceHandlingTests.createAndOpenWorkspace wait for getting started page`);
await getStarted.waitPage();
Logger.trace(`WorkspaceHandlingTests.createAndOpenWorkspace click on sample ${stack}`);
await getStarted.clickOnSample(stack);
});
}