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

662/asterner profile tests #673

Merged
merged 12 commits into from
Aug 30, 2024
Merged

Conversation

AJSterner
Copy link
Contributor

@AJSterner AJSterner commented Aug 28, 2024

This PR:

Resolves (part of) #662

1. Adds basic render tests for the Profile page
2. Adds tests to check basic functionality for the Profile page
3. Factors out a MockSignedInUserContext to allow multiple tests to access user profiles

Future Steps:

We should figure out why there's a second timeout before loading the full profile page...

PASS/src/pages/Profile.jsx

Lines 114 to 128 in 52c881f

useEffect(() => {
setTimeout(() => {
setLoadingProfile(false);
}, 1000);
}, []);
const truncatedText = selectedDocToDelete?.name ? truncateText(selectedDocToDelete.name) : '';
if (loadingProfile) {
return (
<LoadingAnimation loadingItem="Profile">
<CircularProgress />
</LoadingAnimation>
);
}

@AJSterner AJSterner marked this pull request as draft August 28, 2024 16:57
@@ -145,7 +145,9 @@ const Profile = () => {
width: isSmallScreen ? '100%' : 'auto'
}}
>
<Typography sx={{ fontWeight: 'bold', fontSize: '18px' }}>My Profile</Typography>
<Typography variant="h1" sx={{ fontWeight: 'bold', fontSize: '18px' }}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change makes this text into a proper heading without modifying the visual rendering

Copy link
Member

Choose a reason for hiding this comment

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

Looking over it, I'm not certain whether we need it to say "My Profile" at the top at all. The breadcrumb basically covers the same role already and we don't really apply this same concept to other pages (such as the Contacts page). But that's a different discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I attempted to make minimal changes to the page itself. This seems like something we can take a look at post MVP.

@AJSterner AJSterner force-pushed the 662/asterner-profile-tests branch 2 times, most recently from 1005f5b to 3d9658e Compare August 28, 2024 17:41
@AJSterner AJSterner marked this pull request as ready for review August 28, 2024 17:57
@AJSterner AJSterner mentioned this pull request Aug 28, 2024
12 tasks
@AJSterner AJSterner force-pushed the 662/asterner-profile-tests branch from b824b66 to 1f8628a Compare August 28, 2024 18:26
Copy link
Member

@andycwilliams andycwilliams left a comment

Choose a reason for hiding this comment

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

A couple of minor edits I'd like but it's looking good to me

@@ -145,7 +145,9 @@ const Profile = () => {
width: isSmallScreen ? '100%' : 'auto'
}}
>
<Typography sx={{ fontWeight: 'bold', fontSize: '18px' }}>My Profile</Typography>
<Typography variant="h1" sx={{ fontWeight: 'bold', fontSize: '18px' }}>
Copy link
Member

Choose a reason for hiding this comment

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

Looking over it, I'm not certain whether we need it to say "My Profile" at the top at all. The breadcrumb basically covers the same role already and we don't really apply this same concept to other pages (such as the Contacts page). But that's a different discussion

import { render, screen, cleanup, waitForElementToBeRemoved } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, beforeEach, afterEach } from 'vitest';

Copy link
Member

Choose a reason for hiding this comment

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

Can delete these extra lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

import { vi } from 'vitest';
import { SignedInUserContext } from '@contexts';
import * as profileHelper from '../../../src/model-helpers/Profile';

Copy link
Member

Choose a reason for hiding this comment

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

If we're going to keep this, we can leave a TODO note here to import it elsewhere. I'm pretty sure there are other tests that can make use of this but not as part of this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would you like to add as a TODO?

I don't see the SignedInUserContext used in other tests (other than the tests for the context itself).

Copy link
Member

Choose a reason for hiding this comment

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

I'll put a pin in that idea. I want to think it over more

Copy link
Member

@andycwilliams andycwilliams left a comment

Choose a reason for hiding this comment

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

There's one extra line that can be removed but approving anyway.

Also would like @leekahung to give this a once-over just to be extra safe

import { vi } from 'vitest';
import { SignedInUserContext } from '@contexts';
import * as profileHelper from '../../../src/model-helpers/Profile';

Copy link
Member

Choose a reason for hiding this comment

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

I'll put a pin in that idea. I want to think it over more

test/components/Profile/ProfileComponent.test.jsx Outdated Show resolved Hide resolved
@AJSterner
Copy link
Contributor Author

There's one extra line that can be removed but approving anyway.

Also would like @leekahung to give this a once-over just to be extra safe

Sweet! I'll wait for feedback from @leekahung

Copy link
Contributor

@leekahung leekahung left a comment

Choose a reason for hiding this comment

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

Just a comment on the mock context, but it's a positive one. I can approve this. 👍

@@ -0,0 +1,32 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

I see we're making mock contexts for the tests. I'm fine with this since it'll be useful in case multiple tests need the same context.

@AJSterner AJSterner merged commit fb5f35d into Development Aug 30, 2024
3 checks passed
@AJSterner
Copy link
Contributor Author

Awesome! Thanks y'all :) merged!

@AJSterner AJSterner deleted the 662/asterner-profile-tests branch August 30, 2024 04:32
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.

3 participants