Skip to content

Commit

Permalink
Updating everywhere else that needs to use userId from userPreference…
Browse files Browse the repository at this point in the history
…sContext
  • Loading branch information
dr-bizz committed Jun 7, 2024
1 parent 417bab1 commit 788f667
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { ThemeProvider } from '@mui/material/styles';
import { render, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { SnackbarProvider } from 'notistack';
import { session } from '__tests__/fixtures/session';
import TestRouter from '__tests__/util/TestRouter';
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
import { UserPreferenceContext } from 'src/components/User/Preferences/UserPreferenceProvider';
import theme from 'src/theme';
import { EarlyAdopterAccordion } from './EarlyAdopterAccordion';

Expand Down Expand Up @@ -35,18 +35,20 @@ interface ComponentsProps {
tester: boolean;
expandedPanel: string;
}

const userId = 'userID123';
const Components: React.FC<ComponentsProps> = ({ tester, expandedPanel }) => (
<SnackbarProvider>
<TestRouter router={router}>
<ThemeProvider theme={theme}>
<GqlMockedProvider onCall={mutationSpy}>
<EarlyAdopterAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
tester={tester}
accountListId={accountListId}
/>
<UserPreferenceContext.Provider value={{ userId, locale: 'en-US' }}>
<EarlyAdopterAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
tester={tester}
accountListId={accountListId}
/>
</UserPreferenceContext.Provider>
</GqlMockedProvider>
</ThemeProvider>
</TestRouter>
Expand Down Expand Up @@ -161,7 +163,7 @@ describe('EarlyAdopterAccordion', () => {
);

expect(window.location.href).toEqual(
`${process.env.SITE_URL}/api/handoff?accountListId=${accountListId}&userId=${session.user.userID}&path=%2Fpreferences%2Fpersonal`,
`${process.env.SITE_URL}/api/handoff?accountListId=${accountListId}&userId=${userId}&path=%2Fpreferences%2Fpersonal`,
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as yup from 'yup';
import { AccordionItem } from 'src/components/Shared/Forms/Accordions/AccordionItem';
import { FieldWrapper } from 'src/components/Shared/Forms/FieldWrapper';
import { FormWrapper } from 'src/components/Shared/Forms/FormWrapper';
import { useUserPreferenceContext } from 'src/components/User/Preferences/UserPreferenceProvider';
import { AccountListSettingsInput } from 'src/graphql/types.generated';
import useGetAppSettings from 'src/hooks/useGetAppSettings';
import { useRequiredSession } from 'src/hooks/useRequiredSession';
import { useUpdateAccountPreferencesMutation } from '../UpdateAccountPreferences.generated';

const accountPreferencesSchema: yup.SchemaOf<
Expand All @@ -32,7 +32,7 @@ export const EarlyAdopterAccordion: React.FC<EarlyAdopterAccordionProps> = ({
accountListId,
}) => {
const { t } = useTranslation();
const { userID } = useRequiredSession();
const { userId } = useUserPreferenceContext();
const { appName } = useGetAppSettings();
const { enqueueSnackbar } = useSnackbar();
const [updateAccountPreferences] = useUpdateAccountPreferencesMutation();
Expand Down Expand Up @@ -69,7 +69,7 @@ export const EarlyAdopterAccordion: React.FC<EarlyAdopterAccordionProps> = ({
`${process.env.SITE_URL || window.location.origin}/api/handoff`,
);
url.searchParams.append('accountListId', accountListId ?? '');
url.searchParams.append('userId', userID);
url.searchParams.append('userId', userId ?? '');
url.searchParams.append('path', '/preferences/personal');

window.location.href = url.toString();
Expand Down

0 comments on commit 788f667

Please sign in to comment.