Skip to content

Don't show spinner for a failed analysis#1809

Merged
robertbrignull merged 4 commits intomainfrom
robertbrignull/failed_analysis_spinner
Nov 30, 2022
Merged

Don't show spinner for a failed analysis#1809
robertbrignull merged 4 commits intomainfrom
robertbrignull/failed_analysis_spinner

Conversation

@robertbrignull
Copy link
Copy Markdown
Contributor

This PR avoids showing a spinning spinner when the variant analysis has in fact failed and won't make any more progress.

We're using the completedAt field to tell if the analysis is finished or not instead of the variant analysis status. This causes problems when the variant analysis failed to start a workflow because there were no repos to query. In this case it didn't get as far as creating a workflow run, and so there is no completedAt value. Possibly we should be setting completedAt in the API in this case, but we also can handle this in the extension.

Also, if we just show the non-spinner bit of this component then we start showing the "view logs" link in cases when we shouldn't be. For example when the variant analysis fails before it can start the actions workflow, e.g. if there are no repositories to query. So as part of this I'm also making the "view logs" link option and only populating it when there are logs to link to.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@robertbrignull robertbrignull requested a review from a team as a code owner November 29, 2022 15:07
@robertbrignull
Copy link
Copy Markdown
Contributor Author

I briefly forgot tests exist, but I'll try to write some that cover this.

@robertbrignull
Copy link
Copy Markdown
Contributor Author

Here's some tests. If you think the level of detail in the details is too high or low feel free to say.

Comment on lines +30 to +34
expect(
container.getElementsByClassName(
"codicon codicon-loading codicon-modifier-spin",
).length,
).toEqual(1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think toBeInTheDocument is sufficient for this, I don't think we need to explicitly test that we only have 1 element.

Should we also make the Icon more accessible by adding some alt text so we can use screen.getByRole instead? I'm not sure that should be part of this PR though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Definitely can do. I still need to access the first element of the array, but that works.

I don't have strong preferences about the icon. It was a bit annoying having to use this method to find the element, and it could be a bit fragile if we change the classes on the spinner. But also adding user-visible text to support the tests sounds a bit off too, perhaps. I think I'll leave it be for this PR at least.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Definitely, I don't think we'd need to add user-visible text, but more something along the lines of this where we're adding an aria-label so screen readers understand it. We could potentially even use the Codicon component, although I'm not sure why that hadn't been done originally here. I suspect it's because of the font-size: 1em, but we'd need to test that theory.

@robertbrignull robertbrignull merged commit 125867d into main Nov 30, 2022
@robertbrignull robertbrignull deleted the robertbrignull/failed_analysis_spinner branch November 30, 2022 17:19
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.

2 participants