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

Warning modal for creating duplicate test plan runs #901

Merged
merged 10 commits into from
Feb 15, 2024

Conversation

Paul-Clue
Copy link
Collaborator

@Paul-Clue Paul-Clue commented Jan 25, 2024

see issue #870

This PR is creates a modal that issues a warning to a user that is trying to add a new test plan run to the test queue with the same AT / browser combination and is the same version of an already completed test plan run. The modal warns the user that by creating a duplicate test plan run, the finalized test plan with results will be removed from the results page.

This behavior (completed test results being removed form the results page) is no longer acceptable, according to the issue. This PR serves as a temporary solution for the main issue at hand.


@Paul-Clue Paul-Clue requested a review from howard-e January 25, 2024 20:15
@Paul-Clue Paul-Clue requested a review from evmiguel January 25, 2024 20:16
@ccanash ccanash requested review from jugglinmike and removed request for evmiguel February 13, 2024 17:49
return (
<BasicModal
show={errorMessage}
title={'Conflicting Report Found'}
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to use interpolation for static values.

Suggested change
title={'Conflicting Report Found'}
title='Conflicting Report Found'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. Done.

Comment on lines 141 to 143
content={
'The report could not be created because an existing report was found on the reports page with the same AT, browser and test plan version. Would you like to return the existing report back to the test queue?'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The project doesn't enforce a maximum line length, but it appears to (mostly) split strings at the 100-column boundary. @howard-e @alflennik @stalgiag is there any consensus on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's certainly been mentioned a few times now, in GitHub threads and in sync discussions. I've created an issue to now track that discussion, #924.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey we found out that the project formats code at column 80. I split the strings there.

if (hasAutomationSupport) {
setShowConfirmation(true);
const conflictingReportExists =
existingTestPlanReports.some(report => {
Copy link
Contributor

Choose a reason for hiding this comment

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

existingTestPlanReports is potentially falsey, so we should use optional chaining here, too. It might also be good to perform this calculation outside the handler just like we do for hasAutomationSupport.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok done!

'browser and test plan version. Would you like to return ' +
'the existing report back to the test queue?'
}
closeLabel={'Cancel'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
closeLabel={'Cancel'}
closeLabel="Cancel"

@jugglinmike
Copy link
Contributor

Thanks, @Paul-Clue! Would you mind taking a look at the test failures?

@Paul-Clue
Copy link
Collaborator Author

Hey, @jugglinmike, The tests were failing because I moved the conflictingReportExists calculation outside of the handler. Inside the calculation, at.id is being referenced but it seems that at does not have a value until an AT is selected in the app. So I put the calculation back.

@jugglinmike
Copy link
Contributor

That explains why the getBotUsernameFromAtBrowser utility function uses optional chaining when it dereferences at (and browser). We should use optional chaining in this new code, as well!

If we address the "undefined requirements" case only by relocating the calculation to the event handler, then there's a risk that the code still manages to run before the value is available (possibly due to some uncommon network delay, for instance). Also, implicitly relying on the delay represents a refactoring hazard for future contributors. (What I mean by this is that I think folks would be justified if they assumes that the new logic would be safe to relocate anywhere in the component. We know that assumption is false because we're in the thick of it, but if that future contributor acted on their assumption, they could unknowingly introduce a bug.)

And to that latter concern, if we use optional chaining, then the new code will be safe to use anywhere in the component. That means we could place it up near the top like before, after all. I can think of a couple reasons why that's still desirable:

  • It makes the source more consistent (in that we have all the complicated formulas in one section of the component and all the rendering code in another)
  • It makes the code more readable (for the same reason as above)

If you want to get fancy, you could also wrap this calculation in a call to useMemo so that we don't needlessly recompute the same value every time the component is rendered.

@Paul-Clue
Copy link
Collaborator Author

Hey, @jugglinmike, I missed that I can add optional chaining to the at and browser variables as well. Thank you for pointing that out to me.

Copy link
Contributor

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

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

Looking good, @Paul-Clue--nice work!

@jugglinmike jugglinmike merged commit 7ff07b0 into main Feb 15, 2024
2 checks passed
@jugglinmike jugglinmike deleted the test-queue-error-dialog branch February 15, 2024 18: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.

4 participants