72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
|
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'));
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
validateInput(elementId: string, value: string) {
|
||
|
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]);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|