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

fix: clear errors from invalid group email csv upload #1428

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

marlonkeating
Copy link
Contributor

Jira Ticket

This change makes it so that if an invalid email csv file is uploaded, the error will clear once a valid csv file is uploaded.

Testing Instructions

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.48%. Comparing base (d080f68) to head (47d9be2).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1428      +/-   ##
==========================================
+ Coverage   86.46%   86.48%   +0.01%     
==========================================
  Files         660      660              
  Lines       14921    14936      +15     
  Branches     3159     3106      -53     
==========================================
+ Hits        12902    12917      +15     
- Misses       1949     1952       +3     
+ Partials       70       67       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jesperhodge jesperhodge left a comment

Choose a reason for hiding this comment

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

This is great work. I left some tiny tiny comments but I'm approving it.

expect(screen.getByText('bademails.csv')).toBeInTheDocument();
expect(screen.getByText("Members can't be invited as entered.")).toBeInTheDocument();
expect(screen.getByText('iamnotanemail is not a valid email.')).toBeInTheDocument();
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 });
Copy link
Member

Choose a reason for hiding this comment

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

Can you try if this works as well? We want to run the tests as quickly as possible

Suggested change
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 });
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 20 });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While it worked (as in the test didn't fail when I ran it), we should be clear that the timeout value here is how long the test will look for the awaited conditions before failing, not how long it will wait in the case of a successful test. In a success case, the test will proceed as soon as the conditions are met.

As such, reducing the timeout value would only give us faster failures in the best case, but noisy tests that fail at random in the worst case, which is something I'd like to avoid.

Copy link
Member

Choose a reason for hiding this comment

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

@marlonkeating thanks, very good point. That's something I hadn't considered!

expect(screen.getByText('goodemails.csv')).toBeInTheDocument();
expect(screen.getByText('Summary (1)')).toBeInTheDocument();
expect(screen.getAllByText('[email protected]')).toHaveLength(2);
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 });
Copy link
Member

Choose a reason for hiding this comment

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

Could you try

Suggested change
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 });
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 20 });

@@ -348,6 +348,40 @@ describe('<CreateGroupModal />', () => {
expect(screen.getAllByText('[email protected]')).toHaveLength(2);
}, { timeout: EMAIL_ADDRESSES_INPUT_VALUE_DEBOUNCE_DELAY + 1000 });
});
it('uploads csv file with bad email, re-uploads csv file with good email', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

This test name is a good description of what the test does. Maybe we could improve it further by describing what the test expects? Something like should show an error message after csv upload with invalid emails, and not after re-upload with valid emails.

You may be interested in this ADR I wrote in another repo explaining why and how to write good test names. Incidentally, I intend to turn this into an OEP soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, there were some good suggestions in that ADR. I edited the names of the new tests in this PR to be more in line with your recommendations.

@marlonkeating marlonkeating merged commit 02cc629 into master Feb 18, 2025
6 checks passed
@marlonkeating marlonkeating deleted the mkeating/ENT-10024 branch February 18, 2025 23:34
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