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

Reusable proptypes #1189

Merged
merged 13 commits into from
Aug 8, 2024
Merged

Reusable proptypes #1189

merged 13 commits into from
Aug 8, 2024

Conversation

stalgiag
Copy link
Contributor

@stalgiag stalgiag commented Aug 1, 2024

This PR introduces reusable PropTypes. The proptypes are largely a mirror of the existing GraphQL query fragments. A few additional proptypes were added for situations with relatively complex PropType.shapes.

To ensure that the PropTypes are honored and that no additional console errors are introduced by changes, I added a console error checker to the first load of pages during e2e testing.

Copy link
Contributor

@howard-e howard-e 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 and certainly a plus for how we create and hydrate components!

I've left an additional comment on the new console check utility.

* @param {number} [timeout=500] - Timeout in milliseconds to wait for errors
* @returns {Promise<string[]>} - Array of error messages, if any
*/
async function checkConsoleErrors(page, action, timeout = 500) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is super useful! This definitely gives a lot of confidence!

page,
introductionHeadingSelector
);
const errors = await checkConsoleErrors(page, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great but I think it has a chance to miss errors on certain element checks or with how the page element is being loaded. In this instance, errors could happen after the "Introduction" text has loaded which is what I'm guessing is happening in the following screenshot. There is a prop error not being caught on the DataManagement page:

screenshot showing error with prop being passed to DataManagementRow

I'm thinking the page.on('console') listener could be done in getPage and passed into the callback the same way the browser and baseUrl and checked in that way

@@ -0,0 +1,322 @@
import PropTypes from 'prop-types';
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, huge plus for putting this together and making all those changes. No more having to figure out how to account for certain structures :).

Also appreciate the care taken for identifying what should be required per prop type.

@stalgiag
Copy link
Contributor Author

stalgiag commented Aug 6, 2024

Thanks for the suggestion on how to handle the error tracking in e2e. It worked like a charm and is much cleaner!

Interestingly it also uncovered an error that comes up on the reports page, "Failed to load resource: the server responded with a status of 404 (Not Found)". This only happens on CI. This likely existed previously but wasn't being checked. I can try to figure out what resource it is referring to tomorrow.

@stalgiag
Copy link
Contributor Author

stalgiag commented Aug 6, 2024

Thanks for the suggestion on how to handle the error tracking in e2e. It worked like a charm and is much cleaner!

Interestingly it also uncovered an error that comes up on the reports page, "Failed to load resource: the server responded with a status of 404 (Not Found)". This only happens on CI. This likely existed previously but wasn't being checked. I can try to figure out what resource it is referring to tomorrow.

I ended up adding a tag for a placeholder favicon so that the browser doesn't try to find a favicon by default. Used this solution.

Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

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

Super excited about the increased organization and deduplication something like this change brings. Thanks for putting this together and addressing my feedback!

@@ -5,6 +5,7 @@
<meta name="google" content="notranslate">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/index.css">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting find!

@howard-e
Copy link
Contributor

howard-e commented Aug 6, 2024

@stalgiag there's a new conflict here after merging #1188. Feel free to update and merge once resolved

@stalgiag stalgiag merged commit b0d91ba into development Aug 8, 2024
2 checks passed
@stalgiag stalgiag deleted the proptype-fragments branch August 8, 2024 16:28
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