-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Bonus Pagamenti Digitali): [#175741693] Remove timestamp from transactions when it's equal to 00:00 #2734
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d1197a5
[#175741693] Modified BdpTransactionItem, BdpTransactionDetailCompone…
ebd3759
Merge branch 'master' into 175741693-transaction-timestamp
debiff b607b66
[#175741693] Purged useless comments. Factored out common logic using…
ae12afb
Merge branch '175741693-transaction-timestamp' of https://github.com/…
7741a43
[#175741693] Inverted amount and date in BpdTransactionItem
9801a64
Merge branch 'master' into 175741693-transaction-timestamp
fabriziofff ea16453
[#175741693] Added seconds to isMidNight flag
4545da0
Merge branch '175741693-transaction-timestamp' of https://github.com/…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
ts/features/bonus/bpd/components/transactionItem/__test__/BdpTransactionItem.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { getSubtitle } from "../BpdTransactionItem"; | ||
import { EnhancedBpdTransaction } from "../../../components/transactionItem/BpdTransactionItem"; | ||
import { HPan } from "../../../store/actions/paymentMethods"; | ||
import { AwardPeriodId } from "../../../store/actions/periods"; | ||
|
||
describe("Test how the transaction subtitle changes with different timestamps", () => { | ||
it("Subtitle shouldn't contain hours and minutes, when the transaction has a timestamp 00:00", () => { | ||
const myTransaction: EnhancedBpdTransaction = { | ||
hashPan: "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan, | ||
idTrxAcquirer: "10126487773E", | ||
idTrxIssuer: "R64692", | ||
amount: 87.79, | ||
awardPeriodId: 2 as AwardPeriodId, | ||
image: 29, | ||
maxCashbackForTransactionAmount: 15, | ||
title: "xxxxxxx", | ||
trxDate: new Date("2100-12-17T00:00"), | ||
keyId: "xxxxxxxxx", | ||
cashback: 8.779, | ||
circuitType: "Mastercard" | ||
}; | ||
|
||
expect(getSubtitle(myTransaction)).toMatch("€ 87.79 · 17 Dec "); | ||
}); | ||
|
||
it("Subtitle should contain hours and minutes when the transaction has a timestamp 00:00", () => { | ||
const myTransaction: EnhancedBpdTransaction = { | ||
hashPan: "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan, | ||
idTrxAcquirer: "10126487773E", | ||
idTrxIssuer: "R64692", | ||
amount: 100000.79, | ||
awardPeriodId: 2 as AwardPeriodId, | ||
image: 29, | ||
maxCashbackForTransactionAmount: 15, | ||
title: "xxxxxxx", | ||
trxDate: new Date("2100-12-19T12:39"), | ||
keyId: "xxxxxxxxx", | ||
cashback: 8.779, | ||
circuitType: "Mastercard" | ||
}; | ||
|
||
expect(getSubtitle(myTransaction)).toMatch("€ 100,000.79 · 19 Dec, 12:39 "); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,58 +57,73 @@ const CancelBadge = () => ( | |
</Badge> | ||
); | ||
|
||
const Table = (props: Props) => ( | ||
<View> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("payment.details.info.dateAndTime")} | ||
</H5> | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"}> | ||
{localeDateFormat( | ||
props.transaction.trxDate, | ||
I18n.t("global.dateFormats.fullFormatShortMonthLiteralWithTime") | ||
)} | ||
</H4> | ||
</View> | ||
<View spacer={true} small={true} /> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("bonus.bpd.details.transaction.detail.paymentCircuit")} | ||
</H5> | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"}> | ||
{props.transaction.circuitType === "Unknown" | ||
? I18n.t("global.unknown") | ||
: props.transaction.circuitType} | ||
</H4> | ||
</View> | ||
<View spacer={true} small={true} /> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("bonus.bpd.details.transaction.detail.transactionAmount")} | ||
</H5> | ||
const Table = (props: Props) => { | ||
const isMidNight = | ||
props.transaction.trxDate.getHours() + | ||
props.transaction.trxDate.getMinutes() === | ||
0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same consideration about considering the seconds of the previous comment. |
||
return ( | ||
<View> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"} testID="dateLabel"> | ||
{isMidNight | ||
? I18n.t("payment.details.info.onlyDate") | ||
: I18n.t("payment.details.info.dateAndTime")} | ||
</H5> | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"} testID="dateValue"> | ||
{isMidNight | ||
? localeDateFormat( | ||
props.transaction.trxDate, | ||
I18n.t( | ||
"global.dateFormats.fullFormatShortMonthLiteralWithoutTime" | ||
) | ||
) | ||
: localeDateFormat( | ||
props.transaction.trxDate, | ||
I18n.t("global.dateFormats.fullFormatShortMonthLiteralWithTime") | ||
)} | ||
</H4> | ||
</View> | ||
<View spacer={true} small={true} /> | ||
<View style={styles.rowId}> | ||
{props.transaction.amount < 0 && ( | ||
<> | ||
<CancelBadge /> | ||
<View hspacer={true} /> | ||
</> | ||
)} | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("bonus.bpd.details.transaction.detail.paymentCircuit")} | ||
</H5> | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"}> | ||
{formatNumberAmount(props.transaction.amount, true)} | ||
{props.transaction.circuitType === "Unknown" | ||
? I18n.t("global.unknown") | ||
: props.transaction.circuitType} | ||
</H4> | ||
</View> | ||
<View spacer={true} small={true} /> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("bonus.bpd.details.transaction.detail.transactionAmount")} | ||
</H5> | ||
<View style={styles.rowId}> | ||
{props.transaction.amount < 0 && ( | ||
<> | ||
<CancelBadge /> | ||
<View hspacer={true} /> | ||
</> | ||
)} | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"}> | ||
{formatNumberAmount(props.transaction.amount, true)} | ||
</H4> | ||
</View> | ||
</View> | ||
<View spacer={true} small={true} /> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("bonus.bpd.details.transaction.detail.cashbackAmount")} | ||
</H5> | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"}> | ||
{formatNumberAmount(props.transaction.cashback, true)} | ||
</H4> | ||
</View> | ||
</View> | ||
<View spacer={true} small={true} /> | ||
<View style={styles.rowId}> | ||
<H5 weight={"Regular"} color={"bluegrey"}> | ||
{I18n.t("bonus.bpd.details.transaction.detail.cashbackAmount")} | ||
</H5> | ||
<H4 weight={"SemiBold"} color={"bluegreyDark"}> | ||
{formatNumberAmount(props.transaction.cashback, true)} | ||
</H4> | ||
</View> | ||
</View> | ||
); | ||
); | ||
}; | ||
|
||
const IdBlock = (props: IdBlockProps) => ( | ||
<View> | ||
|
64 changes: 64 additions & 0 deletions
64
...us/bpd/screens/details/transaction/detail/__test__/BdpTransactionDetailComponent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// import { debug } from "console"; | ||
import * as React from "react"; | ||
import { render } from "@testing-library/react-native"; | ||
import { BpdTransactionDetailComponent } from "../BpdTransactionDetailComponent"; | ||
import { EnhancedBpdTransaction } from "../../../../../components/transactionItem/BpdTransactionItem"; | ||
import { HPan } from "../../../../../store/actions/paymentMethods"; | ||
import { AwardPeriodId } from "../../../../../store/actions/periods"; | ||
|
||
describe("Test Transaction Timestamp", () => { | ||
it("It should render label 'Date' and a value without hours and minutes when the transaction has a timestamp 00:00", () => { | ||
const myTransaction: EnhancedBpdTransaction = { | ||
hashPan: "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan, | ||
idTrxAcquirer: "10126487773E", | ||
idTrxIssuer: "R64692", | ||
amount: 87.79, | ||
awardPeriodId: 2 as AwardPeriodId, | ||
image: 29, | ||
maxCashbackForTransactionAmount: 15, | ||
title: "xxxxxxx", | ||
trxDate: new Date("2100-12-17T00:00"), | ||
keyId: "xxxxxxxxx", | ||
cashback: 8.779, | ||
circuitType: "Mastercard" | ||
}; | ||
|
||
// cut : Component Under Test | ||
const cut = render( | ||
<BpdTransactionDetailComponent transaction={myTransaction} /> | ||
); | ||
|
||
const dateLabel = cut.getByTestId("dateLabel"); | ||
const dateValue = cut.getByTestId("dateValue"); | ||
|
||
expect(dateLabel.children[0]).toMatch(/Date/); | ||
expect(dateValue.children[0]).toMatch(/17 Dec 2100/); | ||
}); | ||
|
||
it("It should render label 'Date and time' and a vale woth hours and minutes when the transaction has a timestamp different from 00:00 ", () => { | ||
const myTransaction: EnhancedBpdTransaction = { | ||
hashPan: "0d4194712c5d820fcbbb2e7ba199e15f73cfd43f8fe49f0aa62e7901253506df" as HPan, | ||
idTrxAcquirer: "10126487773E", | ||
idTrxIssuer: "R64692", | ||
amount: 87.79, | ||
awardPeriodId: 2 as AwardPeriodId, | ||
image: 29, | ||
maxCashbackForTransactionAmount: 0, | ||
title: "xxxxxxx", | ||
trxDate: new Date("2100-12-17T01:00"), | ||
keyId: "xxxxxxxxx", | ||
cashback: 8.779, | ||
circuitType: "Mastercard" | ||
}; | ||
|
||
// cut : Component Under Test | ||
const cut = render( | ||
<BpdTransactionDetailComponent transaction={myTransaction} /> | ||
); | ||
const dateLabel = cut.getByTestId("dateLabel"); | ||
const dateValue = cut.getByTestId("dateValue"); | ||
|
||
expect(dateLabel.children[0]).toMatch(/Date and time/); | ||
expect(dateValue.children[0]).toMatch(/17 Dec 2100, 01:00/); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you think about adding also the seconds to the calculation?
In this way we can render the time for a transaction with timestamp
2020-12-13T00:00:31+01:00
that is a valid transaction.