Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,24 @@
"(Quarter)": "(Quarter)",
"(Sent by {{firstName}} {{lastName}})": "(Sent by {{firstName}} {{lastName}})",
"(Year)": "(Year)",
"Change history": "Change history",
"Confirm addresses": "Confirm addresses",
"Dismiss": "Dismiss",
"MPDX started saving who made each change in Nov 2026. Changes made in MPDX before then don't have a name.": "MPDX started saving who made each change in Nov 2026. Changes made in MPDX before then don't have a name.",
"No address changes for \"{{search}}\"": "No address changes for \"{{search}}\"",
"No address changes for \"{{search}}\" in the last 12 months": "No address changes for \"{{search}}\" in the last 12 months",
"No address changes for \"{{search}}\" in the last 3 months": "No address changes for \"{{search}}\" in the last 3 months",
"No address changes for \"{{search}}\" in the last 6 months": "No address changes for \"{{search}}\" in the last 6 months",
"No address changes for \"{{search}}\" in the selected dates": "No address changes for \"{{search}}\" in the selected dates",
"Partner name or address": "Partner name or address",
"Pick each partner's primary address.": "Pick each partner's primary address.",
"Primary email (current)": "Primary email (current)",
"Primary phone (current)": "Primary phone (current)",
"Review your goal, see how to present it to partners, and read your next steps. We also emailed you the full worksheet as a PDF.": "Review your goal, see how to present it to partners, and read your next steps. We also emailed you the full worksheet as a PDF.",
"Search all dates": "Search all dates",
"See what changed, when, and by whom.": "See what changed, when, and by whom.",
"There may be older changes, or the partner may not match your other filters.": "There may be older changes, or the partner may not match your other filters.",
"Try a different search, or clear your filters.": "Try a different search, or clear your filters.",
"View my MPD goal": "View my MPD goal",
"Your goal changed since you last looked. Review the updated worksheet, which was also emailed to you as a PDF.": "Your goal changed since you last looked. Review the updated worksheet, which was also emailed to you as a PDF.",
"Your MPD goal is ready": "Your MPD goal is ready",
Expand Down Expand Up @@ -258,6 +274,8 @@
"{{count}} Selected_other": "{{count}} Selected",
"{{count}} staff_one": "{{count}} staff",
"{{count}} staff_other": "{{count}} staff",
"{{count}} to confirm_one": "{{count}} to confirm",
"{{count}} to confirm_other": "{{count}} to confirm",
"{{count}} were automatic_one": "{{count}} was automatic",
"{{count}} were automatic_other": "{{count}} were automatic",
"{{count}} years_one": "{{count}} years",
Expand Down Expand Up @@ -855,7 +873,6 @@
"Chalk Line is a significant way to save valuable ministry time while more effectively\n connecting with your partners. Send physical newsletters to your current list using\n Chalk Line with a simple click. Chalk Line is a one way send available anytime you’re\n ready to send a new newsletter out.": "Chalk Line is a significant way to save valuable ministry time while more effectively\n connecting with your partners. Send physical newsletters to your current list using\n Chalk Line with a simple click. Chalk Line is a one way send available anytime you’re\n ready to send a new newsletter out.",
"Chalk Line Overview": "Chalk Line Overview",
"Change Coach": "Change Coach",
"Change History": "Change History",
"Change made by": "Change made by",
"Change the contact's status to: <bold>{{status}}</bold>": "Change the contact's status to: <bold>{{status}}</bold>",
"Change the Geographic Multiplier in the staff member's details to recalculate it. Interns, part-time field staff and volunteers have no New Staff Monthly Salary, so they have no Geographic Multiplier to change.": "Change the Geographic Multiplier in the staff member's details to recalculate it. Interns, part-time field staff and volunteers have no New Staff Monthly Salary, so they have no Geographic Multiplier to change.",
Expand Down Expand Up @@ -3501,7 +3518,6 @@
"To be Developed: {{amount}}": "To be Developed: {{amount}}",
"To change this amount, update the Reimbursable Expenses step": "To change this amount, update the Reimbursable Expenses step",
"to check it out and get started saving for future needs!": "to check it out and get started saving for future needs!",
"To Confirm": "To Confirm",
"To Do This Week": "To Do This Week",
"To get started, we're going to walk with you through a few key steps to set you up for success in {{appName}}!": "To get started, we're going to walk with you through a few key steps to set you up for success in {{appName}}!",
"To import your TntConnect database, go to Import from TntConnect": "To import your TntConnect database, go to Import from TntConnect",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en/translation_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"Cannot upload file: file size cannot exceed 1MB": "Cannot upload file: file size cannot exceed 1MB",
"Cell phone number is required": "Cell phone number is required",
"Change": "Change",
"Change History": "Change History",
"Change the Geographic Multiplier in the staff member's details to recalculate it.": "Change the Geographic Multiplier in the staff member's details to recalculate it.",
"Check": "Check",
"Clear Filters": "Clear Filters",
Expand Down Expand Up @@ -559,6 +560,7 @@
"This updated request will take the place of your previous request. Once submitted, you can return and make edits until {{date}}. After this date, your request will be processed as is.": "This updated request will take the place of your previous request. Once submitted, you can return and make edits until {{date}}. After this date, your request will be processed as is.",
"This will log you in on behalf of the user specified below. You will be able to see what the user sees on {{appName}}.\n Impersonation sessions have 20 minute timeout where you will automatically be logged out of the user's account after\n the specified amount of time. Once you are finished impersonating, click 'Exit Impersonation Mode' at the top of the\n page.": "This will log you in on behalf of the user specified below. You will be able to see what the user sees on {{appName}}.\n Impersonation sessions have 20 minute timeout where you will automatically be logged out of the user's account after\n the specified amount of time. Once you are finished impersonating, click 'Exit Impersonation Mode' at the top of the\n page.",
"This Year": "This Year",
"To Confirm": "To Confirm",
"To Do": "To Do",
"To set a one-time savings goal, click \"Add One-time Goal\" to create a new row in the goal table. In the left cell of the new row, enter the name of your goal—for example, \"Car.\" Then, in the right cell, enter the full dollar amount you need to raise, such as 15000.": "To set a one-time savings goal, click \"Add One-time Goal\" to create a new row in the goal table. In the left cell of the new row, enter the name of your goal—for example, \"Car.\" Then, in the right cell, enter the full dollar amount you need to raise, such as 15000.",
"TO_DO": "To Do",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { ThemeProvider } from '@mui/material/styles';
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { ContactFilterChangedDuringEnum } from 'src/components/Shared/Filters/ChangedDuring/changedDuring';
import theme from 'src/theme';
import { AddressChangeSearchEmptyState } from './AddressChangeSearchEmptyState';

const onSearchAllDates = jest.fn();
const onClearFilters = jest.fn();

const renderEmptyState = (
changedDuring: ContactFilterChangedDuringEnum | null,
) =>
render(
<ThemeProvider theme={theme}>
<AddressChangeSearchEmptyState
search="Smith"
changedDuring={changedDuring}
onSearchAllDates={onSearchAllDates}
onClearFilters={onClearFilters}
/>
</ThemeProvider>,
);

describe('AddressChangeSearchEmptyState', () => {
it.each([
[ContactFilterChangedDuringEnum.Last3Months, 'in the last 3 months'],
[ContactFilterChangedDuringEnum.Last6Months, 'in the last 6 months'],
[ContactFilterChangedDuringEnum.Last12Months, 'in the last 12 months'],
[ContactFilterChangedDuringEnum.Custom, 'in the selected dates'],
])('names the search and the %s range', (changedDuring, range) => {
const { getByRole, getByText } = renderEmptyState(changedDuring);

expect(
getByRole('heading', { name: `No address changes for "Smith" ${range}` }),
).toBeInTheDocument();
expect(
getByText(
'There may be older changes, or the partner may not match your other filters.',
),
).toBeInTheDocument();
});

it('is announced to screen readers', () => {
const { getByTestId } = renderEmptyState(
ContactFilterChangedDuringEnum.Last12Months,
);

expect(getByTestId('address-changes-null-state')).toHaveAttribute(
'role',
'status',
);
});

it('searches all dates or clears the filters', () => {
const { getByRole } = renderEmptyState(
ContactFilterChangedDuringEnum.Last12Months,
);

userEvent.click(getByRole('button', { name: 'Search all dates' }));
expect(onSearchAllDates).toHaveBeenCalled();

userEvent.click(getByRole('button', { name: 'Clear filters' }));
expect(onClearFilters).toHaveBeenCalled();
});

it('hides Search all dates when the range is already any time', () => {
const { getByRole, queryByRole, getByText } = renderEmptyState(null);

expect(
getByRole('heading', { name: 'No address changes for "Smith"' }),
).toBeInTheDocument();
expect(
getByText('Try a different search, or clear your filters.'),
).toBeInTheDocument();
expect(
queryByRole('button', { name: 'Search all dates' }),
).not.toBeInTheDocument();
expect(getByRole('button', { name: 'Clear filters' })).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import SearchIcon from '@mui/icons-material/Search';
import { Box, Button, Typography } from '@mui/material';
import { TFunction, useTranslation } from 'react-i18next';
import { ContactFilterChangedDuringEnum } from 'src/components/Shared/Filters/ChangedDuring/changedDuring';
import { NullStateBox } from 'src/components/Shared/Filters/NullState/NullStateBox';

const getTitle = (
search: string,
changedDuring: ContactFilterChangedDuringEnum | null,
t: TFunction,
): string => {
if (!changedDuring) {
return t('No address changes for "{{search}}"', { search });
}
const titles: Record<ContactFilterChangedDuringEnum, string> = {
[ContactFilterChangedDuringEnum.Last3Months]: t(
'No address changes for "{{search}}" in the last 3 months',
{ search },
),
[ContactFilterChangedDuringEnum.Last6Months]: t(
'No address changes for "{{search}}" in the last 6 months',
{ search },
),
[ContactFilterChangedDuringEnum.Last12Months]: t(
'No address changes for "{{search}}" in the last 12 months',
{ search },
),
[ContactFilterChangedDuringEnum.Custom]: t(
'No address changes for "{{search}}" in the selected dates',
{ search },
),
};
return titles[changedDuring];
};

interface AddressChangeSearchEmptyStateProps {
search: string;
changedDuring: ContactFilterChangedDuringEnum | null;
onSearchAllDates: () => void;
onClearFilters: () => void;
}

export const AddressChangeSearchEmptyState: React.FC<
AddressChangeSearchEmptyStateProps
> = ({ search, changedDuring, onSearchAllDates, onClearFilters }) => {
const { t } = useTranslation();

return (
<NullStateBox data-testid="address-changes-null-state" role="status">
<SearchIcon fontSize="large" />
<Typography variant="h5" component="h2">
{getTitle(search, changedDuring, t)}
</Typography>
<Typography my={1}>
{changedDuring
? t(
'There may be older changes, or the partner may not match your other filters.',
)
: t('Try a different search, or clear your filters.')}
</Typography>
<Box display="flex" flexWrap="wrap" justifyContent="center" gap={1.5}>
{changedDuring && (
<Button variant="contained" onClick={onSearchAllDates}>
{t('Search all dates')}
</Button>
)}
<Button onClick={onClearFilters}>{t('Clear filters')}</Button>
</Box>
</NullStateBox>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query AddressChangeHistory(
$startDate: ISO8601Date
$endDate: ISO8601Date
$madeBy: [ID!]
$search: String
) {
addressChangeHistory(
accountListId: $accountListId
Expand All @@ -14,13 +15,16 @@ query AddressChangeHistory(
startDate: $startDate
endDate: $endDate
madeBy: $madeBy
search: $search
) {
nodes {
id
contactId
partnerName
partnerStatus
donorAccountNumbers
partnerPhone
partnerEmail
street
city
state
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { ThemeProvider } from '@mui/material/styles';
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterLuxon } from '@mui/x-date-pickers/AdapterLuxon';
import { render, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
import { ContactFilterPartnerEnum } from 'src/graphql/types.generated';
import theme from 'src/theme';
import {
currentUserId,
mockAddressChangeHistory,
} from '../ChangeHistoryAddressesMock';
import { AddressFilters } from './AddressFilters';

const onSearchChange = jest.fn();

const TestComponent: React.FC<{ search?: string }> = ({ search = '' }) => (
<ThemeProvider theme={theme}>
<LocalizationProvider dateAdapter={AdapterLuxon} adapterLocale="en-US">
<GqlMockedProvider mocks={{ GetUser: { user: { id: currentUserId } } }}>
<AddressFilters
search={search}
onSearchChange={onSearchChange}
partners={ContactFilterPartnerEnum.GaveOneOrMore}
onPartnersChange={jest.fn()}
changedDuring={null}
onChangedDuringChange={jest.fn()}
dateRange={null}
onDateRangeChange={jest.fn()}
madeBy={null}
madeByOptions={mockAddressChangeHistory.madeByOptions}
onMadeByChange={jest.fn()}
/>
</GqlMockedProvider>
</LocalizationProvider>
</ThemeProvider>
);

const notRecordedHelp =
"MPDX started saving who made each change in Nov 2026. Changes made in MPDX before then don't have a name.";

describe('AddressFilters', () => {
it('puts the search field first', () => {
const { getByRole, container } = render(<TestComponent />);

const search = getByRole('searchbox', { name: 'Search' });
expect(search).toHaveAttribute('placeholder', 'Partner name or address');
expect(container.querySelector('input, [role="combobox"]')).toBe(search);
});

it('reports what is typed in the search field', () => {
const { getByRole } = render(<TestComponent />);

userEvent.type(getByRole('searchbox', { name: 'Search' }), 'S');

expect(onSearchChange).toHaveBeenLastCalledWith('S');
});

it('shows the current search', () => {
const { getByRole } = render(<TestComponent search="Smith" />);

expect(getByRole('searchbox', { name: 'Search' })).toHaveValue('Smith');
});

it('explains "Not recorded" in a tooltip on hover', async () => {
const { getByRole, findByRole } = render(<TestComponent />);

userEvent.click(getByRole('combobox', { name: 'Change made by' }));
// Found by text: while the tooltip is closed, MUI copies its text into the option's title
const option = within(await findByRole('listbox'))
.getByText('Not recorded (before Nov 2026)')
.closest('li');
expect(option).toHaveAttribute('role', 'option');
userEvent.hover(option!);

const tooltip = await findByRole('tooltip');
expect(tooltip).toHaveTextContent(notRecordedHelp);
expect(option).toHaveAttribute('aria-describedby', tooltip.id);
});

it('explains "Not recorded" in a tooltip on keyboard focus', async () => {
// jsdom has no :focus-visible, so MUI's Tooltip would never open on focus.
// Treat the focused element as focus-visible, as a browser does for keyboard focus.
const matches = Element.prototype.matches;
const matchesSpy = jest
.spyOn(Element.prototype, 'matches')
.mockImplementation(function (this: Element, selector: string) {
return selector === ':focus-visible'
? this === document.activeElement
: matches.call(this, selector);
});
try {
const { getByRole, findByRole } = render(<TestComponent />);

userEvent.click(getByRole('combobox', { name: 'Change made by' }));
await findByRole('listbox');
userEvent.keyboard('{end}');

expect(await findByRole('tooltip')).toHaveTextContent(notRecordedHelp);
} finally {
matchesSpy.mockRestore();
}
});

it('keeps the other choices free of the tooltip', async () => {
const { getByRole, findByRole, queryByRole } = render(<TestComponent />);

userEvent.click(getByRole('combobox', { name: 'Change made by' }));
userEvent.hover(
within(await findByRole('listbox')).getByRole('option', {
name: 'Jane Smith',
}),
);

expect(queryByRole('tooltip')).not.toBeInTheDocument();
});
});
Loading
Loading