Skip to content

Commit 32feb83

Browse files
committed
feat: add error test
1 parent 566d48e commit 32feb83

File tree

21 files changed

+205
-97
lines changed

21 files changed

+205
-97
lines changed

packages/connect-examples/expo-example/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TamaguiProvider } from '@tamagui/core';
55
import { PortalProvider, Text, Stack, Card } from 'tamagui';
66
import * as ExpoLinking from 'expo-linking';
77
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
8-
8+
import Watermark from '@uiw/react-watermark';
99
import { useIntl } from 'react-intl';
1010
import SDKProvider from './src/provider/SDKProvider';
1111

packages/connect-examples/expo-example/locale/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"action__update_restart": "Restart installation update",
2626

2727
"action__start_test": "Start Test",
28+
"action__start_error_test": "Start testing failed cases",
2829
"action__stop_test": "Stop Test",
2930

3031
"tip__update_ready": "There are new versions that can be updated",

packages/connect-examples/expo-example/locale/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"action__update_restart": "重启并安装更新",
2626

2727
"action__start_test": "开始测试",
28+
"action__start_error_test": "开始测试失败用例",
2829
"action__stop_test": "停止测试",
2930

3031
"tip__update_ready": "检测到新的版本可以更新,点击进行安装",

packages/connect-examples/expo-example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@tamagui/config": "1.90.2",
3333
"@tamagui/core": "1.90.2",
3434
"@tamagui/lucide-icons": "1.90.2",
35+
"@uiw/react-watermark": "^1.0.1",
3536
"asyncstorage-down": "^4.2.0",
3637
"bitcoinjs-lib": "^6.1.5",
3738
"bn.js": "^5.2.1",

packages/connect-examples/expo-example/src/components/Playground.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export type PlaygroundProps = {
3939
description: string;
4040
presupposes?: PresupposeProps[];
4141
deprecated?: boolean;
42+
// eslint-disable-next-line react/no-unused-prop-types
43+
expect?: TestDeviceExpect;
4244
} & MethodPayload;
4345

4446
const Playground = ({
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ScrollView, View } from 'tamagui';
2+
import Watermark from '@uiw/react-watermark';
23
import HeaderView from './Header';
34

45
export interface PageViewProps {
@@ -7,10 +8,18 @@ export interface PageViewProps {
78
}
89

910
const PageView = ({ children, scrollable = true }: PageViewProps) => (
10-
<View flex={1} backgroundColor="bgApp">
11-
<HeaderView />
12-
{scrollable ? <ScrollView flex={1}>{children}</ScrollView> : <View>{children}</View>}
13-
</View>
11+
<Watermark
12+
content="测试使用,需要特殊 Bridge"
13+
fontColor="rgb(255 0 0 / 15%)"
14+
gapX={480}
15+
gapY={480}
16+
fontSize={28}
17+
>
18+
<View flex={1} backgroundColor="bgApp">
19+
<HeaderView />
20+
{scrollable ? <ScrollView flex={1}>{children}</ScrollView> : <View>{children}</View>}
21+
</View>
22+
</Watermark>
1423
);
1524

1625
export default PageView;

packages/connect-examples/expo-example/src/data/basic.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ const api: PlaygroundProps[] = [
3636
method: 'getOnekeyFeatures',
3737
description: 'Get features of a device',
3838
noDeviceIdReq: true,
39+
expect: {
40+
common: {
41+
normal: {
42+
success: true,
43+
},
44+
bootloader: {
45+
success: true,
46+
},
47+
},
48+
},
3949
},
4050
{
4151
method: 'getPassphraseState',

packages/connect-examples/expo-example/src/data/device.ts

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,22 @@ const api: PlaygroundProps[] = [
5151
expect: {
5252
common: {
5353
normal: {
54-
skip: true,
54+
requestPin: true,
5555
},
5656
},
5757
touch: {
5858
normal: {
59-
requestPin: true,
59+
unknownMessage: true,
60+
},
61+
},
62+
classic1s: {
63+
normal: {
64+
unknownMessage: true,
6065
},
6166
},
6267
pro: {
6368
normal: {
64-
requestPin: true,
69+
unknownMessage: true,
6570
},
6671
},
6772
},
@@ -234,9 +239,24 @@ const api: PlaygroundProps[] = [
234239
pin_protection: true,
235240
},
236241
expect: {
242+
common: {
243+
normal: {
244+
requestPin: true,
245+
},
246+
},
237247
classic1s: {
238248
normal: {
239-
error: true,
249+
unknownMessage: true,
250+
},
251+
},
252+
touch: {
253+
normal: {
254+
unknownMessage: true,
255+
},
256+
},
257+
pro: {
258+
normal: {
259+
unknownMessage: true,
240260
},
241261
},
242262
},
@@ -398,6 +418,28 @@ const api: PlaygroundProps[] = [
398418
method: 'deviceBackup',
399419
description: 'Backup a device',
400420
noDeviceIdReq: true,
421+
expect: {
422+
common: {
423+
normal: {
424+
requestPin: true,
425+
},
426+
},
427+
classic1s: {
428+
normal: {
429+
unknownMessage: true,
430+
},
431+
},
432+
touch: {
433+
normal: {
434+
unknownMessage: true,
435+
},
436+
},
437+
pro: {
438+
normal: {
439+
unknownMessage: true,
440+
},
441+
},
442+
},
401443
},
402444
{
403445
method: 'deviceGetFirmwareHash',

packages/connect-examples/expo-example/src/data/dynex.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ const api: PlaygroundProps[] = [
3232
},
3333
},
3434
],
35+
expect: {
36+
common: {
37+
normal: {
38+
unknownMessage: true,
39+
},
40+
},
41+
classic: {
42+
normal: {
43+
requestPin: true,
44+
},
45+
},
46+
classic1s: {
47+
normal: {
48+
requestPin: true,
49+
},
50+
},
51+
},
3552
},
3653
{
3754
method: 'dnxSignTransaction',
@@ -57,6 +74,23 @@ const api: PlaygroundProps[] = [
5774
},
5875
},
5976
],
77+
expect: {
78+
common: {
79+
normal: {
80+
unknownMessage: true,
81+
},
82+
},
83+
classic: {
84+
normal: {
85+
requestPin: true,
86+
},
87+
},
88+
classic1s: {
89+
normal: {
90+
requestPin: true,
91+
},
92+
},
93+
},
6094
},
6195
];
6296

packages/connect-examples/expo-example/src/data/nostr.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ const api: PlaygroundProps[] = [
1111
path: "m/44'/1237'/0'/0/0",
1212
showOnOneKey: true,
1313
},
14-
expect: {
15-
classic1s: {
16-
normal: {
17-
unknownMessage: true,
18-
},
19-
},
20-
},
2114
},
2215
{
2316
title: 'Batch Get Public Key',
@@ -41,13 +34,6 @@ const api: PlaygroundProps[] = [
4134
},
4235
],
4336
},
44-
expect: {
45-
classic1s: {
46-
normal: {
47-
unknownMessage: true,
48-
},
49-
},
50-
},
5137
},
5238
],
5339
},
@@ -66,13 +52,6 @@ const api: PlaygroundProps[] = [
6652
created_at: 1702268010,
6753
},
6854
},
69-
expect: {
70-
classic1s: {
71-
normal: {
72-
unknownMessage: true,
73-
},
74-
},
75-
},
7655
},
7756
{
7857
title: 'Sign other nostr event',
@@ -90,13 +69,6 @@ const api: PlaygroundProps[] = [
9069
],
9170
},
9271
},
93-
expect: {
94-
classic1s: {
95-
normal: {
96-
unknownMessage: true,
97-
},
98-
},
99-
},
10072
},
10173
],
10274
},
@@ -112,13 +84,6 @@ const api: PlaygroundProps[] = [
11284
plaintext: 'Hello world',
11385
showOnOneKey: false,
11486
},
115-
expect: {
116-
classic1s: {
117-
normal: {
118-
unknownMessage: true,
119-
},
120-
},
121-
},
12287
},
12388
],
12489
},
@@ -134,13 +99,6 @@ const api: PlaygroundProps[] = [
13499
ciphertext: 'VpWFJ7JDFv16jL7pBZ1shw==?iv=$1tPpwGD3Ic1RTVXJx1ZG7Q==',
135100
showOnOneKey: false,
136101
},
137-
expect: {
138-
classic1s: {
139-
normal: {
140-
unknownMessage: true,
141-
},
142-
},
143-
},
144102
},
145103
],
146104
},
@@ -154,13 +112,6 @@ const api: PlaygroundProps[] = [
154112
path: "m/44'/1237'/0'/0/0",
155113
hash: '2118c65161c7d68b4bdbe1374f658532670057ab1bb0c99937d0ff7cff45cb5e',
156114
},
157-
expect: {
158-
classic1s: {
159-
normal: {
160-
unknownMessage: true,
161-
},
162-
},
163-
},
164115
},
165116
],
166117
},

0 commit comments

Comments
 (0)