Skip to content

Commit 955c3da

Browse files
committed
fix(suite): Fix test for colors
1 parent 0dec043 commit 955c3da

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

packages/components/src/components/DataAnalytics.tsx

+10-17
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { FormattedMessage } from 'react-intl';
33

44
import styled from 'styled-components';
55

6-
import { spacingsPx } from '@trezor/theme';
6+
import { spacingsPx, typography } from '@trezor/theme';
77

8-
import { variables } from '../config';
98
import { Card } from './Card/Card';
109
import { CollapsibleBox } from './CollapsibleBox/CollapsibleBox';
1110
import { Button } from './buttons/Button/Button';
@@ -32,30 +31,23 @@ const ButtonWrapper = styled.div`
3231
align-self: center;
3332
`;
3433

35-
const StyledButton = styled(Button)`
36-
min-width: 180px;
37-
`;
38-
3934
const Label = styled.span`
4035
margin-left: ${spacingsPx.lg};
41-
font-size: ${variables.FONT_SIZE.SMALL};
42-
font-weight: ${variables.FONT_WEIGHT.MEDIUM};
43-
color: ${({ theme }) => theme.legacy.TYPE_DARK_GREY};
36+
${typography.hint};
37+
color: ${({ theme }) => theme.textDefault};
4438
align-items: center;
4539
display: flex;
4640
`;
4741

4842
const Heading = styled.h2`
49-
font-size: ${variables.FONT_SIZE.SMALL};
50-
font-weight: ${variables.FONT_WEIGHT.DEMI_BOLD};
51-
color: ${({ theme }) => theme.legacy.TYPE_DARK_GREY};
43+
${typography.callout};
44+
color: ${({ theme }) => theme.textDefault};
5245
text-align: left;
5346
`;
5447

5548
const Description = styled.span`
56-
font-size: ${variables.FONT_SIZE.SMALL};
57-
font-weight: ${variables.FONT_WEIGHT.MEDIUM};
58-
color: ${({ theme }) => theme.legacy.TYPE_LIGHT_GREY};
49+
${typography.hint};
50+
color: ${({ theme }) => theme.textSubdued};
5951
`;
6052

6153
const Category = styled.div`
@@ -185,12 +177,13 @@ export const DataAnalytics = ({
185177
</ContentWrapper>
186178

187179
<ButtonWrapper>
188-
<StyledButton
180+
<Button
189181
data-testid="@analytics/continue-button"
190182
onClick={() => onConfirm(trackingEnabled)}
183+
minWidth={180}
191184
>
192185
<FormattedMessage id="TR_CONFIRM" defaultMessage="Confirm" />
193-
</StyledButton>
186+
</Button>
194187
</ButtonWrapper>
195188
</Wrapper>
196189
</Card>

packages/suite-desktop-core/e2e/tests/settings/autodetect.test.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import { palette } from '@trezor/theme';
2+
import { hexToRgba } from '@trezor/utils';
3+
14
import { expect, test } from '../../support/fixtures';
25

3-
const veryDarkGreyColor = 'rgb(23, 23, 23)';
4-
const darkGreyColor = 'rgb(31, 31, 31)';
5-
const veryLightGreyColor = 'rgb(246, 246, 246)';
6-
const lightGreyColor = 'rgb(234, 235, 237)';
6+
const veryDarkGreyColor = palette.darkGray50;
7+
const darkGreyColor = palette.lightGray1000;
8+
const veryLightGreyColor = palette.lightGray100;
9+
const lightGreyColor = palette.lightWhiteAlpha1000;
710
enum ColorScheme {
811
Light = 'light',
912
Dark = 'dark',
@@ -40,10 +43,10 @@ testCases.forEach(({ testName, userPreferences, text, textColor, bodyBackgroundC
4043
test(testName, async ({ onboardingPage, analyticsSection }) => {
4144
await onboardingPage.optionallyDismissFwHashCheckError();
4245
await expect(analyticsSection.heading).toHaveText(text);
43-
await expect(analyticsSection.heading).toHaveCSS('color', textColor);
46+
await expect(analyticsSection.heading).toHaveCSS('color', hexToRgba(textColor));
4447
await expect(onboardingPage.page.locator('body')).toHaveCSS(
4548
'background-color',
46-
bodyBackgroundColor,
49+
hexToRgba(bodyBackgroundColor),
4750
);
4851
});
4952
});

packages/utils/src/hexToRgba.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
export function hexToRgba(hex: string, alpha: number) {
1+
export function hexToRgba(hex: string, alpha?: number) {
22
const r = parseInt(hex.slice(1, 3), 16);
33
const g = parseInt(hex.slice(3, 5), 16);
44
const b = parseInt(hex.slice(5, 7), 16);
55

6-
if (alpha > 0) {
6+
if (alpha && alpha > 0) {
77
return `rgba(${r}, ${g}, ${b}, ${alpha})` as `rgba(${number}, ${number}, ${number}, ${number})`;
88
}
99

0 commit comments

Comments
 (0)