Skip to content

Commit 9e5cf7d

Browse files
authored
test(extension): add tests for shared wallet feature [LW-12755] (#1860)
* test(extension): add LW-11818 and LW-11819 * test(extension): disable LW-11822 on Firefox * test(extension): update selectors after upgrading UI-toolkit * test(extension): update UI toolkit dependencies and selectors
1 parent eb0ceff commit 9e5cf7d

File tree

46 files changed

+1670
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1670
-26
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@cardano-sdk/crypto": "0.2.3",
4747
"@cardano-sdk/wallet": "0.52.6",
4848
"@cardano-sdk/web-extension": "0.39.6",
49-
"@input-output-hk/lace-ui-toolkit": "3.5.0",
49+
"@input-output-hk/lace-ui-toolkit": "3.8.0",
5050
"@lace/cardano": "0.1.0",
5151
"@lace/common": "0.1.0",
5252
"@lace/translation": "0.1.0",

packages/core/src/shared-wallets/add-shared-wallet/SharedWalletLayout/SharedWalletLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const SharedWalletLayout = <Key extends string>(props: SharedWalletLayout
9191
<Flex h="$fill" w="$fill" className={styles.root}>
9292
<Timeline className={styles.timeline}>
9393
{parseTimelineSteps(timelineSteps, timelineCurrentStep).map(({ current, marked, name }) => (
94-
<Timeline.Item key={name} active={marked}>
94+
<Timeline.Item key={name} active={marked} data-testid={`${marked ? 'active' : 'inactive'}-onboarding-step`}>
9595
<Box className={cn({ [`${styles.activeText}`]: current })}>{name}</Box>
9696
</Timeline.Item>
9797
))}

packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSignerInput.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const AddCoSignerInput = ({
7373
errorMessage={(dirty?.name && errorMessage.name) || undefined}
7474
onChange={makeChangeHandler('name')}
7575
w="$fill"
76+
data-testid="identifier"
7677
/>
7778
</Box>
7879
<Box>
@@ -83,6 +84,7 @@ export const AddCoSignerInput = ({
8384
onChange={makeChangeHandler('sharedWalletKey')}
8485
w="$fill"
8586
disabled={keyFieldDisabled}
87+
data-testid="shared-wallet-key"
8688
/>
8789
</Box>
8890
</>

packages/core/src/shared-wallets/add-shared-wallet/creation-flow/ImportantInfoDialog/ImportantInfoDialog.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,33 @@ export const ImportantInfoDialog = ({ onBack, onNext, open, zIndex }: Props): JS
2121
</Dialog.Title>
2222
<Dialog.Description>
2323
<>
24-
<Text.Body.Normal weight="$medium">
24+
<Text.Body.Normal weight="$medium" data-testid="dialog-subtitle">
2525
{t('sharedWallets.addSharedWallet.importantInfo.subtitle')}
2626
</Text.Body.Normal>
2727
<Flex>
2828
<Box mt="$4">
29-
<Checkbox checked={checked} onClick={() => setChecked(!checked)} />
29+
<Checkbox checked={checked} onClick={() => setChecked(!checked)} data-testid="dialog-checkbox" />
3030
</Box>
3131
<Box ml="$10" onClick={() => setChecked(!checked)} className={styles.checkBoxLabel}>
32-
<Text.Body.Small weight="$semibold">
32+
<Text.Body.Small weight="$semibold" data-testid="dialog-checkbox-label">
3333
{t('sharedWallets.addSharedWallet.importantInfo.checkBoxLabel')}
3434
</Text.Body.Small>
3535
</Box>
3636
</Flex>
3737
</>
3838
</Dialog.Description>
3939
<Dialog.Actions>
40-
<Dialog.Action cancel label={t('sharedWallets.addSharedWallet.importantInfo.button.back')} onClick={onBack} />
40+
<Dialog.Action
41+
cancel
42+
label={t('sharedWallets.addSharedWallet.importantInfo.button.back')}
43+
onClick={onBack}
44+
testId="dialog-back-button"
45+
/>
4146
<Dialog.Action
4247
disabled={!checked}
4348
label={t('sharedWallets.addSharedWallet.importantInfo.button.next')}
4449
onClick={onNext}
50+
testId="dialog-next-button"
4551
/>
4652
</Dialog.Actions>
4753
</Dialog.Root>

packages/core/src/shared-wallets/add-shared-wallet/creation-flow/Quorum/QuorumOption.component.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,15 @@ export const QuorumOption = ({
137137
onChange={onNumberOfCosignerChange}
138138
showArrow
139139
zIndex={1001}
140+
triggerTestId="number-of-cosigners-dropdown-trigger"
140141
>
141142
{cosignersNumberPickerOptions.map((num) => (
142-
<Select.Item key={num} value={num} title={num} />
143+
<Select.Item key={num} value={num} title={num} testId={num} />
143144
))}
144145
</Select.Root>
145-
<Text.Body.Small>{translations.cosignersAmountPickerText}</Text.Body.Small>
146+
<Text.Body.Small data-testid="total-signatures-label">
147+
{translations.cosignersAmountPickerText}
148+
</Text.Body.Small>
146149
</Flex>
147150
</Flex>
148151
</Card.Outlined>

packages/core/src/shared-wallets/add-shared-wallet/creation-flow/SetupSharedWallet/SetupSharedWallet.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,16 @@ export const SetupSharedWallet = ({
8585
errorMessage={walletNameErrorMessage}
8686
/>
8787
<Box mt="$12" mb="$20">
88-
<Text.Body.Normal weight="$semibold">{translations.body}</Text.Body.Normal>
88+
<Text.Body.Normal weight="$semibold" data-testid="active-lace-wallet-notice">
89+
{translations.body}
90+
</Text.Body.Normal>
8991
</Box>
9092
<FlowCard.Card flowCardClassName={styles.walletCard ?? ''}>
91-
<FlowCard.Profile icon={<ProfileDropdown.WalletIcon type={walletKind} />} name={activeWalletName} />
93+
<FlowCard.Profile
94+
icon={<ProfileDropdown.WalletIcon type={walletKind} testId="active-lace-wallet-icon" />}
95+
name={activeWalletName}
96+
testId="active-lace-wallet"
97+
/>
9298
<FlowCard.Details
9399
subtitle={addEllipsis(activeWalletAddress, ADDRESS_FIRST_PART_LENGTH, ADDRESS_LAST_PART_LENGTH)}
94100
/>

packages/core/src/shared-wallets/add-shared-wallet/creation-flow/ShareWalletDetails/ShareWalletDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ export const ShareWalletDetails = ({
4141
isNextEnabled
4242
>
4343
<Box mt="$12">
44-
<Text.Body.Normal>{translations.body}</Text.Body.Normal>
44+
<Text.Body.Normal data-testid="download-notice">{translations.body}</Text.Body.Normal>
4545
</Box>
4646
<Divider my="$20" />
4747
<ActionCard
4848
title={[{ text: translations.label, weight: '$semibold' }]}
4949
description={FILENAME}
5050
rootClassName={styles.root}
5151
iconClassName={styles.icon}
52+
testId="shared-wallet-setup-file"
5253
icon={
5354
<Button
5455
block
@@ -59,7 +60,7 @@ export const ShareWalletDetails = ({
5960
color="gradient"
6061
data-testid="download-json-btn"
6162
>
62-
<DownloadFileIcon />
63+
<DownloadFileIcon data-testid="download-icon" />
6364
<Text.Body.Normal weight="$semibold">{translations.cta}</Text.Body.Normal>
6465
</Button>
6566
}

packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKey.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,25 @@ export const CopyKey: VFC<CopyKeysProps> = ({ onClose, onCopyKey, sharedWalletKe
3737
label={t('sharedWallets.addSharedWallet.keyGeneration.copyKeys.backButtonLabel')}
3838
icon={<CopyIcon />}
3939
onClick={copyKeys}
40+
data-testid="copy-key-to-clipboard-button"
4041
/>
4142
}
4243
customNextButton={
4344
<Button.Secondary
4445
onClick={onClose}
4546
label={t('sharedWallets.addSharedWallet.keyGeneration.copyKeys.nextButtonLabel')}
47+
data-testid="close-button"
4648
/>
4749
}
4850
>
4951
<Card.Greyed>
5052
<Flex p="$16" gap="$4" flexDirection="column">
51-
<Text.Body.Large weight="$bold">
53+
<Text.Body.Large weight="$bold" data-testid="shared-wallet-keys-label">
5254
{t('sharedWallets.addSharedWallet.keyGeneration.copyKeys.keyBoxTitle')}
5355
</Text.Body.Large>
54-
<Text.Body.Small className={styles.keyBox}>{sharedWalletKey}</Text.Body.Small>
56+
<Text.Body.Small className={styles.keyBox} data-testid="shared-wallet-keys-value">
57+
{sharedWalletKey}
58+
</Text.Body.Small>
5559
</Flex>
5660
</Card.Greyed>
5761
</SharedWalletLayout>

packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/EnterPassword.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const errorsMap: Record<PasswordErrorType, CoreTranslationKey | SharedWalletsTra
3838
};
3939

4040
const mapOfWalletTypeIconProperties: Record<WalletKind, ReactElement> = {
41-
cold: <ColdWalletIcon />,
42-
hot: <HotWalletIcon />,
41+
cold: <ColdWalletIcon data-testid="cold-wallet-icon" />,
42+
hot: <HotWalletIcon data-testid="hot-wallet-icon" />,
4343
};
4444

4545
type EnterPasswordProps = {
@@ -109,10 +109,12 @@ export const EnterPassword: VFC<EnterPasswordProps> = ({
109109
{icon}
110110
</Flex>
111111
<Flex flexDirection="column">
112-
<Text.Address color="secondary">
112+
<Text.Address color="secondary" data-testid="wallet-type">
113113
{t('sharedWallets.addSharedWallet.keyGeneration.enterPassword.activeWalletLabel')}
114114
</Text.Address>
115-
<Text.Body.Large weight="$bold">{walletName}</Text.Body.Large>
115+
<Text.Body.Large weight="$bold" data-testid="wallet-name">
116+
{walletName}
117+
</Text.Body.Large>
116118
</Flex>
117119
</Flex>
118120
{!isHW && (

packages/core/src/shared-wallets/add-shared-wallet/restore-flow/SharedWalletRestorationFlow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const SharedWalletRestorationFlow: VFC<SharedWalletRestorationProps> = ({
115115
files={file ? [file.name] : undefined}
116116
onRemove={() => setFile(undefined)}
117117
key={file ? file.name : ''}
118+
data-testid="file-upload"
118119
/>
119120
</SharedWalletLayout>
120121
<Dialog.Root open={error?.message === FileErrorMessage.UNRECOGNIZED} zIndex={1000} setOpen={() => void 0}>

0 commit comments

Comments
 (0)