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

Add the progressDelay task start option #7003

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

peterhudec
Copy link
Contributor

Description of change

This PR adds the progressDelay option to starting a task, which delays the transition of a task to its progress state by the number of milliseconds the option was set to. The default value is 100ms. This is to prevent progress indicator to be display for a fraction of a seconds for tasks that resolve very quickly or immediately.

Test instructions

  1. Add a task to the Provider which resolves in 1 second
    const Provider = createProvider({
      foo: () => new Promise(resolve => setTimeout(resolve, 1000, 'RESULT')),
      // ...other tasks
    })
  2. Call the task with progressDelay set to both shorter and longer than 1 second
    <Task>
      {(t) => (
        <>
          <button
            onClick={() => t('foo', 'shouldSeeProgress').start({
              payload: 123,
              progressDelay: 800,
            })}
          >
            Start with progress delay 800ms
          </button>
          <button
            onClick={() => t('foo', 'shouldNotSeeProgress').start({
              payload: 123,
              progressDelay: 1200,
            })}
          >
            Start with progress delay 1200ms
          </button>
          <pre>{JSON.stringify({
            shouldSeeProgress: t('foo', 'shouldSeeProgress'),
            shouldNotSeeProgress: t('foo', 'shouldNotSeeProgress'),
          }, null, 2)}</pre>
        </>
      )}
    </Task>
  3. The task started with progressDelay: 800 should be in progress state for 200ms
  4. The task started with progressDelay: 1200 should never get to progress state

Screenshots

This should not affect how the application works, except that tasks which resolve in less than 100ms there should be no progress indicator visible.

@peterhudec peterhudec changed the base branch from govuk-paas-deploy to main July 25, 2024 15:09
@peterhudec peterhudec force-pushed the feat/deferred-task-progress branch from 7fe27e1 to 24cc027 Compare July 25, 2024 15:10
Copy link

cypress bot commented Jul 25, 2024



Test summary

15 0 0 0


Run details

Project data-hub-frontend
Status Passed
Commit b59bc6e
Started Aug 7, 2024 9:11 AM
Ended Aug 7, 2024 9:12 AM
Duration 01:44 💡
OS Linux Debian -
Browser Chrome 121

View run in Cypress Cloud ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

@peterhudec peterhudec force-pushed the feat/deferred-task-progress branch from 24cc027 to 6d5b1bc Compare July 26, 2024 15:48
@cgsunkel cgsunkel requested review from a team and removed request for marijnkampf, p3dr0migue1, bau123, DeanElliott96 and cgsunkel July 30, 2024 13:12
@paulgain paulgain force-pushed the feat/deferred-task-progress branch from 6d5b1bc to b59bc6e Compare August 7, 2024 09:04
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.

1 participant