Skip to content

Commit 71b0a9b

Browse files
authored
PP-14616 transactions list view cypress tests (#4852)
- Cypress tests for transactions list view - Includes pagination, search/filtering and CSV download
1 parent 6975b54 commit 71b0a9b

File tree

9 files changed

+907
-21
lines changed

9 files changed

+907
-21
lines changed

.secrets.baseline

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,42 +278,42 @@
278278
"filename": "src/views/simplified-account/transactions/index.njk",
279279
"hashed_secret": "8a764e7de8baf91c09a0141c9d0653d6c62300fa",
280280
"is_verified": false,
281-
"line_number": 136
281+
"line_number": 140
282282
},
283283
{
284284
"type": "Base64 High Entropy String",
285285
"filename": "src/views/simplified-account/transactions/index.njk",
286286
"hashed_secret": "c15bfbed4cf339878d4c69339491df034b592627",
287287
"is_verified": false,
288-
"line_number": 142
288+
"line_number": 146
289289
},
290290
{
291291
"type": "Base64 High Entropy String",
292292
"filename": "src/views/simplified-account/transactions/index.njk",
293293
"hashed_secret": "09ea33e2341efbf111c4eb12a709ae94c96a7e51",
294294
"is_verified": false,
295-
"line_number": 150
295+
"line_number": 154
296296
},
297297
{
298298
"type": "Base64 High Entropy String",
299299
"filename": "src/views/simplified-account/transactions/index.njk",
300300
"hashed_secret": "d9d993cc5556aa0fa6e18b26fdfd4fa8527db044",
301301
"is_verified": false,
302-
"line_number": 155
302+
"line_number": 159
303303
},
304304
{
305305
"type": "Base64 High Entropy String",
306306
"filename": "src/views/simplified-account/transactions/index.njk",
307307
"hashed_secret": "ce50854e96f8dd430451450f2e7334e4b48db7f0",
308308
"is_verified": false,
309-
"line_number": 160
309+
"line_number": 164
310310
},
311311
{
312312
"type": "Base64 High Entropy String",
313313
"filename": "src/views/simplified-account/transactions/index.njk",
314314
"hashed_secret": "34f47d2f3c482850fd7f6de8564a8aa73afe87bc",
315315
"is_verified": false,
316-
"line_number": 165
316+
"line_number": 169
317317
}
318318
],
319319
"src/views/transactions/index.njk": [
@@ -794,5 +794,5 @@
794794
}
795795
]
796796
},
797-
"generated_at": "2026-03-03T13:42:18Z"
797+
"generated_at": "2026-03-05T12:26:11Z"
798798
}

src/controllers/simplified-account/services/transactions/transaction-list.controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
WorldpayStatusFilters,
1414
} from '@utils/simplified-account/services/transactions/status-filters'
1515

16+
const LEDGER_TRANSACTION_COUNT_LIMIT = 5000
17+
1618
const getUrlGenerator = (filters: Record<string, string>, transactionsUrl: string) => {
1719
const getPath = (pageNumber: number) => {
1820
const params = new URLSearchParams(filters)
@@ -69,6 +71,10 @@ async function get(req: ServiceRequest, res: ServiceResponse) {
6971
)
7072
const downloadQueryString = transactionSearchParams.getQueryParams().toString()
7173
const downloadLink = downloadQueryString.length ? `${downloadUrl}?${downloadQueryString}` : downloadUrl
74+
const transactionCountWithinRange = results.total > 0 && results.total <= LEDGER_TRANSACTION_COUNT_LIMIT
75+
const hasQueryParams = transactionSearchParams.getQueryParams().toString().length
76+
const showCsvDownload =
77+
transactionCountWithinRange || (hasQueryParams && results.total > LEDGER_TRANSACTION_COUNT_LIMIT)
7278

7379
return response(req, res, 'simplified-account/transactions/index', {
7480
results,
@@ -80,6 +86,7 @@ async function get(req: ServiceRequest, res: ServiceResponse) {
8086
cardBrands: [{ value: '', text: 'Any' }, ...cardBrands],
8187
statuses: eventStates,
8288
downloadLink,
89+
showCsvDownload,
8390
})
8491
}
8592

src/models/transaction/TransactionDisplayValues.class.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export class TransactionDisplayValues {
2323
}
2424

2525
get netAmount(): string {
26+
if (this.isRefund && this.transaction.state.status === Status.SUCCESS) {
27+
return penceToPoundsWithCurrency(-this.transaction.amount)
28+
}
29+
30+
if (this.isDispute && this.transaction.state.status === Status.LOST) {
31+
return penceToPoundsWithCurrency(-this.transaction.netAmount!)
32+
}
33+
2634
return this.transaction.netAmount ? penceToPoundsWithCurrency(this.transaction.netAmount) : ''
2735
}
2836

src/views/simplified-account/transactions/index.njk

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% set fullWidth = true %}
44

55
{% block pageTitle %}
6-
Transactions - {{ currentService.name }} {{ currentGatewayAccount.full_type }} - GOV.UK Pay
6+
Transactions - {{ currentService.name }} - GOV.UK Pay
77
{% endblock %}
88

99
{% block beforeContent %}
@@ -83,13 +83,17 @@
8383
</form>
8484
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible" />
8585

86-
{{
87-
govukButton({
88-
text: "Download CSV",
89-
classes: "govuk-button--secondary",
90-
href: downloadLink
91-
})
92-
}}
86+
{% if (showCsvDownload) %}
87+
{{
88+
govukButton({
89+
text: "Download CSV",
90+
classes: "govuk-button--secondary",
91+
href: downloadLink
92+
})
93+
}}
94+
{% elif (results.transactions.length) %}
95+
<p id="csv-download" class="govuk-body">Filter results to download a CSV of transactions</p>
96+
{% endif %}
9397

9498
{% if isBST %}
9599
<details class="govuk-details">

src/views/simplified-account/transactions/macro/_stripe-transaction-row.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{{ transaction.cardDetails.cardBrand }}
3636
</td>
3737
<td class="govuk-table__cell govuk-!-font-size-16 state vertical-align-middle">
38-
{{ transaction.formattedStatus }}
38+
{{ transaction._locals.formatted.status }}
3939
</td>
4040
<td
4141
style="text-align: left"

src/views/simplified-account/transactions/macro/_worldpay-transaction-row.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
>
2020
<td class="govuk-table__cell amount govuk-!-font-size-16 vertical-align-middle" id="amount">
2121
{%- if transaction.totalAmount and transaction.corporateCardSurcharge -%}
22-
{{ transaction._locals.formatted.signedAmount }}
22+
{{ transaction._locals.formatted.totalAmount }}
2323
<span class="govuk-!-display-block govuk-!-font-size-16">(with card fee)</span>
2424
{%- else -%}
25-
<span style="white-space: pre">{{ transaction._locals.formatted.amount }}</span>
25+
<span style="white-space: pre">{{ transaction._locals.formatted.signedAmount }}</span>
2626
{%- endif -%}
2727
</td>
2828
<td class="govuk-table__cell govuk-!-font-size-16 brand vertical-align-middle">

0 commit comments

Comments
 (0)