diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/History.stories.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/History.stories.tsx | 515 |
1 files changed, 375 insertions, 140 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx index 1674ac135..482b8d698 100644 --- a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx @@ -20,10 +20,14 @@ */ import { + AmountString, PaymentStatus, + RefreshReason, + ScopeType, TalerProtocolTimestamp, TransactionCommon, TransactionDeposit, + TransactionMajorState, TransactionPayment, TransactionPeerPullCredit, TransactionPeerPullDebit, @@ -31,16 +35,15 @@ import { TransactionPeerPushDebit, TransactionRefresh, TransactionRefund, - TransactionTip, TransactionType, TransactionWithdrawal, WithdrawalType, } from "@gnu-taler/taler-util"; import { HistoryView as TestedComponent } from "./History.js"; -import { createExample } from "../test-utils.js"; +import * as tests from "@gnu-taler/web-util/testing"; export default { - title: "balance", + title: "history", component: TestedComponent, }; @@ -49,12 +52,14 @@ const commonTransaction = (): TransactionCommon => ({ amountRaw: "USD:10", amountEffective: "USD:9", - pending: false, + txState: { + major: TransactionMajorState.Done, + }, timestamp: TalerProtocolTimestamp.fromSeconds( new Date().getTime() / 1000 - count++ * 60 * 60 * 7, ), transactionId: String(count), - } as TransactionCommon); + }) as TransactionCommon; const exampleData = { withdraw: { @@ -66,12 +71,14 @@ const exampleData = { confirmed: false, exchangePaytoUris: ["payto://x-taler-bank/bank/account"], type: WithdrawalType.ManualTransfer, + reserveIsReady: false, }, } as TransactionWithdrawal, payment: { ...commonTransaction(), - amountEffective: "USD:11", + amountEffective: "USD:11" as AmountString, type: TransactionType.Payment, + posConfirmation: undefined, info: { contractTermsHash: "ASDZXCASD", merchant: { @@ -84,10 +91,11 @@ const exampleData = { }, refunds: [], refundPending: undefined, - totalRefundEffective: "USD:0", - totalRefundRaw: "USD:0", + totalRefundEffective: "USD:0" as AmountString, + totalRefundRaw: "USD:0" as AmountString, proposalId: "1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0", status: PaymentStatus.Accepted, + refundQueryActive: false, } as TransactionPayment, deposit: { ...commonTransaction(), @@ -98,27 +106,21 @@ const exampleData = { refresh: { ...commonTransaction(), type: TransactionType.Refresh, + refreshInputAmount: "USD:1" as AmountString, + refreshOutputAmount: "USD:0.5" as AmountString, exchangeBaseUrl: "http://exchange.taler", + refreshReason: RefreshReason.PayMerchant, } as TransactionRefresh, - tip: { - ...commonTransaction(), - type: TransactionType.Tip, - merchantBaseUrl: "http://ads.merchant.taler.net/", - } as TransactionTip, refund: { ...commonTransaction(), type: TransactionType.Refund, refundedTransactionId: "payment:1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0", - info: { - contractTermsHash: "ASDZXCASD", + paymentInfo: { merchant: { name: "the merchant", }, - orderId: "2021.167-03NPY6MCYMVGT", - products: [], summary: "the summary", - fulfillmentMessage: "", }, refundPending: undefined, } as TransactionRefund, @@ -160,228 +162,461 @@ const exampleData = { } as TransactionPeerPullDebit, }; -export const NoBalance = createExample(TestedComponent, { - transactions: [], - balances: [], -}); - -export const SomeBalanceWithNoTransactions = createExample(TestedComponent, { - transactions: [], - balances: [ - { - available: "TESTKUDOS:10", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", - hasPendingTransactions: false, - requiresUserInput: false, +export const SomeBalanceWithNoTransactions = tests.createExample( + TestedComponent, + { + transactionsByDate: { + "11/11/11": [], }, - ], -}); + balances: [ + { + available: "TESTKUDOS:10" as AmountString, + flags: [], + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, + hasPendingTransactions: false, + requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, + }, + ], + balanceIndex: 0, + }, +); -export const OneSimpleTransaction = createExample(TestedComponent, { - transactions: [exampleData.withdraw], +export const OneSimpleTransaction = tests.createExample(TestedComponent, { + transactionsByDate: { + "11/11/11": [exampleData.withdraw], + }, balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }); -export const TwoTransactionsAndZeroBalance = createExample(TestedComponent, { - transactions: [exampleData.withdraw, exampleData.deposit], - balances: [ - { - available: "USD:0", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", - hasPendingTransactions: false, - requiresUserInput: false, +export const TwoTransactionsAndZeroBalance = tests.createExample( + TestedComponent, + { + transactionsByDate: { + "11/11/11": [exampleData.withdraw, exampleData.deposit], }, - ], -}); + balances: [ + { + flags: [], + available: "USD:0" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, + hasPendingTransactions: false, + requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, + }, + ], + balanceIndex: 0, + }, +); -export const OneTransactionPending = createExample(TestedComponent, { - transactions: [ - { - ...exampleData.withdraw, - pending: true, - }, - ], +export const OneTransactionPending = tests.createExample(TestedComponent, { + transactionsByDate: { + "11/11/11": [ + { + ...exampleData.withdraw, + txState: { + major: TransactionMajorState.Pending, + }, + }, + ], + }, balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }); -export const SomeTransactions = createExample(TestedComponent, { - transactions: [ - exampleData.withdraw, - exampleData.payment, - exampleData.withdraw, - exampleData.payment, - { - ...exampleData.payment, - info: { - ...exampleData.payment.info, - summary: - "this is a long summary that may be cropped because its too long", +export const SomeTransactions = tests.createExample(TestedComponent, { + transactionsByDate: { + "11/11/11": [ + exampleData.withdraw, + exampleData.payment, + exampleData.withdraw, + exampleData.payment, + { + ...exampleData.payment, + info: { + ...exampleData.payment.info, + summary: + "this is a long summary that may be cropped because its too long", + }, }, - }, - exampleData.refund, - exampleData.tip, - exampleData.deposit, - ], + exampleData.refund, + exampleData.deposit, + ], + }, balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }); -export const SomeTransactionsWithTwoCurrencies = createExample( +export const SomeTransactionsInDifferentStates = tests.createExample( TestedComponent, { - transactions: [ - exampleData.withdraw, - exampleData.payment, - exampleData.withdraw, - exampleData.payment, - exampleData.refresh, - exampleData.refund, - exampleData.tip, - exampleData.deposit, + transactionsByDate: { + "11/11/11": [ + exampleData.withdraw, + { + ...exampleData.withdraw, + exchangeBaseUrl: "https://aborted/withdrawal", + txState: { + major: TransactionMajorState.Aborted, + }, + }, + { + ...exampleData.withdraw, + exchangeBaseUrl: "https://pending/withdrawal", + txState: { + major: TransactionMajorState.Pending, + }, + }, + { + ...exampleData.withdraw, + exchangeBaseUrl: "https://failed/withdrawal", + txState: { + major: TransactionMajorState.Failed, + }, + }, + { + ...exampleData.payment, + info: { + ...exampleData.payment.info, + summary: "normal payment", + }, + }, + { + ...exampleData.payment, + info: { + ...exampleData.payment.info, + summary: "aborting in progress", + }, + txState: { + major: TransactionMajorState.Aborting, + }, + }, + { + ...exampleData.payment, + info: { + ...exampleData.payment.info, + summary: "aborted payment", + }, + txState: { + major: TransactionMajorState.Aborted, + }, + }, + { + ...exampleData.payment, + info: { + ...exampleData.payment.info, + summary: "pending payment", + }, + txState: { + major: TransactionMajorState.Pending, + }, + }, + { + ...exampleData.payment, + info: { + ...exampleData.payment.info, + summary: "failed payment", + }, + txState: { + major: TransactionMajorState.Failed, + }, + }, + exampleData.refund, + exampleData.deposit, + ], + }, + balances: [ + { + flags: [], + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, + hasPendingTransactions: false, + requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, + }, ], + balanceIndex: 0, + }, +); + +export const SomeTransactionsWithTwoCurrencies = tests.createExample( + TestedComponent, + { + transactionsByDate: { + "11/11/11": [ + exampleData.withdraw, + exampleData.payment, + exampleData.withdraw, + exampleData.payment, + exampleData.refresh, + exampleData.refund, + exampleData.deposit, + ], + }, balances: [ { - available: "USD:0", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:0" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "TESTKUDOS:10", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "TESTKUDOS:10" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }, ); -export const FiveOfficialCurrencies = createExample(TestedComponent, { - transactions: [exampleData.withdraw], +export const FiveOfficialCurrencies = tests.createExample(TestedComponent, { + transactionsByDate: { + "11/11/11": [exampleData.withdraw], + }, balances: [ { - available: "USD:1000", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:1000" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "EUR:881", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "EUR:881" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "COL:4043000.5", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "COL:4043000.5" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "JPY:11564450.6", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "JPY:11564450.6" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "GBP:736", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "GBP:736" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }); -export const FiveOfficialCurrenciesWithHighValue = createExample( +export const FiveOfficialCurrenciesWithHighValue = tests.createExample( TestedComponent, { - transactions: [exampleData.withdraw], + transactionsByDate: { + "11/11/11": [exampleData.withdraw], + }, balances: [ { - available: "USD:881001321230000", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:881001321230000" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "EUR:10", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "EUR:10" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "COL:443000123123000.5123123", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "COL:443000123123000.5123123" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, requiresUserInput: false, }, { - available: "JPY:1564450000000.6123123", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "JPY:1564450000000.6123123" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, { - available: "GBP:736001231231200.23123", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + flags: [], + available: "GBP:736001231231200.23123" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }, ); -export const PeerToPeer = createExample(TestedComponent, { - transactions: [ - exampleData.pull_credit, - exampleData.pull_debit, - exampleData.push_credit, - exampleData.push_debit, - ], +export const PeerToPeer = tests.createExample(TestedComponent, { + transactionsByDate: { + "11/11/11": [ + exampleData.pull_credit, + exampleData.pull_debit, + exampleData.push_credit, + exampleData.push_debit, + ], + }, balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + flags: [], + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, + scopeInfo: { + currency: "Ásd", + type: ScopeType.Auditor, + url: "", + }, }, ], + balanceIndex: 0, }); |