Skip to content

Commit

Permalink
Fix frontend test for email validation on create person
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleisa committed Mar 6, 2023
1 parent 0858d1f commit 6ea41dc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/app/components/person-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { computed } from "@ember/object";
import { isBlank } from "@ember/utils";
import { getNames as countryNames } from "ember-i18n-iso-countries";
import Person from "../models/person";
import config from "../config/environment";

export default ApplicationComponent.extend({
intl: service(),
Expand Down Expand Up @@ -99,7 +100,7 @@ export default ApplicationComponent.extend({
`person.${attribute}`
);
this.get("notify").alert(`${translated_attribute} ${message}`, {
closeAfter: 8000
closeAfter: config.environment === "test" ? null : 8000
});
});
});
Expand Down
46 changes: 42 additions & 4 deletions frontend/tests/acceptance/create-person-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module("Acceptance | create person", function(hooks) {
// TODO expect errors!
});

test("should display error when email is invalid", async function(assert) {
test("should display two error when email is empty", async function(assert) {
await page.newPersonPage.visit();
assert.equal(currentURL(), "/people/new");

Expand All @@ -95,12 +95,50 @@ module("Acceptance | create person", function(hooks) {

interactor.selectDate(new Date(2019, 1, 19));

await selectChoose("#department", "/dev/ruby");
await selectChoose("#company", "Bewerber");
await selectChoose("#department", "/dev/one");
await selectChoose("#company", "Firma");
await selectChoose("#maritalStatus", ".ember-power-select-option", 0);

await click("button#submit-button");

assert.equal(
document.querySelectorAll(".ember-notify")[0].querySelector(".message")
.innerText,
"Email muss ausgefüllt werden"
);
assert.equal(
document.querySelectorAll(".ember-notify")[1].querySelector(".message")
.innerText,
"Email Format nicht gültig"
);
});

test("should display one error when email format is invalid", async function(assert) {
await page.newPersonPage.visit();
assert.equal(currentURL(), "/people/new");

page.newPersonPage.toggleNewForm();

await page.newForm.name("Findus");
await page.newForm.email("findus.puzzle");
await page.newForm.title("Sofware Developer");
await page.newForm.shortname("FI");
await page.newForm.location("Bern");

let interactor = openDatepicker($(".birthdate_pikaday > input"));

interactor.selectDate(new Date(2019, 1, 19));

await selectChoose("#department", "/dev/one");
await selectChoose("#company", "Firma");
await selectChoose("#maritalStatus", ".ember-power-select-option", 0);

await click("button#submit-button");

assert.dom().includesText("Format nicht gültig");
assert.equal(
document.querySelectorAll(".ember-notify")[0].querySelector(".message")
.innerText,
"Email Format nicht gültig"
);
});
});

0 comments on commit 6ea41dc

Please sign in to comment.