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

chore(tests) fixate time format #8691

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

Dominik-Petrik
Copy link
Contributor

What: Closes #8690

@patternfly-build
Copy link
Contributor

patternfly-build commented Feb 15, 2023

Copy link
Contributor

@adamviktora adamviktora left a comment

Choose a reason for hiding this comment

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

Solves the issue. Good job

Copy link
Contributor

@gitdallas gitdallas left a comment

Choose a reason for hiding this comment

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

looking good in the US

Copy link
Contributor

@adamviktora adamviktora left a comment

Choose a reason for hiding this comment

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

I ran the test again (previously I tried from different machine and it worked fine) and I still have the same issue in tests:
Screenshot 2023-02-15 at 21 24 37
Screenshot 2023-02-15 at 21 24 09

@wise-king-sullyman
Copy link
Contributor

Is it just me or is the diff in that snapshot showing the same thing on each line?

@gitdallas
Copy link
Contributor

gitdallas commented Feb 15, 2023

yea.. i can't see a difference.. maybe a different type of space character or something? i'd be curious in you copying the line in question and converting the text to code representation (https://www.online-toolz.com/tools/text-unicode-entities-convertor.php).. then updating the snapshot and doing the same, see if something changed.

@adamviktora
Copy link
Contributor

adamviktora commented Feb 15, 2023

Yes, you are both right. It is a problem with the space just before "AM" (or PM in the next test).

This is the snapshot: 1/1/2022%2C%2012%3A00%3A00%20AM (Space)

And this is actually received: 1/1/2022%2C%2012%3A00%3A00%u202FAM (Narrow no-break space)

@adamviktora
Copy link
Contributor

It seems, that new Date().toLocaleString() creates 'NARROW NO-BREAK SPACE' character before AM / PM in my localization.

Here is a suggestion, how it could be repaired: timestamp test repair commit

I have edited the tests, so they replace the 'NARROW NO-BREAK SPACE' with classic space before calling the screen.getByText(...) method.

I did not find an easy way to modify asFragment so it uses classic space, because it consists of a whole component using the .toLocaleString() internally. So I have modified the snapshot to use the 'NARROW NO-BREAK SPACE' -- but this is probably not a good way, because now it will break these localizations, which are using classic space. I don't know how to extend this expect(asFragment()).toMatchSnapshot(); condition, so we can compare fragment and snapshot as strings -- so the conversion of the narrow nbsp to space could be appliable.

Anyway, overall I don't think this is a great solution, it seems to me like only "hiding a problem" by this conversion of nbsp to space character -- and it could create some other troubles in the future.

@adamviktora
Copy link
Contributor

It actually might be a Node version issue.

To reproduce the bug: I am using node v18.14.0, yarn 1.22.19

@Dominik-Petrik
Copy link
Contributor Author

Dominik-Petrik commented Feb 16, 2023

Slightly better solution than explicitly replacing spaces in the tested string might be to use normalization. Tested strings are getting normalized, which seems to mess up the spaces. We can configure the normalization like this:
Screenshot 2023-02-16 at 13 19 49
I am not sure how to handle the snapshot failing, because there seems to be no way to configure normalization on snapshot.

@gitdallas
Copy link
Contributor

screenshot is based on what the app produces, so if you normalize it in the app (timestamp component?) it will update the screenshot that way.

@Dominik-Petrik
Copy link
Contributor Author

Dominik-Petrik commented Feb 16, 2023

screenshot is based on what the app produces, so if you normalize it in the app (timestamp component?) it will update the screenshot that way.

Yeah, but the matchers are getting normalized and not what gets rendered. And since snapshots are not getting matched, we can't use normalization on them. And the code snapshot produces can't be easily modified because we would have to modify the Timestamp component itself. See Adam's comment

@wise-king-sullyman
Copy link
Contributor

If it's a Node version issue would it potentially be resolved as part of #8303?

@nicolethoen nicolethoen merged commit a74c1b2 into patternfly:v5 Mar 7, 2023
tlabaj added a commit that referenced this pull request Mar 7, 2023
dlabaj pushed a commit that referenced this pull request Mar 7, 2023
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.

Bug - Tests - Timestamp tests keeps failing because of wrong format
6 participants