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

Basic presentation of form load failures; prepare release: @getodk/web-forms 0.5.0 #237

Merged
merged 7 commits into from
Oct 16, 2024

Conversation

eyelidlessness
Copy link
Member

I have verified this PR works in these browsers (latest versions):

  • Chrome
  • Firefox
  • Safari (macOS)
  • Safari (iOS)
  • Not applicable

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

A few tests. I think we'll want to expand testing in this area significantly, probably at different levels of the stack.

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

It's approximately the quickest solution, which was the priority for now. There are known areas for improvement, discussed under What's changed below.

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?

If users previously depended on getting no information whatsoever when a form fails to load, this will break that workflow.

Do we need any specific form for testing your changes? If so, please attach one.

Added a few fixtures, each demonstrating a known failure case.

What's changed

Here, a “form load failure” is any Promise rejection produced by the engine’s initializeForm entrypoint. This is intentionally broad, and what I think is a relatively minimal first pass that might be useful to users (and to us).

“Relatively” minimal because I took the opportunity to lay a bit of groundwork for a few things either cued for near term work, or ripe for near term improvement.

Notable among those:

  • Establish a more intentional approach to use of test fixtures in the web-forms package. This includes a dedicated fixtures directory (alongside those already used by scenario), and a narrower “test helper” (ugh) to access those. That access point also includes some additional breadcrumbs for ways we might improve fixture access in the future.

  • FormLoadFailure begins laying a bit of groundwork for the incoming, much more comprehensive overhaul of error messaging.

  • Actually tests a few different form load failure conditions. I believe these will be useful for catching potential regressions in that overhaul, as well in other future work around those specific failure modes.

UI/UX/presentation design note

I had a brief discussion with @alyblenkin about this being a minimal first step. We agreed that this seems like a reasonable first pass, and agreed there’s more to do in near-future iterations. Some of the things which are currently lacking from a UX perspective, blocked by work with a larger scope:

  • Better messaging of specific errors. We’ll be cataloguing known cases as part of External secondary instances: Error conditions #202, which will give us a much clearer picture of how to address this.
  • Any kind of direct prompt for user action. Deferred for the same reasons.
  • Ability to close the dialog or go back. Deferred because this would expand scope to navigation more generally, which we should look at more holistically.

Where a “form load failure” is any Promise rejection produced by the engine’s `initializeForm` entrypoint. This is intentionally broad, and what I think is a relatively minimal first pass that might be useful to users (and to us).

“Relatively” minimal because I took the opportunity to lay a bit of groundwork for a few things either cued for near term work, or ripe for near term improvement.

Notable among those:

- Establish a more intentional approach to use of test fixtures in the `web-forms` package. This includes a dedicated fixtures directory (alongside those already used by `scenario`), and a narrower “test helper” (ugh) to access those. That access point also includes some additional breadcrumbs for ways we might improve fixture access in the future.

- `FormLoadFailure` begins laying a bit of groundwork for the incoming, much more comprehensive overhaul of error messaging.

- Actually tests a few different form load failure conditions. I believe these will be useful for catching potential regressions in that overhaul, as well in other future work around those specific failure modes.

UI/UX/presentation design note: I had a brief discussion with @alyblenkin about this being a minimal first step. We agreed that this seems like a reasonable first pass, and agreed there’s more to do in near-future iterations. Things which are currently lacking from a UX perspective, blocked by work with a larger scope:

- Better messaging of specific errors. We’ll be cataloguing known cases as part of #202, which will give us a much clearer picture of how to address this.
- Any kind of direct prompt for user action. Deferred for the same reasons.
- Ability to close the dialog or go back. Deferred because this would expand scope to navigation more generally, which we should look at more holistically.
It would make a lot more sense to just include all `.ts` source files, but that causes issues with the handful of `.ts` entrypoint-ish modules which happen to also import `.vue` modules. That’s a fundamental problem with the Vue template language as a pseudo-module format, just like how it breaks down with ESLint (and probably will for many other tools!).
For some reason, testing in Firefox fails unpredictably when asserting text content of an element where word breaks occur at element boundaries! I had hoped not to use a more specific selector here, but it’s gonna have to do...
Copy link

changeset-bot bot commented Oct 4, 2024

⚠️ No Changeset found

Latest commit: c235324

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

* {@link unknownCauseDetail}, in hopes it will provide further clarification
* of unknown failure conditions.
*/
export class InitializeFormFailure extends Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps a better name for this class could be FormInitializationFailure. Or even FormInitializationError, making it clear to passers-by that it's specialization of Error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Normally I'd agree! The naming here is trying to accomplish—or start to accomplish—a few things which aren't typical:

  1. Make it explicit that the class is directly coupled to the initializeForm function
  2. Make it clear that the condition is unambiguously a failure of a call to that function
  3. Set this case up for incorporation into very near-term work on External secondary instances: Error conditions #202

In near term work (and application of the approach generally), we'll have at least some notion of:

  • Errors/error-like conditions which correspond directly to specific operations, computational concepts, spec domain model concepts, etc. To the extent they're coupled, naming them as such seems helpful.

  • Levels of severity which may be objective (e.g. this case, "initializeForm failed") but may have some room for subjective interpretation (such as failure to access some form attachment, which could be terminal for some use cases but perfectly fine for others).

  • In support of that, errors/error-like conditions produced together with requested values.

  • Type-level and API documentation incorporating those types, in a way that conventional throw semantics don't allow.

All of that aside, I'm perfectly fine with preferring an Error suffix here as the specific terminology to convey "this operation unambiguously failed". This is definitely a case that most overlaps with that idiom. But I do want to make sure all of this context around the broader approach to error production doesn't get lost in naming this one class.


Note to myself: whatever we decide on the name, the module name is already inconsistent with the class. So one or both should change.

- For now, we’ll go with the name suggested in review. As discussed there, we have broader goals for error reporting, but we can address those in a non-bandaid change (i.e. supporting #202)
- Aligns the module and class name
@eyelidlessness eyelidlessness changed the title Basic presentation of form load failures Basic presentation of form load failures; prepare release: @getodk/web-forms 0.5.0 Oct 16, 2024
@eyelidlessness eyelidlessness merged commit c9a0ee3 into main Oct 16, 2024
86 checks passed
@eyelidlessness eyelidlessness deleted the temp/ui/form-load-error branch October 16, 2024 21:53
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.

3 participants