diff --git a/cypress/e2e/ui/people/standard.person.new.spec.js b/cypress/e2e/ui/people/standard.person.new.spec.js index d7e9894e0c..85e2874801 100644 --- a/cypress/e2e/ui/people/standard.person.new.spec.js +++ b/cypress/e2e/ui/people/standard.person.new.spec.js @@ -1,8 +1,13 @@ +const personEditorPath = "PersonEditor.php"; +const personViewPath = "PersonView.php"; + context("Standard Person", () => { + const uniqueSeed = Date.now().toString(); + it("Add Full Person", () => { - const uniqueSeed = Date.now().toString(); const name = "Bobby " + uniqueSeed; - cy.loginStandard("PersonEditor.php"); + + cy.loginStandard(personEditorPath); cy.get("#Gender").select("1"); cy.get("#FirstName").type(name); cy.get("#LastName").type("Hall"); @@ -13,19 +18,43 @@ context("Standard Person", () => { cy.get("#Classification").select("1"); cy.get("#PersonSaveButton").click(); - cy.url().should("contains", "PersonView.php"); + cy.url().should("contains", personViewPath); + cy.contains(name); + + // make sure edit works + cy.get('#EditPerson').click(); + + cy.url().should("contains", personEditorPath); + + cy.get("#BirthYear").clear().type("1980"); + cy.get("#Email").clear().type(`bobby${uniqueSeed}@example.com`); + cy.get("#PersonSaveButton").click(); + + cy.url().should("contains", personViewPath); cy.contains(name); + }); it("Add Person only first and last name", () => { - const uniqueSeed = Date.now().toString(); const name = "Robby " + uniqueSeed; - cy.loginStandard("PersonEditor.php"); + + cy.loginStandard(personEditorPath); cy.get("#FirstName").type(name); cy.get("#LastName").type("Hall"); cy.get("#PersonSaveButton").click(); - cy.url().should("contains", "PersonView.php"); + cy.url().should("contains", personViewPath); + cy.contains(name); + + // make sure edit works + cy.get('#EditPerson').click(); + + cy.url().should("contains", personEditorPath); + + cy.get("#Email").clear().type(`robby${uniqueSeed}@example.com`); + cy.get("#PersonSaveButton").click(); + + cy.url().should("contains", personViewPath); cy.contains(name); }); }); diff --git a/src/Include/Functions.php b/src/Include/Functions.php index c93190cf6e..38fc9ca51a 100644 --- a/src/Include/Functions.php +++ b/src/Include/Functions.php @@ -331,9 +331,16 @@ function ChopLastCharacter($sText): string return mb_substr($sText, 0, strlen($sText) - 1); } -function change_date_for_place_holder($string) +function change_date_for_place_holder(string $string = null): string { - return ((strtotime($string) != "") ? date(SystemConfig::getValue("sDatePickerFormat"), strtotime($string)) : strtotime($string)); + $string ??= ''; + $timestamp = strtotime($string); + + if ($timestamp !== false) { + return date(SystemConfig::getValue("sDatePickerFormat"), $timestamp); + } + + return ''; } function FormatDateOutput()