Skip to content

Commit 7aff140

Browse files
authored
Merge pull request #1284 from CruGlobal/8566-goal-warning
[MPDX-8566] Preference goal warnings
2 parents a1c8392 + 2b30e9b commit 7aff140

File tree

14 files changed

+834
-321
lines changed

14 files changed

+834
-321
lines changed

src/components/AccountLists/AccountLists.test.tsx

+58-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('AccountLists', () => {
7373
</ThemeProvider>,
7474
);
7575
expect(getByRole('link')).toHaveTextContent(
76-
'AccountGoal$1,000*Gifts Started60%Committed80%*Last updated Jan 1, 2024',
76+
'AccountGoal$1,000*Gifts Started60%Committed80%*Below machine-calculated goal',
7777
);
7878
});
7979

@@ -167,7 +167,7 @@ describe('AccountLists', () => {
167167
</ThemeProvider>,
168168
);
169169
expect(getByRole('link')).toHaveTextContent(
170-
'AccountGoal€2,000*Gifts Started-Committed-*machine-calculated',
170+
'AccountGifts Started-Committed-',
171171
);
172172
});
173173

@@ -211,4 +211,60 @@ describe('AccountLists', () => {
211211
expect(queryByText('Last updated Dec 30, 2019')).not.toBeInTheDocument();
212212
});
213213
});
214+
215+
describe('below machine-calculated warning', () => {
216+
it('is shown if goal is less than the machine-calculated goal', () => {
217+
const data = gqlMock<GetAccountListsQuery>(GetAccountListsDocument, {
218+
mocks: {
219+
accountLists: {
220+
nodes: [
221+
{
222+
currency: 'USD',
223+
monthlyGoal: 5000,
224+
healthIndicatorData: {
225+
machineCalculatedGoal: 10000,
226+
machineCalculatedGoalCurrency: 'USD',
227+
},
228+
},
229+
],
230+
},
231+
},
232+
});
233+
234+
const { getByText } = render(
235+
<ThemeProvider theme={theme}>
236+
<AccountLists data={data} />
237+
</ThemeProvider>,
238+
);
239+
expect(getByText('Below machine-calculated goal')).toBeInTheDocument();
240+
});
241+
242+
it('is hidden if goal is greater than or equal to the machine-calculated goal', async () => {
243+
const data = gqlMock<GetAccountListsQuery>(GetAccountListsDocument, {
244+
mocks: {
245+
accountLists: {
246+
nodes: [
247+
{
248+
currency: 'USD',
249+
monthlyGoal: 5000,
250+
healthIndicatorData: {
251+
machineCalculatedGoal: 5000,
252+
machineCalculatedGoalCurrency: 'USD',
253+
},
254+
},
255+
],
256+
},
257+
},
258+
});
259+
260+
const { queryByText } = render(
261+
<ThemeProvider theme={theme}>
262+
<AccountLists data={data} />
263+
</ThemeProvider>,
264+
);
265+
expect(
266+
queryByText('Below machine-calculated goal'),
267+
).not.toBeInTheDocument();
268+
});
269+
});
214270
});

0 commit comments

Comments
 (0)