chromaui / addon-visual-tests

Visual Tests addon for Storybook
MIT License
33 stars 2 forks source link

Reviewing: Rerun query when accepting & un-accepting changes #86

Closed ndelangen closed 1 year ago

ndelangen commented 1 year ago

What I did

As per @tmeasday's suggestion: I added a call to rerun() to the onAccept & onUnaccept callbacks making mutation

How to test

linear[bot] commented 1 year ago
AP-3637 Accept/unaccept buttons don't immediately update after update

They only update when we've polled for new data. The mutation should trigger a rerun of the query.

ndelangen commented 1 year ago

Hmmm.. I'm not sure.. it seems like there should also really be some sort of loading indicator? @ghengeveld How do you feel we should solve this?

tmeasday commented 1 year ago

it seems like there should also really be some sort of loading indicator?

There is a loading indicator, it appears while the mutation is running. It just doesn't show up while the rerun query is running, so you see "Accept" again for a moment.

I'm happy to move on for now and reconsider these UX nuances later for sure, btw. But to do what we want here I think we'd do something like:

const [isReviewing, setIsReviewing] = useState(false);
onAccepting = async () => {
  try {
    setIsReviewing(true);
    await reviewTest(...)

    await rerun();
  } finally {
    setIsReviewing(false);
  }
}

So not super complicated IMO.

ndelangen commented 1 year ago

@tmeasday when I added rerun() I wondered if I should await it.. and I decided it should not, because rerun (according to types) is not an async function.