@swan-io/shared-business 18.5.0 → 18.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/components/BirthdatePicker.d.ts +3 -1
- package/src/components/BirthdatePicker.js +2 -2
- package/src/components/FileInput.js +25 -10
- package/src/components/FileTile.d.ts +4 -3
- package/src/components/FileTile.js +14 -7
- package/src/components/FilesUploader.js +12 -4
- package/src/components/FraudReport/CardDetailsStep.d.ts +7 -0
- package/src/components/FraudReport/CardDetailsStep.js +46 -0
- package/src/components/FraudReport/DocumentsStep.d.ts +13 -0
- package/src/components/FraudReport/DocumentsStep.js +49 -0
- package/src/components/FraudReport/FraudReportLayout.d.ts +2 -1
- package/src/components/FraudReport/FraudReportLayout.js +2 -2
- package/src/components/FraudReport/FraudsterDetailsStep.d.ts +7 -0
- package/src/components/FraudReport/FraudsterDetailsStep.js +56 -0
- package/src/components/FraudReport/IntroStep.js +5 -1
- package/src/components/FraudReport/TransactionPicker.d.ts +13 -0
- package/src/components/FraudReport/TransactionPicker.js +213 -0
- package/src/components/FraudReport/TransactionPickerFilters.d.ts +8 -0
- package/src/components/FraudReport/TransactionPickerFilters.js +213 -0
- package/src/components/FraudReport/TransactionRows.d.ts +8 -0
- package/src/components/FraudReport/TransactionRows.js +32 -0
- package/src/components/FraudReport/TransactionsStep.js +9 -27
- package/src/components/FraudReport/TransferDetailsStep.d.ts +7 -0
- package/src/components/FraudReport/TransferDetailsStep.js +25 -0
- package/src/components/FraudReport/VictimStep.d.ts +3 -1
- package/src/components/FraudReport/VictimStep.js +38 -5
- package/src/components/LakeModal.js +1 -1
- package/src/components/SupportingDocumentCollection.d.ts +1 -0
- package/src/components/SupportingDocumentCollection.js +13 -14
- package/src/hooks/__tests__/useFilesUploader.test.d.ts +1 -0
- package/src/hooks/__tests__/useFilesUploader.test.js +101 -0
- package/src/hooks/__tests__/useFraudReportFlow.test.js +108 -20
- package/src/hooks/useFilesUploader.d.ts +2 -1
- package/src/hooks/useFilesUploader.js +28 -9
- package/src/hooks/useFraudReportFlow.js +12 -7
- package/src/locales/de.json +84 -8
- package/src/locales/en.json +77 -1
- package/src/locales/es.json +77 -1
- package/src/locales/fi.json +77 -1
- package/src/locales/fr.json +77 -1
- package/src/locales/it.json +77 -1
- package/src/locales/nl.json +77 -1
- package/src/locales/pt.json +77 -1
- package/src/utils/SwanFile.d.ts +2 -0
- package/src/utils/__tests__/fraudReport.card.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.card.test.js +39 -0
- package/src/utils/__tests__/fraudReport.documents.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.documents.test.js +61 -0
- package/src/utils/__tests__/fraudReport.fraudster.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.fraudster.test.js +35 -0
- package/src/utils/__tests__/fraudReport.messages.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.messages.test.js +28 -0
- package/src/utils/__tests__/fraudReport.picker.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.picker.test.js +186 -0
- package/src/utils/__tests__/fraudReport.pickerFilters.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.pickerFilters.test.js +144 -0
- package/src/utils/__tests__/fraudReport.prefill.test.js +7 -1
- package/src/utils/__tests__/fraudReport.rejections.test.js +11 -19
- package/src/utils/__tests__/fraudReport.resume.test.js +19 -4
- package/src/utils/__tests__/fraudReport.toInput.test.js +160 -40
- package/src/utils/__tests__/fraudReport.transactions.test.js +11 -1
- package/src/utils/__tests__/fraudReport.transfer.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.transfer.test.js +31 -0
- package/src/utils/__tests__/fraudReport.victim.test.js +27 -1
- package/src/utils/__tests__/validation.test.js +81 -7
- package/src/utils/fraudReport/card.d.ts +11 -0
- package/src/utils/fraudReport/card.js +15 -0
- package/src/utils/fraudReport/documents.d.ts +9 -0
- package/src/utils/fraudReport/documents.js +18 -0
- package/src/utils/fraudReport/fakeApi.js +1 -1
- package/src/utils/fraudReport/fraudster.d.ts +10 -0
- package/src/utils/fraudReport/fraudster.js +11 -0
- package/src/utils/fraudReport/messages.d.ts +4 -0
- package/src/utils/fraudReport/messages.js +7 -0
- package/src/utils/fraudReport/picker.d.ts +19 -0
- package/src/utils/fraudReport/picker.js +50 -0
- package/src/utils/fraudReport/pickerFilters.d.ts +26 -0
- package/src/utils/fraudReport/pickerFilters.js +62 -0
- package/src/utils/fraudReport/prefill.d.ts +1 -1
- package/src/utils/fraudReport/prefill.js +6 -3
- package/src/utils/fraudReport/rejections.d.ts +0 -1
- package/src/utils/fraudReport/rejections.js +2 -6
- package/src/utils/fraudReport/resume.js +4 -4
- package/src/utils/fraudReport/toInput.d.ts +6 -3
- package/src/utils/fraudReport/toInput.js +41 -24
- package/src/utils/fraudReport/transactions.d.ts +2 -0
- package/src/utils/fraudReport/transactions.js +4 -0
- package/src/utils/fraudReport/transfer.d.ts +6 -0
- package/src/utils/fraudReport/transfer.js +8 -0
- package/src/utils/fraudReport/types.d.ts +1 -1
- package/src/utils/fraudReport/validation.d.ts +1 -1
- package/src/utils/fraudReport/validation.js +4 -0
- package/src/utils/fraudReport/victim.d.ts +11 -0
- package/src/utils/fraudReport/victim.js +9 -0
- package/src/utils/validation.d.ts +2 -0
- package/src/utils/validation.js +15 -8
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { hasPickerFilters, isSamePickerFilters, parseAmountFilter, pickerFilterTypes, setPickerFilters, toExecutionDateBounds, togglePickerFilterType, validateFromDate, validateToDate, } from "../fraudReport/pickerFilters";
|
|
4
|
+
describe("setPickerFilters", () => {
|
|
5
|
+
test("adds a filter and keeps the others", () => {
|
|
6
|
+
expect(setPickerFilters({ amount: "12.50" }, { fromDate: "2026-11-01" })).toEqual({
|
|
7
|
+
amount: "12.50",
|
|
8
|
+
fromDate: "2026-11-01",
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
test("replaces a filter that is already set", () => {
|
|
12
|
+
expect(setPickerFilters({ types: ["CardOutDebit"] }, { types: ["SepaCreditTransferOut"] })).toEqual({ types: ["SepaCreditTransferOut"] });
|
|
13
|
+
});
|
|
14
|
+
test("removes a filter set to undefined, an empty text or an empty list", () => {
|
|
15
|
+
const filters = {
|
|
16
|
+
search: "rewe",
|
|
17
|
+
amount: "12.50",
|
|
18
|
+
types: ["CardOutDebit"],
|
|
19
|
+
toDate: "2026-11-02",
|
|
20
|
+
};
|
|
21
|
+
expect(setPickerFilters(filters, { search: "", amount: undefined, types: [], toDate: "2026-11-02" })).toEqual({ toDate: "2026-11-02" });
|
|
22
|
+
});
|
|
23
|
+
test("trims the search, and removes it when only spaces are left", () => {
|
|
24
|
+
expect(setPickerFilters({}, { search: " rewe " })).toEqual({ search: "rewe" });
|
|
25
|
+
expect(setPickerFilters({ search: "rewe" }, { search: " " })).toEqual({});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe("hasPickerFilters", () => {
|
|
29
|
+
test("is false without any filter", () => {
|
|
30
|
+
expect(hasPickerFilters({})).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
test("is true with a search or a chip filter", () => {
|
|
33
|
+
expect(hasPickerFilters({ search: "rewe" })).toBe(true);
|
|
34
|
+
expect(hasPickerFilters({ amount: "12" })).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("parseAmountFilter", () => {
|
|
38
|
+
test("accepts an amount with up to two decimals", () => {
|
|
39
|
+
expect(parseAmountFilter("12")).toEqual({ amount: "12" });
|
|
40
|
+
expect(parseAmountFilter(" 3010.99 ")).toEqual({ amount: "3010.99" });
|
|
41
|
+
expect(parseAmountFilter("0.5")).toEqual({ amount: "0.5" });
|
|
42
|
+
});
|
|
43
|
+
test("reads a comma as the decimal separator", () => {
|
|
44
|
+
expect(parseAmountFilter("657,75")).toEqual({ amount: "657.75" });
|
|
45
|
+
});
|
|
46
|
+
test("an empty text clears the filter", () => {
|
|
47
|
+
expect(parseAmountFilter(" ")).toEqual({ amount: undefined });
|
|
48
|
+
});
|
|
49
|
+
test("rejects anything else", () => {
|
|
50
|
+
expect(parseAmountFilter("abc")).toEqual({ error: "InvalidAmount" });
|
|
51
|
+
expect(parseAmountFilter("12.345")).toEqual({ error: "InvalidAmount" });
|
|
52
|
+
expect(parseAmountFilter("-12")).toEqual({ error: "InvalidAmount" });
|
|
53
|
+
expect(parseAmountFilter("1 000")).toEqual({ error: "InvalidAmount" });
|
|
54
|
+
expect(parseAmountFilter("12.")).toEqual({ error: "InvalidAmount" });
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe("validateFromDate", () => {
|
|
58
|
+
test("accepts any date without an end", () => {
|
|
59
|
+
expect(validateFromDate("2026-11-30", undefined)).toBeUndefined();
|
|
60
|
+
});
|
|
61
|
+
test("rejects a date after the end of the range, accepts the same day", () => {
|
|
62
|
+
expect(validateFromDate("2026-11-11", "2026-11-10")).toBe("StartAfterEnd");
|
|
63
|
+
expect(validateFromDate("2026-11-10", "2026-11-10")).toBeUndefined();
|
|
64
|
+
expect(validateFromDate("2026-11-09", "2026-11-10")).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
test("rejects a date that doesn't exist", () => {
|
|
67
|
+
expect(validateFromDate("2026-02-30", undefined)).toBe("InvalidDate");
|
|
68
|
+
expect(validateFromDate("", undefined)).toBe("InvalidDate");
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("validateToDate", () => {
|
|
72
|
+
test("accepts any date without a start", () => {
|
|
73
|
+
expect(validateToDate("2026-11-30", undefined)).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
test("rejects a date before the start of the range, accepts the same day", () => {
|
|
76
|
+
expect(validateToDate("2026-11-09", "2026-11-10")).toBe("StartAfterEnd");
|
|
77
|
+
expect(validateToDate("2026-11-10", "2026-11-10")).toBeUndefined();
|
|
78
|
+
expect(validateToDate("2026-11-11", "2026-11-10")).toBeUndefined();
|
|
79
|
+
});
|
|
80
|
+
test("rejects a date that doesn't exist", () => {
|
|
81
|
+
expect(validateToDate("2026-13-01", undefined)).toBe("InvalidDate");
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
describe("toExecutionDateBounds", () => {
|
|
85
|
+
test("has no bound without a date filter", () => {
|
|
86
|
+
expect(toExecutionDateBounds({ search: "rewe" })).toEqual({});
|
|
87
|
+
});
|
|
88
|
+
test("starts at the beginning of the first day, in the user's time zone", () => {
|
|
89
|
+
expect(toExecutionDateBounds({ fromDate: "2026-11-04" })).toEqual({
|
|
90
|
+
isAfterExecutionDate: dayjs("2026-11-04T00:00:00").toISOString(),
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
test("ends at the beginning of the day after the last one, so the last day is included", () => {
|
|
94
|
+
expect(toExecutionDateBounds({ toDate: "2026-11-04" })).toEqual({
|
|
95
|
+
isBeforeExecutionDate: dayjs("2026-11-05T00:00:00").toISOString(),
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
test("includes a transaction of the only day of a one-day range", () => {
|
|
99
|
+
const { isAfterExecutionDate = "", isBeforeExecutionDate = "" } = toExecutionDateBounds({
|
|
100
|
+
fromDate: "2026-11-04",
|
|
101
|
+
toDate: "2026-11-04",
|
|
102
|
+
});
|
|
103
|
+
const executionDate = dayjs("2026-11-04T15:30:00").toISOString();
|
|
104
|
+
expect(isAfterExecutionDate <= executionDate).toBe(true);
|
|
105
|
+
expect(executionDate < isBeforeExecutionDate).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
describe("togglePickerFilterType", () => {
|
|
109
|
+
test("adds a type that isn't ticked", () => {
|
|
110
|
+
expect(togglePickerFilterType(undefined, "CardOutDebit")).toEqual(["CardOutDebit"]);
|
|
111
|
+
});
|
|
112
|
+
test("removes a ticked type", () => {
|
|
113
|
+
expect(togglePickerFilterType(["CardOutDebit", "SepaCreditTransferOut"], "CardOutDebit")).toEqual(["SepaCreditTransferOut"]);
|
|
114
|
+
expect(togglePickerFilterType(["CardOutDebit"], "CardOutDebit")).toEqual([]);
|
|
115
|
+
});
|
|
116
|
+
test("keeps the order of the list, whatever the order of the ticks", () => {
|
|
117
|
+
expect(togglePickerFilterType(["InternalCreditTransferOut"], "CardOutDebit")).toEqual([
|
|
118
|
+
"CardOutDebit",
|
|
119
|
+
"InternalCreditTransferOut",
|
|
120
|
+
]);
|
|
121
|
+
});
|
|
122
|
+
test("lists the card first, then the transfers", () => {
|
|
123
|
+
expect(pickerFilterTypes).toEqual([
|
|
124
|
+
"CardOutDebit",
|
|
125
|
+
"SepaCreditTransferOut",
|
|
126
|
+
"SepaInstantCreditTransferOut",
|
|
127
|
+
"InternationalCreditTransferOut",
|
|
128
|
+
"InternalCreditTransferOut",
|
|
129
|
+
]);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe("isSamePickerFilters", () => {
|
|
133
|
+
test("is true for the same values", () => {
|
|
134
|
+
expect(isSamePickerFilters({ search: "rewe", types: ["CardOutDebit"] }, { search: "rewe", types: ["CardOutDebit"] })).toBe(true);
|
|
135
|
+
expect(isSamePickerFilters({}, {})).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
test("is false when a value differs, is added or is removed", () => {
|
|
138
|
+
expect(isSamePickerFilters({ search: "rewe" }, { search: "lidl" })).toBe(false);
|
|
139
|
+
expect(isSamePickerFilters({}, { amount: "12" })).toBe(false);
|
|
140
|
+
expect(isSamePickerFilters({ fromDate: "2026-11-01" }, {})).toBe(false);
|
|
141
|
+
expect(isSamePickerFilters({ toDate: "2026-11-01" }, { toDate: "2026-11-02" })).toBe(false);
|
|
142
|
+
expect(isSamePickerFilters({ types: ["CardOutDebit"] }, { types: ["CardOutDebit", "SepaCreditTransferOut"] })).toBe(false);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -45,7 +45,7 @@ const fullDraft = draft({
|
|
|
45
45
|
externalReference: "ref-42",
|
|
46
46
|
});
|
|
47
47
|
const roundTrip = (savedCase) => toUpdateInput({
|
|
48
|
-
savedCase,
|
|
48
|
+
disputeCaseId: savedCase.id,
|
|
49
49
|
values: toFormValues(savedCase),
|
|
50
50
|
savedTransactionIds: savedCase.transactions.map(({ id }) => id),
|
|
51
51
|
});
|
|
@@ -61,8 +61,11 @@ describe("toFormValues", () => {
|
|
|
61
61
|
discoveryDetails: "My bank app showed a payment I didn't make",
|
|
62
62
|
fraudsterChannels: ["Phone"],
|
|
63
63
|
sharedInformationWithFraudster: ["VerificationCode"],
|
|
64
|
+
hasFiledPoliceComplaint: true,
|
|
64
65
|
isLostOrStolen: true,
|
|
65
66
|
lostOrStolenNoticedAt: "2026-11-19",
|
|
67
|
+
hasContactedMerchant: false,
|
|
68
|
+
hasContactedBankOrBeneficiary: true,
|
|
66
69
|
externalReference: "ref-42",
|
|
67
70
|
});
|
|
68
71
|
});
|
|
@@ -117,6 +120,7 @@ describe("toFormValues then toUpdateInput", () => {
|
|
|
117
120
|
}))).toEqual({
|
|
118
121
|
disputeCaseId: "case-1",
|
|
119
122
|
fraudDetails,
|
|
123
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: null },
|
|
120
124
|
victimAccountMembershipId: "membership-2",
|
|
121
125
|
externalReference: "ref-42",
|
|
122
126
|
});
|
|
@@ -126,6 +130,7 @@ describe("toFormValues then toUpdateInput", () => {
|
|
|
126
130
|
disputeCaseId: "case-1",
|
|
127
131
|
fraudDetails,
|
|
128
132
|
fraudCardDetails,
|
|
133
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: true },
|
|
129
134
|
externalReference: "ref-42",
|
|
130
135
|
});
|
|
131
136
|
});
|
|
@@ -133,6 +138,7 @@ describe("toFormValues then toUpdateInput", () => {
|
|
|
133
138
|
expect(roundTrip(draft({ transactions: [transfer1], fraudDetails, hasVictim: true }))).toEqual({
|
|
134
139
|
disputeCaseId: "case-1",
|
|
135
140
|
fraudDetails,
|
|
141
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: null },
|
|
136
142
|
});
|
|
137
143
|
});
|
|
138
144
|
test("sends empty fraudster lists back as null", () => {
|
|
@@ -86,20 +86,15 @@ const incomplete = (...paths) => ({
|
|
|
86
86
|
message: "",
|
|
87
87
|
missingFields: paths.map(path => ({ path })),
|
|
88
88
|
});
|
|
89
|
-
const
|
|
90
|
-
hasDraft: false,
|
|
89
|
+
const context = {
|
|
91
90
|
detailsSteps: fraudReportDetailsSteps,
|
|
92
91
|
};
|
|
93
|
-
const afterDraft = { ...beforeDraft, hasDraft: true };
|
|
94
92
|
describe("getRejectionStep", () => {
|
|
95
93
|
test.each(Object.values(rejections))("maps $__typename", rejection => {
|
|
96
|
-
expect(getRejectionStep(rejection,
|
|
94
|
+
expect(getRejectionStep(rejection, context)).toBe(expectedSteps[rejection.__typename]);
|
|
97
95
|
});
|
|
98
96
|
test("shows the submitted screen when the case was submitted elsewhere", () => {
|
|
99
|
-
expect(getRejectionStep({ ...rejections.DisputeCaseWrongStatusRejection, currentStatus: "Submitted" },
|
|
100
|
-
});
|
|
101
|
-
test("rejects the report when the victim isn't found once the draft exists", () => {
|
|
102
|
-
expect(getRejectionStep(rejections.AccountMembershipNotFoundRejection, afterDraft)).toBe("Rejected");
|
|
97
|
+
expect(getRejectionStep({ ...rejections.DisputeCaseWrongStatusRejection, currentStatus: "Submitted" }, context)).toBe("Submitted");
|
|
103
98
|
});
|
|
104
99
|
});
|
|
105
100
|
describe("getRejectionStep: incomplete", () => {
|
|
@@ -118,32 +113,29 @@ describe("getRejectionStep: incomplete", () => {
|
|
|
118
113
|
[["fraudCardDetails", "isLostOrStolen"], "Card"],
|
|
119
114
|
[["fraudCardDetails", "lostOrStolenNoticedAt"], "Card"],
|
|
120
115
|
])("sends a missing %j to %s", (path, step) => {
|
|
121
|
-
expect(getRejectionStep(incomplete(path),
|
|
116
|
+
expect(getRejectionStep(incomplete(path), context)).toBe(step);
|
|
122
117
|
});
|
|
123
118
|
test("sends several missing fields to the earliest step", () => {
|
|
124
|
-
expect(getRejectionStep(incomplete(["fraudCardDetails"], ["transactionIds"], ["fraudDetails", "fraudsterChannels"]),
|
|
119
|
+
expect(getRejectionStep(incomplete(["fraudCardDetails"], ["transactionIds"], ["fraudDetails", "fraudsterChannels"]), context)).toBe("Transactions");
|
|
125
120
|
});
|
|
126
121
|
test("picks the earliest step after moving fields out of missing sub-steps", () => {
|
|
127
122
|
expect(getRejectionStep(incomplete(["fraudCardDetails"], ["fraudDetails", "fraudsterChannels"]), {
|
|
128
|
-
...
|
|
123
|
+
...context,
|
|
129
124
|
detailsSteps: ["Card"],
|
|
130
125
|
})).toBe("Incident");
|
|
131
126
|
});
|
|
132
127
|
test("ignores fields the form can't fix when another one can be fixed", () => {
|
|
133
|
-
expect(getRejectionStep(incomplete(["
|
|
134
|
-
});
|
|
135
|
-
test("rejects the report when the victim is missing once the draft exists", () => {
|
|
136
|
-
expect(getRejectionStep(incomplete(["victimAccountMembershipId"]), afterDraft)).toBe("Rejected");
|
|
128
|
+
expect(getRejectionStep(incomplete(["fraudCardDetails"], ["fraudDetails", "hasFiledPoliceComplaint"]), context)).toBe("Card");
|
|
137
129
|
});
|
|
138
130
|
test("sends fraudster fields to the incident when the flow has no fraudster sub-step", () => {
|
|
139
131
|
expect(getRejectionStep(incomplete(["fraudDetails", "fraudsterChannels"]), {
|
|
140
|
-
...
|
|
132
|
+
...context,
|
|
141
133
|
detailsSteps: ["Card"],
|
|
142
134
|
})).toBe("Incident");
|
|
143
135
|
});
|
|
144
136
|
test("sends card fields to the transactions when the flow has no card sub-step", () => {
|
|
145
137
|
expect(getRejectionStep(incomplete(["fraudCardDetails"]), {
|
|
146
|
-
...
|
|
138
|
+
...context,
|
|
147
139
|
detailsSteps: ["Transfer"],
|
|
148
140
|
})).toBe("Transactions");
|
|
149
141
|
});
|
|
@@ -155,9 +147,9 @@ describe("getRejectionStep: incomplete", () => {
|
|
|
155
147
|
[["externalReference"]],
|
|
156
148
|
[["unknownField"]],
|
|
157
149
|
])("rejects the report when only %j is missing", path => {
|
|
158
|
-
expect(getRejectionStep(incomplete(path),
|
|
150
|
+
expect(getRejectionStep(incomplete(path), context)).toBe("Rejected");
|
|
159
151
|
});
|
|
160
152
|
test("rejects the report when no missing field is given", () => {
|
|
161
|
-
expect(getRejectionStep(incomplete(),
|
|
153
|
+
expect(getRejectionStep(incomplete(), context)).toBe("Rejected");
|
|
162
154
|
});
|
|
163
155
|
});
|
|
@@ -26,16 +26,31 @@ describe("getResumeStep", () => {
|
|
|
26
26
|
])("opens the incident step with $name", ({ values }) => {
|
|
27
27
|
expect(getResumeStep({ transactions: [card], ...values })).toBe("Incident");
|
|
28
28
|
});
|
|
29
|
-
test("opens the card sub-step until
|
|
29
|
+
test("opens the card sub-step until one of its card answers is given", () => {
|
|
30
30
|
expect(getResumeStep({ transactions: [card], ...incident })).toBe("Card");
|
|
31
31
|
expect(getResumeStep({ transactions: [card], ...incident, isLostOrStolen: false })).toBe("Documents");
|
|
32
|
+
expect(getResumeStep({ transactions: [card], ...incident, hasContactedMerchant: true })).toBe("Documents");
|
|
32
33
|
});
|
|
33
|
-
test("
|
|
34
|
+
test("opens the card sub-step when only the police complaint is answered", () => {
|
|
35
|
+
expect(getResumeStep({ transactions: [card], ...incident, hasFiledPoliceComplaint: true })).toBe("Card");
|
|
36
|
+
});
|
|
37
|
+
test("skips the transfer sub-step, answered or not", () => {
|
|
34
38
|
expect(getResumeStep({ transactions: [transfer], ...incident })).toBe("Documents");
|
|
39
|
+
expect(getResumeStep({ transactions: [transfer], ...incident, hasContactedBankOrBeneficiary: true })).toBe("Documents");
|
|
40
|
+
});
|
|
41
|
+
test.each([
|
|
42
|
+
{ name: "only the shared information", values: { sharedInformationWithFraudster: ["None"] } },
|
|
43
|
+
{ name: "only the channels", values: { fraudsterChannels: ["Phone"] } },
|
|
44
|
+
])("skips the fraudster sub-step answered with $name", ({ values }) => {
|
|
45
|
+
expect(getResumeStep({
|
|
46
|
+
transactions: [transfer],
|
|
47
|
+
...incident,
|
|
48
|
+
reportedReason: "Manipulated",
|
|
49
|
+
...values,
|
|
50
|
+
})).toBe("Documents");
|
|
35
51
|
});
|
|
36
52
|
test.each([
|
|
37
|
-
{ name: "no
|
|
38
|
-
{ name: "nothing shared", values: { fraudsterChannels: ["Phone"] } },
|
|
53
|
+
{ name: "no answer", values: {} },
|
|
39
54
|
{ name: "empty lists", values: { fraudsterChannels: [], sharedInformationWithFraudster: [] } },
|
|
40
55
|
])("opens the fraudster sub-step with $name", ({ values }) => {
|
|
41
56
|
expect(getResumeStep({
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Option } from "@bloodyowl/boxed";
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
3
3
|
import { createFakeFraudReportApi, createFakeTransaction } from "../fraudReport/fakeApi";
|
|
4
|
+
import { toFormValues } from "../fraudReport/prefill";
|
|
4
5
|
import { getCaseRail, getTransactionRail } from "../fraudReport/rail";
|
|
5
6
|
import { toDraftInput, toUpdateInput } from "../fraudReport/toInput";
|
|
7
|
+
import { MAX_TRANSACTIONS } from "../fraudReport/transactions";
|
|
6
8
|
import { validateDescription, validateDiscoveryDetails, validateExternalReference, validateNotInFuture, validateSelected, validateSharedInformation, validateTransactionIds, } from "../fraudReport/validation";
|
|
7
9
|
const card1 = createFakeTransaction("card-1", "CardOutDebit");
|
|
8
10
|
const card2 = createFakeTransaction("card-2", "CardOutDebit");
|
|
@@ -91,6 +93,11 @@ describe("validateTransactionIds", () => {
|
|
|
91
93
|
expect(validateTransactionIds(["card-1"])).toBeUndefined();
|
|
92
94
|
expect(validateTransactionIds(["card-1", "transfer-1"])).toBeUndefined();
|
|
93
95
|
});
|
|
96
|
+
test("accepts the most transactions a report takes, rejects one more", () => {
|
|
97
|
+
const ids = Array.from({ length: MAX_TRANSACTIONS + 1 }, (_, index) => `transfer-${index}`);
|
|
98
|
+
expect(validateTransactionIds(ids.slice(0, MAX_TRANSACTIONS))).toBeUndefined();
|
|
99
|
+
expect(validateTransactionIds(ids)).toBe("TooMany");
|
|
100
|
+
});
|
|
94
101
|
});
|
|
95
102
|
describe("validateSelected", () => {
|
|
96
103
|
test("requires a value", () => {
|
|
@@ -282,10 +289,18 @@ describe("toDraftInput", () => {
|
|
|
282
289
|
externalReference: "REF-42",
|
|
283
290
|
});
|
|
284
291
|
});
|
|
285
|
-
test("
|
|
292
|
+
test("leaves the transfer details out until they are answered", () => {
|
|
286
293
|
expect(toDraftInput({ ...filled, transactions: [transfer1] })).not.toHaveProperty("fraudTransferDetails");
|
|
287
294
|
expect(toDraftInput({ ...filled, transactions: [transfer1, card1] })).not.toHaveProperty("fraudTransferDetails");
|
|
288
295
|
});
|
|
296
|
+
test("sends the transfer details once answered, only on a case with transfers", () => {
|
|
297
|
+
const answered = { ...filled, hasContactedBankOrBeneficiary: true };
|
|
298
|
+
expect(toDraftInput({ ...answered, transactions: [transfer1] }).fraudTransferDetails).toEqual({
|
|
299
|
+
hasContactedBankOrBeneficiary: true,
|
|
300
|
+
});
|
|
301
|
+
expect(toDraftInput({ ...answered, transactions: [transfer1, card1] }).fraudTransferDetails).toEqual({ hasContactedBankOrBeneficiary: true });
|
|
302
|
+
expect(toDraftInput({ ...answered, transactions: [card1] })).not.toHaveProperty("fraudTransferDetails");
|
|
303
|
+
});
|
|
289
304
|
test("leaves the victim out of a transfer-only case until one is picked", () => {
|
|
290
305
|
expect(toDraftInput({ ...incident, transactions: [transfer1] })).not.toHaveProperty("victimAccountMembershipId");
|
|
291
306
|
});
|
|
@@ -326,6 +341,21 @@ describe("toDraftInput", () => {
|
|
|
326
341
|
expect(toDraftInput({ ...incident, transactions: [card1] })).not.toHaveProperty("fraudCardDetails");
|
|
327
342
|
expect(toDraftInput({ ...incident, lostOrStolenNoticedAt: "", transactions: [card1] })).not.toHaveProperty("fraudCardDetails");
|
|
328
343
|
});
|
|
344
|
+
test("sends the actions taken from the form", () => {
|
|
345
|
+
var _a;
|
|
346
|
+
const input = toDraftInput({
|
|
347
|
+
...incident,
|
|
348
|
+
hasFiledPoliceComplaint: true,
|
|
349
|
+
hasContactedMerchant: true,
|
|
350
|
+
transactions: [card1],
|
|
351
|
+
});
|
|
352
|
+
expect((_a = input.fraudDetails) === null || _a === void 0 ? void 0 : _a.hasFiledPoliceComplaint).toBe(true);
|
|
353
|
+
expect(input.fraudCardDetails).toStrictEqual({
|
|
354
|
+
isLostOrStolen: null,
|
|
355
|
+
lostOrStolenNoticedAt: null,
|
|
356
|
+
hasContactedMerchant: true,
|
|
357
|
+
});
|
|
358
|
+
});
|
|
329
359
|
test("sends null for the card detail left empty", () => {
|
|
330
360
|
expect(toDraftInput({ isLostOrStolen: false, transactions: [card1] }).fraudCardDetails).toStrictEqual({
|
|
331
361
|
isLostOrStolen: false,
|
|
@@ -345,11 +375,16 @@ describe("toDraftInput", () => {
|
|
|
345
375
|
});
|
|
346
376
|
});
|
|
347
377
|
describe("toUpdateInput", () => {
|
|
348
|
-
const savedCase = { id: "case-1"
|
|
378
|
+
const savedCase = { id: "case-1" };
|
|
349
379
|
const disputeCaseId = savedCase.id;
|
|
380
|
+
const cardGroups = { fraudCardDetails: expect.any(Object) };
|
|
381
|
+
const mixedGroups = {
|
|
382
|
+
...cardGroups,
|
|
383
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: null },
|
|
384
|
+
};
|
|
350
385
|
test("sends the card details and no victim on a card-only case", () => {
|
|
351
386
|
expect(toUpdateInput({
|
|
352
|
-
savedCase,
|
|
387
|
+
disputeCaseId: savedCase.id,
|
|
353
388
|
values: { ...filled, transactions: [card1, card2] },
|
|
354
389
|
savedTransactionIds: ["card-1"],
|
|
355
390
|
})).toStrictEqual({
|
|
@@ -362,20 +397,21 @@ describe("toUpdateInput", () => {
|
|
|
362
397
|
});
|
|
363
398
|
test("sends the victim and no card details on a transfer-only case", () => {
|
|
364
399
|
expect(toUpdateInput({
|
|
365
|
-
savedCase,
|
|
400
|
+
disputeCaseId: savedCase.id,
|
|
366
401
|
values: { ...filled, transactions: [transfer1] },
|
|
367
402
|
savedTransactionIds: ["transfer-1", "card-1"],
|
|
368
403
|
})).toStrictEqual({
|
|
369
404
|
disputeCaseId,
|
|
370
405
|
transactionIds: ["transfer-1"],
|
|
371
406
|
fraudDetails,
|
|
407
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: null },
|
|
372
408
|
victimAccountMembershipId: "member-1",
|
|
373
409
|
externalReference: "REF-42",
|
|
374
410
|
});
|
|
375
411
|
});
|
|
376
412
|
test("sends the card details and no victim on a mixed case", () => {
|
|
377
413
|
expect(toUpdateInput({
|
|
378
|
-
savedCase,
|
|
414
|
+
disputeCaseId: savedCase.id,
|
|
379
415
|
values: { ...filled, transactions: [transfer1, card1] },
|
|
380
416
|
savedTransactionIds: ["transfer-1"],
|
|
381
417
|
})).toStrictEqual({
|
|
@@ -383,19 +419,33 @@ describe("toUpdateInput", () => {
|
|
|
383
419
|
transactionIds: ["transfer-1", "card-1"],
|
|
384
420
|
fraudDetails,
|
|
385
421
|
fraudCardDetails,
|
|
422
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: null },
|
|
386
423
|
externalReference: "REF-42",
|
|
387
424
|
});
|
|
388
425
|
});
|
|
389
|
-
test("
|
|
426
|
+
test("sends the transfer details from the form on a case with transfers", () => {
|
|
427
|
+
const values = { ...filled, hasContactedBankOrBeneficiary: true };
|
|
390
428
|
expect(toUpdateInput({
|
|
391
|
-
savedCase,
|
|
392
|
-
values: { ...
|
|
393
|
-
savedTransactionIds: [],
|
|
429
|
+
disputeCaseId: savedCase.id,
|
|
430
|
+
values: { ...values, transactions: [transfer1] },
|
|
431
|
+
savedTransactionIds: ["transfer-1"],
|
|
432
|
+
}).fraudTransferDetails).toStrictEqual({ hasContactedBankOrBeneficiary: true });
|
|
433
|
+
expect(toUpdateInput({
|
|
434
|
+
disputeCaseId: savedCase.id,
|
|
435
|
+
values: { ...values, transactions: [transfer1, card1] },
|
|
436
|
+
savedTransactionIds: ["transfer-1", "card-1"],
|
|
437
|
+
}).fraudTransferDetails).toStrictEqual({ hasContactedBankOrBeneficiary: true });
|
|
438
|
+
});
|
|
439
|
+
test("never sends transfer details on a card-only case", () => {
|
|
440
|
+
expect(toUpdateInput({
|
|
441
|
+
disputeCaseId: savedCase.id,
|
|
442
|
+
values: { ...filled, hasContactedBankOrBeneficiary: true, transactions: [card1] },
|
|
443
|
+
savedTransactionIds: ["card-1"],
|
|
394
444
|
})).not.toHaveProperty("fraudTransferDetails");
|
|
395
445
|
});
|
|
396
446
|
test("clears the fraudster answers once no fraudster convinced the user", () => {
|
|
397
447
|
expect(toUpdateInput({
|
|
398
|
-
savedCase,
|
|
448
|
+
disputeCaseId: savedCase.id,
|
|
399
449
|
values: { ...filled, reportedReason: "Unauthorized", transactions: [card1] },
|
|
400
450
|
savedTransactionIds: ["card-1"],
|
|
401
451
|
}).fraudDetails).toStrictEqual({
|
|
@@ -407,60 +457,90 @@ describe("toUpdateInput", () => {
|
|
|
407
457
|
});
|
|
408
458
|
test("leaves the transaction IDs out when the selection didn't change", () => {
|
|
409
459
|
expect(toUpdateInput({
|
|
410
|
-
savedCase,
|
|
460
|
+
disputeCaseId: savedCase.id,
|
|
411
461
|
values: { ...incident, transactions: [card1, transfer1] },
|
|
412
462
|
savedTransactionIds: ["transfer-1", "card-1"],
|
|
413
|
-
})).toStrictEqual({
|
|
463
|
+
})).toStrictEqual({
|
|
464
|
+
disputeCaseId,
|
|
465
|
+
fraudDetails: expect.any(Object),
|
|
466
|
+
fraudCardDetails: expect.any(Object),
|
|
467
|
+
fraudTransferDetails: expect.any(Object),
|
|
468
|
+
});
|
|
414
469
|
});
|
|
415
470
|
test.each([
|
|
416
|
-
["a transaction was added", [card1, card2], ["card-1"]],
|
|
417
|
-
["a transaction was removed", [card1], ["card-1", "card-2"]],
|
|
418
|
-
["a transaction was swapped", [card1, transfer1], ["card-1", "card-2"]],
|
|
419
|
-
["a transaction is there twice", [card1, card1], ["card-1", "card-2"]],
|
|
420
|
-
])("sends the whole selection when %s", (_, transactions, savedTransactionIds) => {
|
|
421
|
-
expect(toUpdateInput({ savedCase, values: { transactions }, savedTransactionIds })).toStrictEqual({
|
|
422
|
-
|
|
423
|
-
|
|
471
|
+
["a transaction was added", [card1, card2], ["card-1"], cardGroups],
|
|
472
|
+
["a transaction was removed", [card1], ["card-1", "card-2"], cardGroups],
|
|
473
|
+
["a transaction was swapped", [card1, transfer1], ["card-1", "card-2"], mixedGroups],
|
|
474
|
+
["a transaction is there twice", [card1, card1], ["card-1", "card-2"], cardGroups],
|
|
475
|
+
])("sends the whole selection when %s", (_, transactions, savedTransactionIds, groups) => {
|
|
476
|
+
expect(toUpdateInput({ disputeCaseId: savedCase.id, values: { transactions }, savedTransactionIds })).toStrictEqual({
|
|
477
|
+
disputeCaseId,
|
|
478
|
+
transactionIds: transactions.map(({ id }) => id),
|
|
479
|
+
...groups,
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
test("sends the transfer details even when empty, so removed answers are cleared", () => {
|
|
483
|
+
expect(toUpdateInput({
|
|
484
|
+
disputeCaseId: savedCase.id,
|
|
485
|
+
values: { transactions: [transfer1] },
|
|
486
|
+
savedTransactionIds: ["transfer-1"],
|
|
487
|
+
})).toStrictEqual({
|
|
488
|
+
disputeCaseId,
|
|
489
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: null },
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
test("sends the card details even when empty, so removed answers are cleared", () => {
|
|
424
493
|
expect(toUpdateInput({
|
|
425
|
-
savedCase,
|
|
494
|
+
disputeCaseId: savedCase.id,
|
|
426
495
|
values: { transactions: [card1] },
|
|
427
496
|
savedTransactionIds: ["card-1"],
|
|
428
|
-
})).toStrictEqual({
|
|
497
|
+
})).toStrictEqual({
|
|
498
|
+
disputeCaseId,
|
|
499
|
+
fraudCardDetails: {
|
|
500
|
+
isLostOrStolen: null,
|
|
501
|
+
lostOrStolenNoticedAt: null,
|
|
502
|
+
hasContactedMerchant: null,
|
|
503
|
+
},
|
|
504
|
+
});
|
|
429
505
|
});
|
|
430
506
|
test("clears the external reference when it was emptied", () => {
|
|
431
507
|
expect(toUpdateInput({
|
|
432
|
-
savedCase,
|
|
508
|
+
disputeCaseId: savedCase.id,
|
|
433
509
|
values: { externalReference: "", transactions: [card1] },
|
|
434
510
|
savedTransactionIds: ["card-1"],
|
|
435
|
-
})).toStrictEqual({
|
|
511
|
+
})).toStrictEqual({
|
|
512
|
+
disputeCaseId,
|
|
513
|
+
fraudCardDetails: {
|
|
514
|
+
isLostOrStolen: null,
|
|
515
|
+
lostOrStolenNoticedAt: null,
|
|
516
|
+
hasContactedMerchant: null,
|
|
517
|
+
},
|
|
518
|
+
externalReference: null,
|
|
519
|
+
});
|
|
436
520
|
});
|
|
437
521
|
test("keeps the stored external reference when the form has none", () => {
|
|
438
522
|
expect(toUpdateInput({
|
|
439
|
-
savedCase,
|
|
523
|
+
disputeCaseId: savedCase.id,
|
|
440
524
|
values: { ...incident, transactions: [card1] },
|
|
441
525
|
savedTransactionIds: ["card-1"],
|
|
442
526
|
})).not.toHaveProperty("externalReference");
|
|
443
527
|
});
|
|
444
528
|
test("holds the card details and the victim back while no transaction is selected", () => {
|
|
445
529
|
expect(toUpdateInput({
|
|
446
|
-
savedCase,
|
|
530
|
+
disputeCaseId: savedCase.id,
|
|
447
531
|
values: { ...filled, transactions: [] },
|
|
448
532
|
savedTransactionIds: [],
|
|
449
533
|
})).toStrictEqual({ disputeCaseId, fraudDetails, externalReference: "REF-42" });
|
|
450
534
|
});
|
|
451
|
-
test("sends
|
|
535
|
+
test("sends the actions taken from the form", () => {
|
|
452
536
|
var _a, _b;
|
|
453
537
|
const input = toUpdateInput({
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
fraudDetails: { ...fraudDetails, hasFiledPoliceComplaint: true },
|
|
457
|
-
fraudCardDetails: { ...fraudCardDetails, hasContactedMerchant: false },
|
|
458
|
-
},
|
|
459
|
-
values: { ...filled, transactions: [card1] },
|
|
538
|
+
disputeCaseId: savedCase.id,
|
|
539
|
+
values: { ...filled, hasContactedMerchant: true, transactions: [card1] },
|
|
460
540
|
savedTransactionIds: ["card-1"],
|
|
461
541
|
});
|
|
462
|
-
expect((_a = input.fraudDetails) === null || _a === void 0 ? void 0 : _a.hasFiledPoliceComplaint).
|
|
463
|
-
expect((_b = input.fraudCardDetails) === null || _b === void 0 ? void 0 : _b.hasContactedMerchant).toBe(
|
|
542
|
+
expect((_a = input.fraudDetails) === null || _a === void 0 ? void 0 : _a.hasFiledPoliceComplaint).toBeNull();
|
|
543
|
+
expect((_b = input.fraudCardDetails) === null || _b === void 0 ? void 0 : _b.hasContactedMerchant).toBe(true);
|
|
464
544
|
});
|
|
465
545
|
});
|
|
466
546
|
describe("inputs sent to the API", () => {
|
|
@@ -504,7 +584,7 @@ describe("inputs sent to the API", () => {
|
|
|
504
584
|
const api = createApi();
|
|
505
585
|
const savedCase = getCase(await api.draft(toDraftInput({ ...filled, transactions: [card1] })));
|
|
506
586
|
const updated = getCase(await api.update(toUpdateInput({
|
|
507
|
-
savedCase,
|
|
587
|
+
disputeCaseId: savedCase.id,
|
|
508
588
|
values: { ...filled, transactions: [transfer1] },
|
|
509
589
|
savedTransactionIds: ["card-1"],
|
|
510
590
|
})));
|
|
@@ -516,7 +596,7 @@ describe("inputs sent to the API", () => {
|
|
|
516
596
|
const api = createApi();
|
|
517
597
|
const savedCase = getCase(await api.draft(toDraftInput({ ...filled, transactions: [transfer1] })));
|
|
518
598
|
const updated = getCase(await api.update(toUpdateInput({
|
|
519
|
-
savedCase,
|
|
599
|
+
disputeCaseId: savedCase.id,
|
|
520
600
|
values: { ...filled, transactions: [card1] },
|
|
521
601
|
savedTransactionIds: ["transfer-1"],
|
|
522
602
|
})));
|
|
@@ -524,7 +604,47 @@ describe("inputs sent to the API", () => {
|
|
|
524
604
|
expect(updated.fraudCardDetails).toMatchObject({ isLostOrStolen: true });
|
|
525
605
|
expect(updated.victimAccountMembershipId).toBe("member-2");
|
|
526
606
|
});
|
|
527
|
-
test("an update
|
|
607
|
+
test("an update clears an action the user removed", async () => {
|
|
608
|
+
var _a;
|
|
609
|
+
const api = createApi();
|
|
610
|
+
const savedCase = getCase(await api.draft({
|
|
611
|
+
transactionIds: ["card-1"],
|
|
612
|
+
fraudCardDetails: { hasContactedMerchant: true },
|
|
613
|
+
}));
|
|
614
|
+
const updated = getCase(await api.update(toUpdateInput({
|
|
615
|
+
disputeCaseId: savedCase.id,
|
|
616
|
+
values: { ...toFormValues(savedCase), hasContactedMerchant: undefined },
|
|
617
|
+
savedTransactionIds: ["card-1"],
|
|
618
|
+
})));
|
|
619
|
+
expect((_a = updated.fraudCardDetails) === null || _a === void 0 ? void 0 : _a.hasContactedMerchant).toBeNull();
|
|
620
|
+
});
|
|
621
|
+
test("a transfer answer is accepted and stored, and not sent once only cards are left", async () => {
|
|
622
|
+
const api = createApi();
|
|
623
|
+
const values = { ...filled, hasContactedBankOrBeneficiary: true };
|
|
624
|
+
const savedCase = getCase(await api.draft(toDraftInput({ ...values, transactions: [transfer1, card1] })));
|
|
625
|
+
expect(savedCase.fraudTransferDetails).toStrictEqual({ hasContactedBankOrBeneficiary: true });
|
|
626
|
+
const updated = getCase(await api.update(toUpdateInput({
|
|
627
|
+
disputeCaseId: savedCase.id,
|
|
628
|
+
values: { ...values, transactions: [card1] },
|
|
629
|
+
savedTransactionIds: ["transfer-1", "card-1"],
|
|
630
|
+
})));
|
|
631
|
+
expect(updated.fraudTransferDetails).toBeNull();
|
|
632
|
+
});
|
|
633
|
+
test("an update clears a transfer action the user removed", async () => {
|
|
634
|
+
var _a;
|
|
635
|
+
const api = createApi();
|
|
636
|
+
const savedCase = getCase(await api.draft({
|
|
637
|
+
transactionIds: ["transfer-1"],
|
|
638
|
+
fraudTransferDetails: { hasContactedBankOrBeneficiary: true },
|
|
639
|
+
}));
|
|
640
|
+
const updated = getCase(await api.update(toUpdateInput({
|
|
641
|
+
disputeCaseId: savedCase.id,
|
|
642
|
+
values: { ...toFormValues(savedCase), hasContactedBankOrBeneficiary: undefined },
|
|
643
|
+
savedTransactionIds: ["transfer-1"],
|
|
644
|
+
})));
|
|
645
|
+
expect((_a = updated.fraudTransferDetails) === null || _a === void 0 ? void 0 : _a.hasContactedBankOrBeneficiary).toBeNull();
|
|
646
|
+
});
|
|
647
|
+
test("an update keeps the details another client stored on a resumed draft", async () => {
|
|
528
648
|
var _a;
|
|
529
649
|
const api = createApi();
|
|
530
650
|
const savedCase = getCase(await api.draft({
|
|
@@ -534,8 +654,8 @@ describe("inputs sent to the API", () => {
|
|
|
534
654
|
fraudTransferDetails: { hasContactedBankOrBeneficiary: true },
|
|
535
655
|
}));
|
|
536
656
|
const updated = getCase(await api.update(toUpdateInput({
|
|
537
|
-
savedCase,
|
|
538
|
-
values: { ...filled, transactions: [card1, transfer1] },
|
|
657
|
+
disputeCaseId: savedCase.id,
|
|
658
|
+
values: { ...toFormValues(savedCase), ...filled, transactions: [card1, transfer1] },
|
|
539
659
|
savedTransactionIds: ["card-1", "transfer-1"],
|
|
540
660
|
})));
|
|
541
661
|
expect((_a = updated.fraudDetails) === null || _a === void 0 ? void 0 : _a.hasFiledPoliceComplaint).toBe(true);
|