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

Warn about <2024.1 entities spec and update tests #1272

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ktuite
Copy link
Member

@ktuite ktuite commented Nov 6, 2024

Closes getodk/central#730

I updated the versions in testData.forms.simpleEntity and testData.forms.updateEntity so the tests didn't have to change, but for any test that expected the older version, I also made test forms testData.forms.simpleEntity2022 and testData.forms.updateEntity2023 and used those (along with ?ignoreWarnings=true) where appropriate.

I need to take a closer look at how frontend expects warnings. I wrote the nice text "Entities specification version [2023.1.0] is not compatible with Offline Entities. Please use version 2024.1.0 or later.'" in the warning but it's probably not in a place frontend can find it, and we might want to translate it anyway.

Screenshot 2024-11-05 at 4 28 41 PM

What has been done to verify that this works as intended?

Why is this the best possible solution? Were any other approaches considered?

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.

Before submitting this PR, please make sure you have:

  • run make test and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

@matthew-white
Copy link
Member

I wrote … nice text … in the warning but it's probably not in a place frontend can find it, and we might want to translate it anyway.

I do think that we'll want to translate it. I think we translate other workflow warnings. In general, we want to translate most warnings or errors that a user could trigger by user error. (There's getodk/central#489 to do more of that for errors.)

Comment on lines +85 to +87
let warnings;
if (semverSatisfies(version.get(), '<2024.1.x'))
warnings = {
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's nice to avoid a let where possible. How about const + a ternary?

const warnings = semverSatisfies(version.get(), '>=2024.1.x')
  ? null
  : {
    type: 'oldEntityVersion',
    // ...
  };

Comment on lines +85 to +87
let warnings;
if (semverSatisfies(version.get(), '<2024.1.x'))
warnings = {
Copy link
Member

Choose a reason for hiding this comment

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

The name warnings in the plural makes me think that it should be an array. Just a thought, I also wouldn't mind leaving it as-is until we have a second warning.


if (dataset.isDefined() && dataset.get().warnings != null) {
if (!context.transitoryData.has('workflowWarnings')) context.transitoryData.set('workflowWarnings', []);
context.transitoryData.get('workflowWarnings').push(dataset.get().warnings);
Copy link
Member

Choose a reason for hiding this comment

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

If you make warnings an array:

Suggested change
context.transitoryData.get('workflowWarnings').push(dataset.get().warnings);
context.transitoryData.get('workflowWarnings').push(...dataset.get().warnings);

@@ -134,6 +134,7 @@ const createNew = (partial, project) => async ({ Actees, Datasets, FormAttachmen

// Check for xmlFormId collisions with previously deleted forms
await Forms.checkDeletedForms(partial.xmlFormId, project.id);
await Forms.checkDatasetWarnings(parsedDataset);
Copy link
Member

Choose a reason for hiding this comment

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

I see that the lines above and below this one use await, but if Forms.checkDatasetWarnings() doesn't need to be async and return a promise, I think it'd be nice to remove the await. I think code is often clearer when things can be done sync.

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.

Warn about forms with old version of entity spec <2024.*
2 participants