@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
package/src/locales/pt.json
CHANGED
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"businessActivity.scientificActivities": "Atividades científicas",
|
|
48
48
|
"businessActivity.transportation": "Transporte",
|
|
49
49
|
"common.cancel": "Cancelar",
|
|
50
|
+
"common.clearSelection": "Limpar a seleção",
|
|
50
51
|
"common.close": "Fechar",
|
|
51
52
|
"common.form.help.nbCharacters": "{nbCharacters} caracteres",
|
|
52
53
|
"common.form.help.nbDigits": "{nbDigits} dígitos",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"common.noResult": "Resultado vazio",
|
|
57
58
|
"common.open": "Abrir",
|
|
58
59
|
"common.optional": "Opcional",
|
|
60
|
+
"common.options": "Opções",
|
|
59
61
|
"common.previous": "Anterior",
|
|
60
62
|
"common.rejectionReason.BadDocumentQuality": "A qualidade do documento é muito baixa para leitura. Carregue uma digitalização ou fotografia com maior resolução.",
|
|
61
63
|
"common.rejectionReason.CompanyNameMismatch": "O nome da empresa não corresponde aos registos da Swan. Carregue um documento com o nome correto da empresa.",
|
|
@@ -87,6 +89,8 @@
|
|
|
87
89
|
"common.rejectionReason.TransactionNameMismatch": "Os nomes no documento não correspondem aos detalhes da transação. Carregue um documento com os nomes corretos.",
|
|
88
90
|
"common.rejectionReason.UnacceptableDocument": "O documento não corresponde ao tipo solicitado. Consulte o campo «motivo» para obter mais detalhes da Swan.",
|
|
89
91
|
"common.remove": "Remover",
|
|
92
|
+
"common.removeItem": "Remover {item}",
|
|
93
|
+
"common.search": "Pesquisar",
|
|
90
94
|
"common.skipToContent": "Saltar para o conteúdo",
|
|
91
95
|
"common.statement.footer": "A SWAN é uma sociedade por ações simplificada (SAS) registada no Registo de Comércio e Sociedades de Paris com o número 853 827 103, um capital de 951.164,50 euros, NIF FR90853827103 e com sede social em 91 rue du Faubourg Saint-Honoré, 75008 Paris, FRANÇA.\n\nNa sua qualidade de instituição de Moeda Eletrónica que oferece serviços de pagamento ao abrigo da lei francesa, aprovada pela ACPR, a SWAN está registada junto desta última sob o número 17328.",
|
|
92
96
|
"common.yes": "Sim",
|
|
@@ -137,17 +141,59 @@
|
|
|
137
141
|
"fileInput.browse": "navegar",
|
|
138
142
|
"fileInput.clickToModify": "Clique para modificar",
|
|
139
143
|
"fileInput.dropFile": "Arraste o seu ficheiro, ou {browse}",
|
|
144
|
+
"fileInput.error.invalidType": "Este tipo de ficheiro não é compatível. Carregue um ficheiro {formats}.",
|
|
145
|
+
"fileInput.error.tooLarge": "Este ficheiro é demasiado grande. Carregue um ficheiro com até {maxSizeMB} MB.",
|
|
140
146
|
"fileInput.noFile": "Nenhum ficheiro",
|
|
141
147
|
"fileTile.deleteModal.delete": "Apagar",
|
|
142
148
|
"fileTile.deleteModal.title": "Tem a certeza que deseja eliminar este documento?",
|
|
149
|
+
"fileTile.error.remove": "Não foi possível remover este ficheiro. Tente novamente.",
|
|
150
|
+
"fileTile.error.upload": "Não foi possível carregar este ficheiro. Tente novamente.",
|
|
143
151
|
"fileTile.id": "ID: {id}",
|
|
144
152
|
"fileTile.status.Pending": "Verificação pendente",
|
|
153
|
+
"fileTile.tryAgain": "Tentar novamente",
|
|
145
154
|
"fileTile.uploading": "Carregando…",
|
|
146
155
|
"forecastYearlyIncome.from0To500000": "Menos de 500.000 €",
|
|
147
156
|
"forecastYearlyIncome.from1000001To5000000": "Entre 1.000.000 € e 5.000.000 €",
|
|
148
157
|
"forecastYearlyIncome.from500001To1000000": "Entre 500.000 € e 1.000.000 €",
|
|
149
158
|
"forecastYearlyIncome.moreThan5000000": "Mais de 5.000.000 €",
|
|
159
|
+
"fraudReport.card.action.merchant": "Comerciante",
|
|
160
|
+
"fraudReport.card.action.police": "Polícia",
|
|
161
|
+
"fraudReport.card.actionsLabel": "Selecione todas as opções aplicáveis",
|
|
162
|
+
"fraudReport.card.actionsPlaceholder": "Selecionar",
|
|
163
|
+
"fraudReport.card.actionsTitle": "Selecione a quem comunicou a fraude",
|
|
164
|
+
"fraudReport.card.blockCards": "Se ainda não o fez, bloqueie já os seus cartões.",
|
|
165
|
+
"fraudReport.card.lostOrStolenLabel": "Algum dos seus cartões foi perdido ou roubado?",
|
|
166
|
+
"fraudReport.card.noticedAtInFuture": "Introduza a data de hoje ou uma data anterior.",
|
|
167
|
+
"fraudReport.card.noticedAtInvalid": "Introduza uma data válida.",
|
|
168
|
+
"fraudReport.card.noticedAtLabel": "Quando reparou pela primeira vez que faltava um cartão?",
|
|
169
|
+
"fraudReport.card.title": "Confirme o estado dos seus cartões",
|
|
150
170
|
"fraudReport.continue": "Continuar",
|
|
171
|
+
"fraudReport.documents.description": "Adicione documentos que ajudem a explicar o que aconteceu. Pode enviar este formulário sem eles.\nO seu progresso é guardado automaticamente. Pode voltar antes de enviar.",
|
|
172
|
+
"fraudReport.documents.formats": "PDF, JPEG, PNG ou HEIC. Até {maxSizeMB} MB.",
|
|
173
|
+
"fraudReport.documents.otherDocuments": "Outros documentos",
|
|
174
|
+
"fraudReport.documents.otherDocumentsDescription": "Adicione mensagens, recibos ou capturas de ecrã relevantes.",
|
|
175
|
+
"fraudReport.documents.policeReport": "Queixa à polícia",
|
|
176
|
+
"fraudReport.documents.policeReportDescription": "Adicione uma queixa à polícia ou um comprovativo Perceval.",
|
|
177
|
+
"fraudReport.documents.reviewReport": "Rever a comunicação",
|
|
178
|
+
"fraudReport.documents.title": "Adicione documentos comprovativos",
|
|
179
|
+
"fraudReport.fraudster.channel.Application": "Aplicação, mensagens ou rede social",
|
|
180
|
+
"fraudReport.fraudster.channel.Email": "E-mail",
|
|
181
|
+
"fraudReport.fraudster.channel.Other": "Outro",
|
|
182
|
+
"fraudReport.fraudster.channel.Phone": "Chamada telefónica",
|
|
183
|
+
"fraudReport.fraudster.channel.Sms": "SMS",
|
|
184
|
+
"fraudReport.fraudster.channel.Website": "Site",
|
|
185
|
+
"fraudReport.fraudster.channelLabel": "Como o contactaram?",
|
|
186
|
+
"fraudReport.fraudster.description": "Diga-nos o que puder. Nunca escreva aqui uma palavra-passe, um PIN ou um código de segurança.",
|
|
187
|
+
"fraudReport.fraudster.shared.BankDetails": "Dados bancários, como um IBAN",
|
|
188
|
+
"fraudReport.fraudster.shared.CardDetails": "Dados do cartão (número, data de validade ou CVC)",
|
|
189
|
+
"fraudReport.fraudster.shared.Other": "Outro",
|
|
190
|
+
"fraudReport.fraudster.shared.PartnerPassword": "Palavra-passe da aplicação ou do site",
|
|
191
|
+
"fraudReport.fraudster.shared.PersonalInformation": "Dados de identidade (nome, data de nascimento, morada ou documento de identificação)",
|
|
192
|
+
"fraudReport.fraudster.shared.SwanPasscode": "Código usado para confirmar pagamentos",
|
|
193
|
+
"fraudReport.fraudster.shared.VerificationCode": "Código de verificação de utilização única",
|
|
194
|
+
"fraudReport.fraudster.sharedItemsLabel": "O que partilhou?",
|
|
195
|
+
"fraudReport.fraudster.sharedLabel": "Partilhou dados bancários ou o acesso à sua conta?",
|
|
196
|
+
"fraudReport.fraudster.title": "Indique-nos como foi contactado e o que partilhou",
|
|
151
197
|
"fraudReport.incident.description": "Conte-nos aquilo de que se lembra. Se não tiver a certeza de algum detalhe, indique-o.",
|
|
152
198
|
"fraudReport.incident.noticedAtInFuture": "Introduza a data de hoje ou uma data anterior.",
|
|
153
199
|
"fraudReport.incident.noticedAtInvalid": "Introduza uma data válida.",
|
|
@@ -175,10 +221,28 @@
|
|
|
175
221
|
"fraudReport.intro.rule.policeReport": "Uma <bold>queixa à polícia</bold> fundamenta o seu pedido. Carregue-a neste formulário.",
|
|
176
222
|
"fraudReport.intro.rule.refund": "Só as transações das últimas <bold>8 semanas</bold> podem ser reembolsadas.",
|
|
177
223
|
"fraudReport.intro.rule.saved": "O formulário é <bold>guardado automaticamente</bold>, pode terminá-lo mais tarde.",
|
|
178
|
-
"fraudReport.intro.rule.transactions": "Comunique até <bold>
|
|
224
|
+
"fraudReport.intro.rule.transactions": "Comunique até <bold>{max} transações</bold> de cada vez.",
|
|
179
225
|
"fraudReport.intro.rulesTitle": "Antes de começar:",
|
|
180
226
|
"fraudReport.intro.start": "Começar",
|
|
181
227
|
"fraudReport.intro.title": "Comunicar uma fraude",
|
|
228
|
+
"fraudReport.picker.clearSearch": "Limpar a pesquisa",
|
|
229
|
+
"fraudReport.picker.confirm": "Confirmar seleção",
|
|
230
|
+
"fraudReport.picker.description": "Selecione até {max} transações para esta comunicação.",
|
|
231
|
+
"fraudReport.picker.emptyTitle": "Nenhuma transação a comunicar",
|
|
232
|
+
"fraudReport.picker.filters.apply": "Aplicar",
|
|
233
|
+
"fraudReport.picker.filters.clear": "Remover o filtro: {filter}",
|
|
234
|
+
"fraudReport.picker.filters.endDate": "Data de fim",
|
|
235
|
+
"fraudReport.picker.filters.invalidAmount": "Introduza um montante válido.",
|
|
236
|
+
"fraudReport.picker.filters.startAfterEnd": "A data de início não pode ser posterior à data de fim.",
|
|
237
|
+
"fraudReport.picker.filters.startDate": "Data de início",
|
|
238
|
+
"fraudReport.picker.limitExceeded": "Pode comunicar até {max} transações de cada vez. Remova {count} para continuar.",
|
|
239
|
+
"fraudReport.picker.loadMore": "Carregar mais transações",
|
|
240
|
+
"fraudReport.picker.noMatchTitle": "Nenhuma transação corresponde a estes filtros",
|
|
241
|
+
"fraudReport.picker.noneYetTitle": "Ainda não foi encontrada nenhuma transação",
|
|
242
|
+
"fraudReport.picker.search": "Pesquisar",
|
|
243
|
+
"fraudReport.picker.selectAll": "Selecionar todas as transações",
|
|
244
|
+
"fraudReport.picker.selectTransaction": "Selecionar {counterparty}, {amount}, {date}",
|
|
245
|
+
"fraudReport.picker.title": "Selecionar transações",
|
|
182
246
|
"fraudReport.step.confirmation": "Confirmação",
|
|
183
247
|
"fraudReport.step.details": "Detalhes",
|
|
184
248
|
"fraudReport.step.documents": "Documentos",
|
|
@@ -190,6 +254,7 @@
|
|
|
190
254
|
"fraudReport.transactions.description": "Selecione as transações relacionadas com a fraude que está a comunicar.",
|
|
191
255
|
"fraudReport.transactions.emptySubtitle": "Selecione pelo menos uma transação para continuar.",
|
|
192
256
|
"fraudReport.transactions.emptyTitle": "Nenhuma transação",
|
|
257
|
+
"fraudReport.transactions.limit": "Pode comunicar até {max} transações de cada vez.",
|
|
193
258
|
"fraudReport.transactions.listTitle": "Transações",
|
|
194
259
|
"fraudReport.transactions.paidTo": "Pago a",
|
|
195
260
|
"fraudReport.transactions.paymentMethod": "Método de pagamento",
|
|
@@ -204,11 +269,21 @@
|
|
|
204
269
|
"fraudReport.transactions.title": "Selecione as transações a comunicar",
|
|
205
270
|
"fraudReport.transactions.total": "Montante total: <highlight>{amount}</highlight>",
|
|
206
271
|
"fraudReport.transactions.transactionId": "ID da transação",
|
|
272
|
+
"fraudReport.transfer.action.bankOrBeneficiary": "Banco ou beneficiário",
|
|
273
|
+
"fraudReport.transfer.action.police": "Polícia",
|
|
274
|
+
"fraudReport.transfer.actionsLabel": "Selecione todas as opções aplicáveis",
|
|
275
|
+
"fraudReport.transfer.actionsPlaceholder": "Selecionar",
|
|
276
|
+
"fraudReport.transfer.actionsTitle": "Selecione a quem comunicou a fraude",
|
|
277
|
+
"fraudReport.victim.changeConfirm": "Mudar de vítima",
|
|
278
|
+
"fraudReport.victim.changeMessage": "As transações com cartão que selecionou pertencem à vítima anterior e serão removidas desta comunicação. As transferências continuam selecionadas.",
|
|
279
|
+
"fraudReport.victim.changeMessageCardsOnly": "As transações com cartão que selecionou pertencem à vítima anterior e serão removidas desta comunicação.",
|
|
280
|
+
"fraudReport.victim.changeTitle": "Mudar de vítima?",
|
|
207
281
|
"fraudReport.victim.description": "Escolha a vítima dos pagamentos fraudulentos. Só pode comunicar a fraude de uma vítima de cada vez.",
|
|
208
282
|
"fraudReport.victim.forYourself": "Está a comunicar uma fraude em nome próprio?",
|
|
209
283
|
"fraudReport.victim.memberHelp": "Só um membro que possa gerir as associações da conta pode fazer uma comunicação em nome de outra pessoa.",
|
|
210
284
|
"fraudReport.victim.memberLabel": "Em nome de quem está a fazer a comunicação?",
|
|
211
285
|
"fraudReport.victim.reportingFor": "Está a fazer a comunicação em nome de: <highlight>{name}</highlight>",
|
|
286
|
+
"fraudReport.victim.searchMember": "Pesquisar um membro",
|
|
212
287
|
"fraudReport.victim.title": "Identidade da vítima",
|
|
213
288
|
"monthlyPaymentVolume.between10000And50000": "Entre 10.000€ e 50.000€ por mês",
|
|
214
289
|
"monthlyPaymentVolume.between50000And100000": "Entre 50.000€ e 100.000€ por mês",
|
|
@@ -446,6 +521,7 @@
|
|
|
446
521
|
"transactionStatement.type.SepaInstantCreditTransferIn": "Transferência de crédito instantânea SEPA recebida",
|
|
447
522
|
"transactionStatement.type.SepaInstantCreditTransferOut": "Transferência de crédito instantânea SEPA enviada",
|
|
448
523
|
"validation.birthdateCannotBeFuture": "A data de nascimento não pode estar no futuro",
|
|
524
|
+
"validation.birthdateMustBeAdult": "Deve ter pelo menos 18 anos",
|
|
449
525
|
"validation.invalidBirthDate": "Por favor, introduza uma data de nascimento válida.",
|
|
450
526
|
"validation.invalidDate": "Por favor, introduza uma data válida."
|
|
451
527
|
}
|
package/src/utils/SwanFile.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { getCardActions, toCardValues } from "../fraudReport/card";
|
|
3
|
+
describe("getCardActions", () => {
|
|
4
|
+
test("selects the actions answered yes", () => {
|
|
5
|
+
expect(getCardActions({ hasContactedMerchant: true, hasFiledPoliceComplaint: true })).toEqual([
|
|
6
|
+
"Merchant",
|
|
7
|
+
"Police",
|
|
8
|
+
]);
|
|
9
|
+
});
|
|
10
|
+
test("selects nothing for actions answered no or not answered", () => {
|
|
11
|
+
expect(getCardActions({ hasContactedMerchant: false, hasFiledPoliceComplaint: undefined })).toEqual([]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe("toCardValues", () => {
|
|
15
|
+
test("sends the noticed date and the selected actions when the card was lost or stolen", () => {
|
|
16
|
+
expect(toCardValues({
|
|
17
|
+
isLostOrStolen: true,
|
|
18
|
+
lostOrStolenNoticedAt: "2026-10-21",
|
|
19
|
+
actions: ["Merchant", "Police"],
|
|
20
|
+
})).toEqual({
|
|
21
|
+
isLostOrStolen: true,
|
|
22
|
+
lostOrStolenNoticedAt: "2026-10-21",
|
|
23
|
+
hasContactedMerchant: true,
|
|
24
|
+
hasFiledPoliceComplaint: true,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
test.each([false, undefined])("clears the noticed date when lost or stolen is %s", isLostOrStolen => {
|
|
28
|
+
expect(toCardValues({ isLostOrStolen, lostOrStolenNoticedAt: "2026-10-21", actions: [] })
|
|
29
|
+
.lostOrStolenNoticedAt).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
test("leaves an unselected action empty instead of sending false", () => {
|
|
32
|
+
expect(toCardValues({ isLostOrStolen: undefined, lostOrStolenNoticedAt: undefined, actions: [] })).toEqual({
|
|
33
|
+
isLostOrStolen: undefined,
|
|
34
|
+
lostOrStolenNoticedAt: undefined,
|
|
35
|
+
hasContactedMerchant: undefined,
|
|
36
|
+
hasFiledPoliceComplaint: undefined,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { getGroupFiles, setGroupFiles } from "../fraudReport/documents";
|
|
3
|
+
const file = (id) => ({
|
|
4
|
+
id,
|
|
5
|
+
name: `${id}.pdf`,
|
|
6
|
+
statusInfo: { status: "Uploaded" },
|
|
7
|
+
});
|
|
8
|
+
const document = (id, purpose) => ({
|
|
9
|
+
purpose,
|
|
10
|
+
file: file(id),
|
|
11
|
+
});
|
|
12
|
+
const documents = [
|
|
13
|
+
document("police", "PoliceReport"),
|
|
14
|
+
document("evidence", "FraudEvidence"),
|
|
15
|
+
document("correspondence", "DisputeCorrespondence"),
|
|
16
|
+
document("other", "Other"),
|
|
17
|
+
];
|
|
18
|
+
describe("getGroupFiles", () => {
|
|
19
|
+
test("lists the police reports in the police report group", () => {
|
|
20
|
+
expect(getGroupFiles(documents, "PoliceReport")).toEqual([file("police")]);
|
|
21
|
+
});
|
|
22
|
+
test("lists every other purpose in the other documents group", () => {
|
|
23
|
+
expect(getGroupFiles(documents, "OtherDocuments")).toEqual([
|
|
24
|
+
file("evidence"),
|
|
25
|
+
file("correspondence"),
|
|
26
|
+
file("other"),
|
|
27
|
+
]);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe("setGroupFiles", () => {
|
|
31
|
+
test("gives a new file the purpose its group uploads with", () => {
|
|
32
|
+
expect(setGroupFiles([], "PoliceReport", [file("new")])).toEqual([
|
|
33
|
+
document("new", "PoliceReport"),
|
|
34
|
+
]);
|
|
35
|
+
expect(setGroupFiles([], "OtherDocuments", [file("new")])).toEqual([
|
|
36
|
+
document("new", "FraudEvidence"),
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
test("keeps the purpose of a file already in the group", () => {
|
|
40
|
+
expect(setGroupFiles(documents, "OtherDocuments", [file("correspondence"), file("other")])).toEqual([
|
|
41
|
+
document("police", "PoliceReport"),
|
|
42
|
+
document("correspondence", "DisputeCorrespondence"),
|
|
43
|
+
document("other", "Other"),
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
test("keeps the other group's documents when a group changes", () => {
|
|
47
|
+
expect(setGroupFiles(documents, "PoliceReport", [])).toEqual([
|
|
48
|
+
document("evidence", "FraudEvidence"),
|
|
49
|
+
document("correspondence", "DisputeCorrespondence"),
|
|
50
|
+
document("other", "Other"),
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
test("keeps the file's new status", () => {
|
|
54
|
+
const uploading = {
|
|
55
|
+
id: "new",
|
|
56
|
+
name: "new.pdf",
|
|
57
|
+
statusInfo: { status: "Uploading", progress: 0.5 },
|
|
58
|
+
};
|
|
59
|
+
expect(setGroupFiles([{ purpose: "PoliceReport", file: uploading }], "PoliceReport", [file("new")])).toEqual([document("new", "PoliceReport")]);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { getSharedInformationChoice, toSharedInformation } from "../fraudReport/fraudster";
|
|
3
|
+
describe("getSharedInformationChoice", () => {
|
|
4
|
+
test.each([undefined, []])("leaves the question unanswered for %j", shared => {
|
|
5
|
+
expect(getSharedInformationChoice(shared)).toEqual({ answer: undefined, items: [] });
|
|
6
|
+
});
|
|
7
|
+
test("answers No when nothing was shared", () => {
|
|
8
|
+
expect(getSharedInformationChoice(["None"])).toEqual({ answer: "No", items: [] });
|
|
9
|
+
expect(getSharedInformationChoice(["None", "CardDetails"])).toEqual({
|
|
10
|
+
answer: "No",
|
|
11
|
+
items: [],
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
test("answers Yes with what was shared", () => {
|
|
15
|
+
expect(getSharedInformationChoice(["VerificationCode", "CardDetails"])).toEqual({
|
|
16
|
+
answer: "Yes",
|
|
17
|
+
items: ["VerificationCode", "CardDetails"],
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe("toSharedInformation", () => {
|
|
22
|
+
test("sends None for No, even with items picked before", () => {
|
|
23
|
+
expect(toSharedInformation({ answer: "No", items: ["CardDetails"] })).toEqual(["None"]);
|
|
24
|
+
});
|
|
25
|
+
test("sends what was shared for Yes", () => {
|
|
26
|
+
expect(toSharedInformation({ answer: "Yes", items: ["SwanPasscode", "BankDetails"] })).toEqual([
|
|
27
|
+
"SwanPasscode",
|
|
28
|
+
"BankDetails",
|
|
29
|
+
]);
|
|
30
|
+
});
|
|
31
|
+
test("leaves the answer empty for Yes with nothing picked, or no answer", () => {
|
|
32
|
+
expect(toSharedInformation({ answer: "Yes", items: [] })).toBeUndefined();
|
|
33
|
+
expect(toSharedInformation({ answer: undefined, items: ["CardDetails"] })).toBeUndefined();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import en from "../../locales/en.json";
|
|
3
|
+
import { getTransactionsLimitMessage } from "../fraudReport/messages";
|
|
4
|
+
import { MAX_TRANSACTIONS } from "../fraudReport/transactions";
|
|
5
|
+
test("gives the limit of a report", () => {
|
|
6
|
+
expect(getTransactionsLimitMessage()).toBe(`You can report up to ${MAX_TRANSACTIONS} transactions at a time.`);
|
|
7
|
+
});
|
|
8
|
+
test("gives the limit the API rejection carries", () => {
|
|
9
|
+
expect(getTransactionsLimitMessage({ max: 50 })).toBe("You can report up to 50 transactions at a time.");
|
|
10
|
+
});
|
|
11
|
+
test("says how many transactions to remove", () => {
|
|
12
|
+
expect(getTransactionsLimitMessage({ toRemove: 2 })).toBe(`You can report up to ${MAX_TRANSACTIONS} transactions at a time. Remove 2 to continue.`);
|
|
13
|
+
});
|
|
14
|
+
test("says how many to remove with the limit the API rejection carries", () => {
|
|
15
|
+
expect(getTransactionsLimitMessage({ max: 50, toRemove: 2 })).toBe("You can report up to 50 transactions at a time. Remove 2 to continue.");
|
|
16
|
+
});
|
|
17
|
+
test("asks to remove nothing when nothing is over the limit", () => {
|
|
18
|
+
expect(getTransactionsLimitMessage({ toRemove: 0 })).toBe(getTransactionsLimitMessage());
|
|
19
|
+
});
|
|
20
|
+
test.each([
|
|
21
|
+
"fraudReport.transactions.limit",
|
|
22
|
+
"fraudReport.picker.limitExceeded",
|
|
23
|
+
"fraudReport.picker.description",
|
|
24
|
+
"fraudReport.intro.rule.transactions",
|
|
25
|
+
])("%s takes the limit as an argument", key => {
|
|
26
|
+
expect(en[key]).toContain("{max}");
|
|
27
|
+
expect(en[key]).not.toContain(String(MAX_TRANSACTIONS));
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { createFakeTransaction } from "../fraudReport/fakeApi";
|
|
3
|
+
import { countPagesWithoutRows, getPickerTransactions, getSelectAllValue, restartPickerPages, toggleAllTransactions, toggleTransaction, } from "../fraudReport/picker";
|
|
4
|
+
const victimCard = createFakeTransaction("card-victim", "CardOutDebit");
|
|
5
|
+
const otherCard = createFakeTransaction("card-other", "CardOutDebit");
|
|
6
|
+
const sepa = createFakeTransaction("transfer-sepa", "SepaCreditTransferOut");
|
|
7
|
+
const instant = createFakeTransaction("transfer-instant", "SepaInstantCreditTransferOut");
|
|
8
|
+
const international = createFakeTransaction("transfer-international", "InternationalCreditTransferOut");
|
|
9
|
+
const internal = createFakeTransaction("transfer-internal", "InternalCreditTransferOut");
|
|
10
|
+
const rows = [
|
|
11
|
+
{ transaction: victimCard, cardAccountMembershipId: "member-victim", alreadyReported: false },
|
|
12
|
+
{ transaction: otherCard, cardAccountMembershipId: "member-other", alreadyReported: false },
|
|
13
|
+
{ transaction: sepa, cardAccountMembershipId: null, alreadyReported: false },
|
|
14
|
+
{ transaction: instant, cardAccountMembershipId: null, alreadyReported: false },
|
|
15
|
+
{ transaction: international, cardAccountMembershipId: null, alreadyReported: false },
|
|
16
|
+
{ transaction: internal, cardAccountMembershipId: null, alreadyReported: false },
|
|
17
|
+
];
|
|
18
|
+
describe("getPickerTransactions", () => {
|
|
19
|
+
test("lists a card transaction only when its card belongs to the victim", () => {
|
|
20
|
+
const listed = getPickerTransactions(rows, "member-victim");
|
|
21
|
+
expect(listed).toContain(victimCard);
|
|
22
|
+
expect(listed).not.toContain(otherCard);
|
|
23
|
+
});
|
|
24
|
+
test("lists every transfer, whoever the victim is", () => {
|
|
25
|
+
expect(getPickerTransactions(rows, "member-other")).toEqual([
|
|
26
|
+
otherCard,
|
|
27
|
+
sepa,
|
|
28
|
+
instant,
|
|
29
|
+
international,
|
|
30
|
+
internal,
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
test("lists no card transaction while the victim isn't known", () => {
|
|
34
|
+
expect(getPickerTransactions(rows, undefined)).toEqual([
|
|
35
|
+
sepa,
|
|
36
|
+
instant,
|
|
37
|
+
international,
|
|
38
|
+
internal,
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
test("leaves out a card transaction whose card has no known account membership", () => {
|
|
42
|
+
expect(getPickerTransactions([{ transaction: victimCard, cardAccountMembershipId: null, alreadyReported: false }], "member-victim")).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
test("keeps the order of the rows and removes duplicates", () => {
|
|
45
|
+
expect(getPickerTransactions([
|
|
46
|
+
{ transaction: sepa, cardAccountMembershipId: null, alreadyReported: false },
|
|
47
|
+
{
|
|
48
|
+
transaction: victimCard,
|
|
49
|
+
cardAccountMembershipId: "member-victim",
|
|
50
|
+
alreadyReported: false,
|
|
51
|
+
},
|
|
52
|
+
{ transaction: sepa, cardAccountMembershipId: null, alreadyReported: false },
|
|
53
|
+
], "member-victim")).toEqual([sepa, victimCard]);
|
|
54
|
+
});
|
|
55
|
+
test("leaves out a transaction already in a submitted case", () => {
|
|
56
|
+
expect(getPickerTransactions([
|
|
57
|
+
{ transaction: sepa, cardAccountMembershipId: null, alreadyReported: true },
|
|
58
|
+
{
|
|
59
|
+
transaction: victimCard,
|
|
60
|
+
cardAccountMembershipId: "member-victim",
|
|
61
|
+
alreadyReported: true,
|
|
62
|
+
},
|
|
63
|
+
{ transaction: instant, cardAccountMembershipId: null, alreadyReported: false },
|
|
64
|
+
], "member-victim")).toEqual([instant]);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe("toggleTransaction", () => {
|
|
68
|
+
test("adds a transaction that isn't selected, after the others", () => {
|
|
69
|
+
expect(toggleTransaction([sepa], victimCard)).toEqual([sepa, victimCard]);
|
|
70
|
+
});
|
|
71
|
+
test("removes a selected transaction, matched by ID", () => {
|
|
72
|
+
expect(toggleTransaction([sepa, victimCard], { ...sepa, counterparty: "Renamed" })).toEqual([
|
|
73
|
+
victimCard,
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe("getSelectAllValue", () => {
|
|
78
|
+
test("is false when no listed transaction is selected", () => {
|
|
79
|
+
expect(getSelectAllValue([otherCard], [sepa, instant])).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
test("is mixed when some listed transactions are selected", () => {
|
|
82
|
+
expect(getSelectAllValue([sepa], [sepa, instant])).toBe("mixed");
|
|
83
|
+
});
|
|
84
|
+
test("is true when every listed transaction is selected", () => {
|
|
85
|
+
expect(getSelectAllValue([instant, sepa, otherCard], [sepa, instant])).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
test("is false when nothing is listed", () => {
|
|
88
|
+
expect(getSelectAllValue([sepa], [])).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe("toggleAllTransactions", () => {
|
|
92
|
+
test("selects the listed transactions that aren't selected yet", () => {
|
|
93
|
+
expect(toggleAllTransactions([instant], [sepa, instant, internal])).toEqual([
|
|
94
|
+
instant,
|
|
95
|
+
sepa,
|
|
96
|
+
internal,
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
test("unselects the listed transactions when all of them are selected", () => {
|
|
100
|
+
expect(toggleAllTransactions([sepa, instant], [sepa, instant])).toEqual([]);
|
|
101
|
+
});
|
|
102
|
+
test("keeps a selected transaction that isn't listed, both ways", () => {
|
|
103
|
+
expect(toggleAllTransactions([otherCard], [sepa])).toEqual([otherCard, sepa]);
|
|
104
|
+
expect(toggleAllTransactions([otherCard, sepa], [sepa])).toEqual([otherCard]);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe("countPagesWithoutRows", () => {
|
|
108
|
+
const start = { rowCount: 20, listedCount: 4, withoutRows: 0, restarted: false };
|
|
109
|
+
test("counts a page that adds no listed row", () => {
|
|
110
|
+
expect(countPagesWithoutRows(start, 40, 4)).toEqual({
|
|
111
|
+
rowCount: 40,
|
|
112
|
+
listedCount: 4,
|
|
113
|
+
withoutRows: 1,
|
|
114
|
+
restarted: false,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
test("keeps counting over pages in a row", () => {
|
|
118
|
+
const second = countPagesWithoutRows(countPagesWithoutRows(start, 40, 4), 60, 4);
|
|
119
|
+
expect(second.withoutRows).toBe(2);
|
|
120
|
+
});
|
|
121
|
+
test("starts again from zero when a page adds a listed row", () => {
|
|
122
|
+
const empty = countPagesWithoutRows(start, 40, 4);
|
|
123
|
+
expect(countPagesWithoutRows(empty, 60, 5)).toEqual({
|
|
124
|
+
rowCount: 60,
|
|
125
|
+
listedCount: 5,
|
|
126
|
+
withoutRows: 0,
|
|
127
|
+
restarted: false,
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
test("doesn't count a render with no new page", () => {
|
|
131
|
+
const empty = countPagesWithoutRows(start, 40, 4);
|
|
132
|
+
expect(countPagesWithoutRows(empty, 40, 4)).toBe(empty);
|
|
133
|
+
});
|
|
134
|
+
test("doesn't count the rows being cleared", () => {
|
|
135
|
+
const paused = { ...start, withoutRows: 3 };
|
|
136
|
+
expect(countPagesWithoutRows(paused, 0, 0)).toEqual({
|
|
137
|
+
rowCount: 0,
|
|
138
|
+
listedCount: 0,
|
|
139
|
+
withoutRows: 0,
|
|
140
|
+
restarted: false,
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
test("starts again when fewer rows come back: it is another list", () => {
|
|
144
|
+
const long = { rowCount: 60, listedCount: 10, withoutRows: 2, restarted: false };
|
|
145
|
+
expect(countPagesWithoutRows(long, 20, 3).withoutRows).toBe(0);
|
|
146
|
+
expect(countPagesWithoutRows(long, 20, 0).withoutRows).toBe(1);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe("restartPickerPages", () => {
|
|
150
|
+
const paused = { rowCount: 20, listedCount: 10, withoutRows: 3, restarted: false };
|
|
151
|
+
test("ends the pause right away", () => {
|
|
152
|
+
expect(restartPickerPages(paused).withoutRows).toBe(0);
|
|
153
|
+
});
|
|
154
|
+
test("makes the next rows a first page, even when they are more than before", () => {
|
|
155
|
+
const restarted = restartPickerPages(paused);
|
|
156
|
+
expect(countPagesWithoutRows(restarted, 40, 3)).toEqual({
|
|
157
|
+
rowCount: 40,
|
|
158
|
+
listedCount: 3,
|
|
159
|
+
withoutRows: 0,
|
|
160
|
+
restarted: false,
|
|
161
|
+
});
|
|
162
|
+
expect(countPagesWithoutRows(restarted, 40, 0).withoutRows).toBe(1);
|
|
163
|
+
});
|
|
164
|
+
test("waits for the rows to change", () => {
|
|
165
|
+
const restarted = restartPickerPages(paused);
|
|
166
|
+
expect(countPagesWithoutRows(restarted, 20, 10)).toBe(restarted);
|
|
167
|
+
});
|
|
168
|
+
test("counts a first page with as many rows as before, once the load ended", () => {
|
|
169
|
+
const restarted = restartPickerPages(paused);
|
|
170
|
+
expect(countPagesWithoutRows(restarted, 20, 0, true)).toEqual({
|
|
171
|
+
rowCount: 20,
|
|
172
|
+
listedCount: 0,
|
|
173
|
+
withoutRows: 1,
|
|
174
|
+
restarted: false,
|
|
175
|
+
});
|
|
176
|
+
expect(countPagesWithoutRows(restarted, 20, 4, true).withoutRows).toBe(0);
|
|
177
|
+
});
|
|
178
|
+
test("the end of a load counts no page when the list wasn't replaced", () => {
|
|
179
|
+
expect(countPagesWithoutRows(paused, 20, 10, true)).toBe(paused);
|
|
180
|
+
});
|
|
181
|
+
test("counts the pages after the first one as usual", () => {
|
|
182
|
+
const first = countPagesWithoutRows(restartPickerPages(paused), 40, 3);
|
|
183
|
+
expect(countPagesWithoutRows(first, 60, 3).withoutRows).toBe(1);
|
|
184
|
+
expect(countPagesWithoutRows(first, 60, 4).withoutRows).toBe(0);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|