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

Refresh stale forms after 30 min of no change #1256

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

nmajor25
Copy link
Contributor

@nmajor25 nmajor25 commented Apr 23, 2024

Shortcut Story ID: [sc-50208]

  • Add tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the form initially loads or reloads (on ready:form), set the refreshForm() function to run in 30 min.

When the user makes a change to the form (represented by the updateStoredSubmission() function being called), set a new refreshForm() to be called in 30 min.

When the user submits the form, cancel the scheduled refreshForm() function.

@@ -48,6 +51,8 @@ export default App.extend({
},
readyForm() {
this.trigger('ready');

this.refreshForm();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially put this in the initialize() function. But if a user is prompted with the keep/discard work prompt, this.refreshForm() would be called before the actual form has been shown to the user.

So I put it here instead. To wait until the form content is loaded.

Copy link
Member

@paulfalgout paulfalgout left a comment

Choose a reason for hiding this comment

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

Looks correct to me

@nmajor25
Copy link
Contributor Author

@paulfalgout cool, I'll get some tests created for this.

@nmajor25 nmajor25 force-pushed the feature/refresh-stale-forms branch from 29ce24b to 841afad Compare April 24, 2024 22:10
Copy link

cypress bot commented Apr 24, 2024

1 flaky test on run #6338 ↗︎

0 280 0 0 Flakiness 1

Details:

Refresh stale forms after 30 min of inactivity
Project: RoundingWell Care Ops Frontend Commit: 30777a6595
Status: Passed Duration: 03:09 💡
Started: Apr 25, 2024 5:57 PM Ended: Apr 25, 2024 6:00 PM
Flakiness  test/integration/forms/form.js • 1 flaky test • care-ops-e2e

View Output

Test Artifacts
Noncontext Form > update patient field Test Replay Screenshots

Review all test suite changes for PR #1256 ↗︎

@coveralls
Copy link

coveralls commented Apr 24, 2024

Pull Request Test Coverage Report for Build 970992bc-5fda-453c-ba4b-3a79aa95267c

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.91%

Totals Coverage Status
Change from base Build d0ef3ab5-d6fc-4d65-8a12-00de98cb8bef: 0.0%
Covered Lines: 5941
Relevant Lines: 5945

💛 - Coveralls

@nmajor25 nmajor25 force-pushed the feature/refresh-stale-forms branch from 841afad to 88d4f3d Compare April 25, 2024 15:01
@nmajor25 nmajor25 force-pushed the feature/refresh-stale-forms branch from 88d4f3d to 30777a6 Compare April 25, 2024 17:55
@nmajor25 nmajor25 marked this pull request as ready for review April 25, 2024 17:55
@paulfalgout paulfalgout merged commit b259685 into develop Apr 25, 2024
5 checks passed
@paulfalgout paulfalgout deleted the feature/refresh-stale-forms branch April 25, 2024 18:10
Copy link
Contributor Author

@nmajor25 nmajor25 Apr 25, 2024

Choose a reason for hiding this comment

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

The test is designed to simulate a user having a form open in their browser that becomes "stale". And after 30 minutes of inactivity, we reload the form so the current state of the form is displayed to the user.

Test sequence:

  1. Load an empty form.
  2. Restart the form after 30 minutes of no changes (via cy.tick()). The form is reloaded with a new draft latest form response.
    • Simulating a form draft having been created in a different tab/window/session.
  3. Verify that the form loaded the latest form response data into the form.
  4. Restart the form after 30 more minutes of no changes (via cy.tick()). The form is reloaded with a new submitted form response.
    • Simulating a form draft having been submitted in a different tab/window/session.
  5. Verify that the form is now submitted. Content shown should be from the submitted form response and the submit button should be in the Update state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants