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

feat: add e2e tests for config-import. #700

Merged
merged 21 commits into from
Jun 25, 2024
Merged

Conversation

tomasciccola
Copy link
Contributor

@tomasciccola tomasciccola commented Jun 12, 2024

should close #482

Additionally this adds code to MapeoProject. Specifically:

  1. Expose translation as a getter (only used in tests, but may be useful in the future)
  2. Delete translations that refer to deleted presets and fields

There's a test case where I try to load the default config twice in parallel that results in - what I think - unwanted expectations. Basically we get double the presets, fields and translations since when each config is loaded there's no docs to delete.
We should think if this is a valid (possible) case and how we can fix the code to avoid this?

Tomás Ciccola added 3 commits June 12, 2024 11:26
Additionally:
* added `translation` getter in `mapeoProject`
* `deleteAll(translation)` in import config
@tomasciccola tomasciccola requested a review from EvanHahn June 12, 2024 14:33
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

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

I'll give this a more thorough review on Monday, but found a few small things for now.

src/mapeo-project.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
test-e2e/config-import.js Outdated Show resolved Hide resolved
* make `deleteTranslations` a closure, pass the logger
* `deleteTranslations` avoid for loop, use Promise.all(map)
* make failing test case instead of logging
@tomasciccola tomasciccola requested a review from EvanHahn June 13, 2024 17:36
src/mapeo-project.js Outdated Show resolved Hide resolved
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

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

Looks like tests are failing. Could you fix those?

@tomasciccola
Copy link
Contributor Author

tomasciccola commented Jun 18, 2024

Looks like tests are failing. Could you fix those?

So, the issue with the failing test is the following:
That test loads the config twice in parallel (using Promise.all) and results in presets, fields and translations being loaded to the database twice. Those doctypes should be deleted before loading a new config, but this doesn't happen when loading in parallel.
So to fix this tests I'm thinking:

  1. Delete this test, we shouldn't expect a config being loaded twice in parallel
  2. Find a way to force sequential excecution (So, if you call Promise.all([project.importConfig, project.importConfig]) internally it would force sequetial execution). I don't know if we can actually enforce this. A weird way I'm thinking that can solve this would be having a boolean in the class (like this.#loadingConfig). Not ideal, but it solves this case

@tomasciccola tomasciccola requested a review from EvanHahn June 18, 2024 14:22
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

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

I like the way you've enforced that imports only happen sequentially. Just a few more little things from me.

src/mapeo-project.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

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

LGTM once we move to this.$translation.dataType (happy to discuss alternatives) and fix the failing test.

@tomasciccola
Copy link
Contributor Author

LGTM once we move to this.$translation.dataType (happy to discuss alternatives) and fix the failing test.

I've changed the failing tests so that it now expects an error being throwed. Despite that, the test still fails...
any pointers??

@tomasciccola tomasciccola requested a review from EvanHahn June 19, 2024 17:23
test-e2e/config-import.js Outdated Show resolved Hide resolved
test-e2e/config-import.js Outdated Show resolved Hide resolved
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

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

LGTM once we fix tests.

@tomasciccola tomasciccola merged commit 42bc021 into main Jun 25, 2024
7 checks passed
@tomasciccola tomasciccola deleted the feat/configImporte2eTests branch June 25, 2024 13:32
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.

Create e2e tests for loading the config in a project
2 participants