Skip to content

Commit 6a207ed

Browse files
[DDW-857][DEBT] Integrate Chromatic (#2776)
1 parent 66f9ea0 commit 6a207ed

File tree

11 files changed

+126
-86
lines changed

11 files changed

+126
-86
lines changed

.github/workflows/chromatic.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Chromatic'
2+
on: push
3+
jobs:
4+
chromatic-deployment:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v1
8+
- name: Setup Node.js
9+
uses: actions/setup-node@v2
10+
with:
11+
node-version: "14"
12+
- name: Install dependencies
13+
run: yarn
14+
- name: Publish to Chromatic
15+
if: github.ref != 'refs/heads/develop'
16+
uses: chromaui/action@v1
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
20+
exitZeroOnChanges: true
21+
- name: Publish to Chromatic and auto accept changes
22+
if: github.ref == 'refs/heads/develop'
23+
uses: chromaui/action@v1
24+
with:
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
27+
autoAcceptChanges: true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Chores
1010

11+
- Integrated Chromatic for visual regression testing ([PR 2776](https://github.com/input-output-hk/daedalus/pull/2776))
1112
- Updated `trezor-connect` dependency to version `8.2.4` ([PR 2726](https://github.com/input-output-hk/daedalus/pull/2726))
1213
- Updated vulnerable dependencies ([PR 2769](https://github.com/input-output-hk/daedalus/pull/2769))
1314
- Updated CWB and Cardano Node ([PR 2799](https://github.com/input-output-hk/daedalus/pull/2799))

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
"react-syntax-highlighter": "13.5.3",
157157
"regenerator-runtime": "0.13.7",
158158
"sass-loader": "7.1.0",
159+
"seedrandom": "3.0.5",
159160
"sinon": "9.2.2",
160161
"spawn-sync": "2.0.0",
161162
"spectron": "14.0.0",
@@ -164,6 +165,7 @@
164165
"stylelint-order": "4.1.0",
165166
"svg-inline-loader": "0.8.2",
166167
"thread-loader": "2.1.3",
168+
"timemachine": "0.3.2",
167169
"transform-loader": "0.2.4",
168170
"url-loader": "2.0.1",
169171
"utf-8-validate": "5.0.2",

source/renderer/app/components/loading/syncing-connecting/LogosDisplay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class LogosDisplay extends Component<Props> {
4848
return (
4949
<div className={styles.component}>
5050
<SVGInline svg={adaLogo} className={currencyLogoStyles} />
51-
<div className={daedalusLogoStyles}>
51+
<div className={daedalusLogoStyles} data-chromatic="ignore">
5252
<Lottie options={logoAnimationOptionsLottie} />
5353
</div>
5454
<SVGInline svg={cardanoLogo} className={apiLogoStyles} />

source/renderer/app/components/wallet/settings/ICOPublicKeyQRCodeDialog.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import Dialog from '../../widgets/Dialog';
1111
import iconCopy from '../../../assets/images/clipboard-ic.inline.svg';
1212
import styles from './PublicKeyQRCodeDialog.scss';
1313
import globalMessages from '../../../i18n/global-messages';
14-
import type { ReactIntlMessage } from '../../../types/i18nTypes';
14+
15+
import { messages } from './ICOPublicKeyQRCodeDialog.messages';
1516

1617
type Props = {
1718
walletName: string,
1819
walletPublicKey: string,
1920
onCopyWalletPublicKey: Function,
2021
onClose: Function,
21-
messages: { [string]: ReactIntlMessage },
2222
derivationPath: string,
2323
intl: intlShape.isRequired,
2424
};
@@ -29,7 +29,6 @@ const ICOPublicKeyQRCodeDialog = observer((props: Props) => {
2929
walletPublicKey,
3030
onCopyWalletPublicKey,
3131
onClose,
32-
messages,
3332
derivationPath,
3433
intl,
3534
} = props;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// @flow
2+
import { defineMessages } from 'react-intl';
3+
import type { ReactIntlMessage } from '../../../types/i18nTypes';
4+
5+
export const messages: {
6+
[string]: ReactIntlMessage,
7+
} = defineMessages({
8+
dialogTitle: {
9+
id: 'wallet.settings.icoPublicKey',
10+
defaultMessage: '!!!ICO Public Key',
11+
description: 'Title for the "ICO Public Key QR Code" dialog.',
12+
},
13+
copyPublicKeyLabel: {
14+
id: 'wallet.settings.copyICOPublicKey',
15+
defaultMessage: '!!!Copy ICO public key',
16+
description: 'Copy ICO public key label.',
17+
},
18+
derivationPathTooltip: {
19+
id: 'wallet.settings.dialog.derivationPathTooltip',
20+
defaultMessage: '!!!Derivation path',
21+
description: 'Tooltip for the derivation path',
22+
},
23+
});

source/renderer/app/containers/wallet/dialogs/settings/PublicKeyQRCodeDialogContainer.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,6 @@ const walletMessages: {
3333
},
3434
});
3535

36-
const icoMessages: {
37-
[string]: ReactIntlMessage,
38-
} = defineMessages({
39-
dialogTitle: {
40-
id: 'wallet.settings.icoPublicKey',
41-
defaultMessage: '!!!ICO Public Key',
42-
description: 'Title for the "ICO Public Key QR Code" dialog.',
43-
},
44-
copyPublicKeyLabel: {
45-
id: 'wallet.settings.copyICOPublicKey',
46-
defaultMessage: '!!!Copy ICO public key',
47-
description: 'Copy ICO public key label.',
48-
},
49-
derivationPathTooltip: {
50-
id: 'wallet.settings.dialog.derivationPathTooltip',
51-
defaultMessage: '!!!Derivation path',
52-
description: 'Tooltip for the derivation path',
53-
},
54-
});
55-
5636
type Props = InjectedProps;
5737

5838
@inject('actions', 'stores')
@@ -107,7 +87,6 @@ export default class PublicKeyQRCodeDialogContainer extends Component<Props> {
10787
onClose={() => {
10888
actions.dialogs.closeActiveDialog.trigger();
10989
}}
110-
messages={icoMessages}
11190
derivationPath={ICO_PUBLIC_KEY_DERIVATION_PATH}
11291
/>
11392
);

source/renderer/app/i18n/locales/defaultMessages.json

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11714,6 +11714,53 @@
1171411714
],
1171511715
"path": "source/renderer/app/components/wallet/settings/ICOPublicKeyDialog.json"
1171611716
},
11717+
{
11718+
"descriptors": [
11719+
{
11720+
"defaultMessage": "!!!ICO Public Key",
11721+
"description": "Title for the \"ICO Public Key QR Code\" dialog.",
11722+
"end": {
11723+
"column": 3,
11724+
"line": 12
11725+
},
11726+
"file": "source/renderer/app/components/wallet/settings/ICOPublicKeyQRCodeDialog.messages.js",
11727+
"id": "wallet.settings.icoPublicKey",
11728+
"start": {
11729+
"column": 15,
11730+
"line": 8
11731+
}
11732+
},
11733+
{
11734+
"defaultMessage": "!!!Copy ICO public key",
11735+
"description": "Copy ICO public key label.",
11736+
"end": {
11737+
"column": 3,
11738+
"line": 17
11739+
},
11740+
"file": "source/renderer/app/components/wallet/settings/ICOPublicKeyQRCodeDialog.messages.js",
11741+
"id": "wallet.settings.copyICOPublicKey",
11742+
"start": {
11743+
"column": 22,
11744+
"line": 13
11745+
}
11746+
},
11747+
{
11748+
"defaultMessage": "!!!Derivation path",
11749+
"description": "Tooltip for the derivation path",
11750+
"end": {
11751+
"column": 3,
11752+
"line": 22
11753+
},
11754+
"file": "source/renderer/app/components/wallet/settings/ICOPublicKeyQRCodeDialog.messages.js",
11755+
"id": "wallet.settings.dialog.derivationPathTooltip",
11756+
"start": {
11757+
"column": 25,
11758+
"line": 18
11759+
}
11760+
}
11761+
],
11762+
"path": "source/renderer/app/components/wallet/settings/ICOPublicKeyQRCodeDialog.messages.json"
11763+
},
1171711764
{
1171811765
"descriptors": [
1171911766
{
@@ -17524,41 +17571,13 @@
1752417571
"description": "Tooltip for the derivation path",
1752517572
"end": {
1752617573
"column": 3,
17527-
"line": 53
17574+
"line": 33
1752817575
},
1752917576
"file": "source/renderer/app/containers/wallet/dialogs/settings/PublicKeyQRCodeDialogContainer.js",
1753017577
"id": "wallet.settings.dialog.derivationPathTooltip",
1753117578
"start": {
1753217579
"column": 25,
17533-
"line": 49
17534-
}
17535-
},
17536-
{
17537-
"defaultMessage": "!!!ICO Public Key",
17538-
"description": "Title for the \"ICO Public Key QR Code\" dialog.",
17539-
"end": {
17540-
"column": 3,
17541-
"line": 43
17542-
},
17543-
"file": "source/renderer/app/containers/wallet/dialogs/settings/PublicKeyQRCodeDialogContainer.js",
17544-
"id": "wallet.settings.icoPublicKey",
17545-
"start": {
17546-
"column": 15,
17547-
"line": 39
17548-
}
17549-
},
17550-
{
17551-
"defaultMessage": "!!!Copy ICO public key",
17552-
"description": "Copy ICO public key label.",
17553-
"end": {
17554-
"column": 3,
17555-
"line": 48
17556-
},
17557-
"file": "source/renderer/app/containers/wallet/dialogs/settings/PublicKeyQRCodeDialogContainer.js",
17558-
"id": "wallet.settings.copyICOPublicKey",
17559-
"start": {
17560-
"column": 22,
17561-
"line": 44
17580+
"line": 29
1756217581
}
1756317582
}
1756417583
],

storybook/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import React from 'react';
33
import { configure, addDecorator } from '@storybook/react';
4+
import timemachine from 'timemachine';
45
import StoryWrapper from './stories/_support/StoryWrapper';
56
import '!style-loader!css-loader!sass-loader!../source/renderer/app/themes/index.global.scss'; // eslint-disable-line
67

@@ -13,3 +14,7 @@ function loadStories() {
1314
}
1415

1516
configure(loadStories, module);
17+
18+
timemachine.config({
19+
dateString: 'Sat, 01 Jan 2022 10:00:00 GMT',
20+
});

storybook/stories/_support/utils.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import hash from 'hash.js';
33
import faker from 'faker';
44
import JSONBigInt from 'json-bigint';
55
import moment from 'moment';
6-
import { random, get } from 'lodash';
6+
import { get } from 'lodash';
77
import BigNumber from 'bignumber.js';
8+
import seedrandom from 'seedrandom';
89
import Wallet, {
910
WalletSyncStateStatuses,
1011
} from '../../../source/renderer/app/domains/Wallet';
@@ -34,6 +35,8 @@ import type {
3435
import type { SyncStateStatus } from '../../../source/renderer/app/api/wallets/types';
3536
import type { TransactionMetadata } from '../../../source/renderer/app/types/TransactionMetadata';
3637

38+
const random = seedrandom('daedalus', { global: false });
39+
3740
export const EXAMPLE_METADATA = JSONBigInt.parse(`{
3841
"0": {
3942
"string": "some string"
@@ -81,19 +84,11 @@ export const EXAMPLE_METADATA = JSONBigInt.parse(`{
8184
}`);
8285

8386
export const generateHash = () => {
84-
const now = new Date().valueOf().toString();
85-
return hash
86-
.sha512()
87-
.update(now + random(0.1, 0.9))
88-
.digest('hex');
87+
return hash.sha512().update(random().toString()).digest('hex');
8988
};
9089

9190
export const generatePolicyIdHash = () => {
92-
const now = new Date().valueOf().toString();
93-
return hash
94-
.sha224()
95-
.update(now + random(0.1, 0.9))
96-
.digest('hex');
91+
return hash.sha224().update(random().toString()).digest('hex');
9792
};
9893

9994
const statusProgress = (status) =>

0 commit comments

Comments
 (0)