Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add update person tests to ensure functionality #7034

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading