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

Make sort sensitivity opt-in and configurable #41

Conversation

bjarne-callewaert
Copy link

In a recent PR (#35), the sorting of strings was adjusted to be case-insensitive. This is not an option for us, so I made the functionality optional with the parameter --sort-sensitivity. If not provided, the old behavior is re-applied.

The unit tests for the postprocessor so they have been updated and expanded

Copy link
Member

@michaelbromley michaelbromley left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution!

I made a couple of comments.

@@ -63,5 +162,24 @@ describe('SortByKeyPostProcessor', () => {
i: { value: 'letter i', sourceFiles: [] },
j: { value: 'letter j', sourceFiles: [] }
});

expect(Object.keys(processor.process(collection, new TranslationCollection(), new TranslationCollection()).values)).to.deep.equal(
Object.keys({
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand what this assertion is testing beyond what the test above it is testing? Can you clarify this?

Copy link
Author

@bjarne-callewaert bjarne-callewaert Jun 4, 2024

Choose a reason for hiding this comment

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

According to my findings, the to.deep.equal does not assert the order in Objects.
These tests were added quite recently by this PR: #35 but these these have not been designed to verify the order of the extracted keys.

I modified the assertion a bit and added some comments to make this more clear

Additionally, some tests were added to have at least one assertion per sort-sensitivity option

README.md Outdated
@@ -110,6 +110,7 @@ Output
--format, -f Format [string] [choices: "json", "namespaced-json", "pot"] [default: "json"]
--format-indentation, --fi Format indentation (JSON/Namedspaced JSON) [string] [default: "\t"]
--sort, -s Sort strings in alphabetical order [boolean]
--sort-sensitivity, -ss Sensitivity when sorting strings [string]
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to add a dedicated section to the readme about sorting now. If I understand correctly, the -ss flag only has an effect in combination with the -s flag right? That should be noted.

Also this section can explain how strings will be sorted without the -ss flag, as well as what the different options are and what effect they have on the sort order.

Copy link
Author

Choose a reason for hiding this comment

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

Limitations for the -ss flag have been added, as well as a separate section in the README

@bjarne-callewaert
Copy link
Author

Thanks for the feedback. I pushed some changes to my initial PR with the proposed additions.

@michaelbromley michaelbromley merged commit bfcdacb into vendure-ecommerce:master Jun 10, 2024
4 checks passed
@michaelbromley
Copy link
Member

Thank you!

@michaelbromley
Copy link
Member

This feature was just published in v9.2.0 👍

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.

None yet

2 participants