Skip to content

Commit

Permalink
add update person tests to ensure functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
DAcodedBEAT committed May 17, 2024
1 parent 85c116a commit cc947f5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
41 changes: 35 additions & 6 deletions cypress/e2e/ui/people/standard.person.new.spec.js
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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);
});
});
11 changes: 9 additions & 2 deletions src/Include/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cc947f5

Please sign in to comment.