Skip to content

Commit 2b49106

Browse files
authored
Merge branch 'main' into feat/lw-9145-tx-summary-refactor
2 parents a6d2223 + 26e6e11 commit 2b49106

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

packages/core/src/ui/components/Activity/AssetActivityItem.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,11 @@
123123
line-height: size_unit(3);
124124
}
125125
}
126+
127+
.negativeBalance {
128+
color: var(--data-orange);
129+
}
130+
131+
.positiveBalance {
132+
color: var(--data-green);
133+
}

packages/core/src/ui/components/Activity/AssetActivityItem.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React, { useMemo, useRef, useEffect, useCallback } from 'react';
33
import debounce from 'lodash/debounce';
44
import { Image, Tooltip } from 'antd';
5+
import cn from 'classnames';
56
import Icon from '@ant-design/icons';
67
import { getTextWidth } from '@lace/common';
78
import { ReactComponent as PendingIcon } from '../../assets/icons/pending.component.svg';
@@ -96,6 +97,8 @@ const translationTypes = {
9697
self: 'package.core.assetActivityItem.entry.name.self'
9798
};
9899

100+
const negativeBalanceStyling: Set<ActivityType> = new Set(['outgoing', 'delegationRegistration', 'self', 'delegation']);
101+
99102
// TODO: Handle pluralization and i18n of assetsNumber when we will have more than Ada.
100103
export const AssetActivityItem = ({
101104
amount,
@@ -176,6 +179,8 @@ export const AssetActivityItem = ({
176179
assetAmountContent
177180
);
178181

182+
const isNegativeBalance = negativeBalanceStyling.has(type);
183+
179184
return (
180185
<div data-testid="asset-activity-item" onClick={onClick} className={styles.assetActivityItem}>
181186
<div className={styles.leftSide}>
@@ -196,9 +201,19 @@ export const AssetActivityItem = ({
196201
</div>
197202
</div>
198203
<div data-testid="asset-amount" className={styles.rightSide}>
199-
<h6 data-testid="total-amount" className={styles.title} ref={ref}>
204+
<h6
205+
data-testid="total-amount"
206+
className={cn(styles.title, {
207+
[styles.negativeBalance]: isNegativeBalance,
208+
[styles.positiveBalance]: !isNegativeBalance
209+
})}
210+
ref={ref}
211+
>
200212
<span>
201-
{assetsText.text}
213+
<span data-testid="balance">
214+
{isNegativeBalance ? '-' : ''}
215+
{assetsText.text}
216+
</span>
202217
{assetsText.suffix && (
203218
<Tooltip
204219
overlayClassName={styles.tooltip}

packages/core/src/ui/components/Activity/__tests__/AssetActivityItem.test.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import { render, within, fireEvent, queryByTestId } from '@testing-library/react';
44
import '@testing-library/jest-dom';
55
import { AssetActivityItem, AssetActivityItemProps, ActivityStatus } from '../AssetActivityItem';
6+
import { ActivityType } from '../../ActivityDetail';
67

78
const assetsAmountTestId = 'asset-amount';
89

@@ -21,8 +22,8 @@ describe('Testing AssetActivityItem component', () => {
2122

2223
const assetActivityItemId = 'asset-activity-item';
2324

24-
test('should render an asset activity item', async () => {
25-
const { findByTestId } = render(<AssetActivityItem {...props} />);
25+
test('should render an asset activity item with type incoming', async () => {
26+
const { findByTestId } = render(<AssetActivityItem {...props} type="incoming" />);
2627
const activityItem = await findByTestId(assetActivityItemId);
2728

2829
const activityIcon = await findByTestId('asset-icon');
@@ -43,6 +44,16 @@ describe('Testing AssetActivityItem component', () => {
4344
expect(activityFiatAmountText).toBeVisible();
4445
});
4546

47+
['outgoing', 'delegationRegistration', 'self', 'delegation'].forEach((type) => {
48+
test(`should apply negative balance for: ${type} activity`, async () => {
49+
const { findByTestId } = render(<AssetActivityItem {...props} type={type as ActivityType} />);
50+
51+
const totalAmount = await findByTestId('balance');
52+
53+
expect(totalAmount).toHaveTextContent(`-${props.amount}`);
54+
});
55+
});
56+
4657
test('should render an asset activity item with proper assets text when there is enough space to show assets info', async () => {
4758
const elWidth = 100;
4859
Object.defineProperties(window.HTMLElement.prototype, {
@@ -53,7 +64,7 @@ describe('Testing AssetActivityItem component', () => {
5364
const { findByTestId } = render(<AssetActivityItem {...props} />);
5465

5566
const activityAmount = await findByTestId(assetsAmountTestId);
56-
const tickerText = `${props.amount}, ${props.assets[0].val} ${props.assets[0].info.ticker}`;
67+
const tickerText = `-${props.amount}, ${props.assets[0].val} ${props.assets[0].info.ticker}`;
5768
const activityAssetTickerText = await within(activityAmount).findByText(tickerText);
5869

5970
expect(activityAssetTickerText).toBeVisible();

packages/e2e-tests/src/pageobject/menuHeaderPageObject.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class MenuHeaderPageObject {
44
async clickMenuButton() {
55
await MenuHeader.menuButton.waitForClickable({ timeout: 16_000 });
66
await MenuHeader.menuButton.click();
7-
await MenuHeader.menuWalletName.waitForStable();
87
}
98

109
async clickUserDetailsButton() {

0 commit comments

Comments
 (0)