angular4-testing/project-manager/e2e/page-object/task/task-edit.po.ts

78 lines
2.0 KiB
TypeScript
Raw Normal View History

2017-04-14 03:57:42 +02:00
import {AbstractHeaderPage} from "../abstract-header.po";
import {by, element} from "protractor";
import {TaskOverviewPage} from "./task-overview.po";
export class TaskEditPage extends AbstractHeaderPage {
errorMessages = {title: 'Titel muss mindestens 5 Zeichen enthalten',
email : 'Bitte geben Sie eine gültige E-Mail Adresse an'};
titleInput = element(by.id('title'));
descriptionInput = element(by.id('description'));
statusDropdown = element(by.id('state'));
assigneeName = element(by.id('assignee_name'));
assigneeEmail = element(by.id('assignee_email'));
saveButton = element(by.id('save'));
cancelButton = element(by.id('cancel'));
2017-04-14 03:57:42 +02:00
constructor(newTask: boolean) {
super();
let headline;
if (newTask) {
headline = 'Neue Aufgabe anlegen';
} else {
headline = 'Aufgabe bearbeiten';
}
super.validatePageHeadline(headline)
}
clearEnterTitle(title: string) {
this.titleInput.clear();
this.titleInput.sendKeys(title);
}
clearEnterDescription(description: string) {
this.descriptionInput.clear();
this.descriptionInput.sendKeys(description);
}
setStatus(state: string) {
this.statusDropdown.element(by.css('[value="${state}"]'))
.click()// -> Höller, Christoph - Angular, S. 562 - Listing 14.12
}
clearInsertName(name: string) {
this.assigneeName.clear();
this.assigneeName.sendKeys(name);
}
clearInsertEmail(email: string) {
this.assigneeEmail.clear();
this.assigneeEmail.sendKeys(email);
}
submitTaskForm() {
this.saveButton.click();
return new TaskOverviewPage;
}
cancelSubmitTask() : TaskOverviewPage {
this.cancelButton.click();
return new TaskOverviewPage();
}
static validateInput(elementId: string, value: string) {
2017-04-14 03:57:42 +02:00
const input = element(by.id(elementId));
expect(input.getAttribute('value')).toBe(value);
}
validateError(input: string) {
expect(element(by.className('alert')).getText())
.toBe(this.errorMessages[input]);
}
}