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

Test non-standard date and time formats #2127

Conversation

labkey-danield
Copy link
Contributor

Rationale

Test automation for non-standard date and time formats. The tests are in NonStandardDateAndTimeFormatTest.java.
Consolidated various test helpers that set date and time fields. Change various helpers, UI components, other tests, etc... to use the enums defined in the base setting page for the format not a string (not a string).

Added a page to set formats at the page level (FolderFormatsPage).

Added APIContainerHelper.setDateAndTimeFormats. This allows setting of non-standard formats to projects and folders.

Related Pull Requests

Changes

  • Consolidate and clean up helpers.
  • Add back tests that had been commented out.
  • Added NonStandardDateAndTimeFormatTest.java
  • Updated tests and other code to use helpers from LKS tests.
  • Added check for format warnings to domain designer and settings pages.
  • APIContainerHelper.setDateAndTimeFormats

Change helpers to take enum values and not strings.
Uncomment a test that fails with older versions of FireFox.
Added check for Site Validation report.
Add a FolderFormats page.
Added a helper in the test that cna be used to validate the format settings on a site, project or folder page.
@labkey-danield labkey-danield requested a review from XingY December 3, 2024 00:30
{
String format = fieldDefinition.getFormat().trim();

int index = format.indexOf(" ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works with MMMM dd yyyy date time format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.
I have changed the code to this:

                String format = fieldDefinition.getFormat().trim();
                int index = format.lastIndexOf(" ");

                if (format.substring(index + 1).contains(":"))
                {
                    fieldRow.setDateTimeFormat(
                            DATE_FORMAT.get(format.substring(0, index)),
                            TIME_FORMAT.get(format.substring(index + 1)));

If the "last part" of the format string contains a ':' the it has a time value. If it doesn't then it is a date only format.

ddMMMyyyy("ddMMMyyyy"),
ddMMMyy("ddMMMyy"),
MMddyyyy("MM/dd/yyyy"),
MM_dd_yyyy("MM-dd-yyyy"),
MMMM_dd_yyyy("MMMM dd yyyy"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is MMMM_dd_yyyy used in any test? It's kinda special in that it contains space. I think it's good to check setting date/datetime field that uses this type and verify it's persisted / parsed correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed a couple of tests in LKS and LKSM to use MMMM_dd_yyyy


// Private helper to check the Site Validation report. Checks to see if the report should, or should not, contain
// the list of warnings.
private void validateSiteValidationReport(String scope, List<String> expectedWarnings, boolean shouldContain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there test that checks meta formats "date", "datetime" and "time" won't show up on the report?

Copy link
Contributor Author

@labkey-danield labkey-danield Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NonStandardDateAndTimeFormatTest.testTextFormatValueOfDate uses the DATE, TIME, DATETIME and none values. I've added a call to check that the site validation report does not flag them.

Use the date format that has spaces in it in a few tests.
In NonStandardDateAndTimeFormatTest.testTextFormatValueOfDate check that using DATE, TIME and DATETIME do not get flagged by the site validation report.
In SMNonStandardDateTimes.testAdminPage add a check for setting the formats back to standard values.
@labkey-danield labkey-danield merged commit 4b634e1 into release24.11-SNAPSHOT Dec 4, 2024
1 of 2 checks passed
@labkey-danield labkey-danield deleted the 24.11_fb_testNonStandardDateAndTimeFormats branch December 4, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants