@@ -3,7 +3,7 @@ import { WalletPage } from './shared/pages/WalletPage';
3
3
import { WalletValidator } from './shared/validators/WalletValidator' ;
4
4
import { ModalPage } from './shared/pages/ModalPage' ;
5
5
import { ModalValidator } from './shared/validators/ModalValidator' ;
6
- import { DEFAULT_CHAIN_NAME } from './shared/constants' ;
6
+ import { DEFAULT_CHAIN_NAME , TEST_CHAINS } from './shared/constants' ;
7
7
8
8
let modalPage : ModalPage ;
9
9
let modalValidator : ModalValidator ;
@@ -37,21 +37,36 @@ sampleWalletTest.afterAll(async () => {
37
37
} ) ;
38
38
39
39
// -- Tests --------------------------------------------------------------------
40
+ /**
41
+ * Connection Tests
42
+ * Tests the basic connection functionality including:
43
+ * - Page refresh behavior
44
+ * - Network switching
45
+ * - Disconnection flows
46
+ */
47
+
40
48
sampleWalletTest ( 'it should be connected instantly after page refresh' , async ( ) => {
41
49
await modalPage . page . reload ( ) ;
42
50
await modalValidator . expectToBeConnectedInstantly ( ) ;
43
51
} ) ;
44
52
53
+ /**
54
+ * Network Tests
55
+ * Tests network-related functionality including:
56
+ * - Disabled networks visibility
57
+ * - Network switching
58
+ * - Network persistence after refresh
59
+ */
60
+
45
61
sampleWalletTest ( 'it should show disabled networks' , async ( ) => {
46
- const disabledNetworks = 'Gnosis' ;
47
62
await modalPage . openAccountModal ( ) ;
48
63
await modalPage . goToNetworks ( ) ;
49
- await modalValidator . expectNetworksDisabled ( disabledNetworks ) ;
64
+ await modalValidator . expectNetworksDisabled ( TEST_CHAINS . GNOSIS ) ;
50
65
await modalPage . closeModal ( ) ;
51
66
} ) ;
52
67
53
68
sampleWalletTest ( 'it should switch networks and sign' , async ( ) => {
54
- const chains = [ 'Polygon' , 'Ethereum' ] ;
69
+ const chains = [ TEST_CHAINS . POLYGON , TEST_CHAINS . ETHEREUM ] ;
55
70
56
71
async function processChain ( index : number ) {
57
72
if ( index >= chains . length ) {
@@ -77,34 +92,45 @@ sampleWalletTest('it should switch networks and sign', async () => {
77
92
await processChain ( index + 1 ) ;
78
93
}
79
94
80
- // Start processing from the first chain
81
95
await processChain ( 0 ) ;
82
96
} ) ;
83
97
84
98
sampleWalletTest ( 'it should show last connected network after refreshing' , async ( ) => {
85
- const chainName = 'Polygon' ;
86
-
87
99
await modalPage . openAccountModal ( ) ;
88
100
await modalPage . goToNetworks ( ) ;
89
- await modalPage . switchNetwork ( chainName ) ;
90
- await modalValidator . expectSwitchedNetwork ( chainName ) ;
101
+ await modalPage . switchNetwork ( TEST_CHAINS . POLYGON ) ;
102
+ await modalValidator . expectSwitchedNetwork ( TEST_CHAINS . POLYGON ) ;
91
103
await modalPage . closeModal ( ) ;
92
104
93
105
await modalPage . page . reload ( ) ;
94
106
95
107
await modalPage . openAccountModal ( ) ;
96
- await modalValidator . expectSwitchedNetwork ( chainName ) ;
108
+ await modalValidator . expectSwitchedNetwork ( TEST_CHAINS . POLYGON ) ;
97
109
await modalPage . closeModal ( ) ;
98
110
} ) ;
99
111
112
+ /**
113
+ * Signing Tests
114
+ * Tests message signing functionality including:
115
+ * - Successful signing flow
116
+ * - Rejection flow
117
+ */
118
+
100
119
sampleWalletTest ( 'it should reject sign' , async ( ) => {
101
- const chainName = 'Polygon' ;
102
120
await modalPage . sign ( ) ;
103
- await walletValidator . expectReceivedSign ( { chainName } ) ;
121
+ await walletValidator . expectReceivedSign ( { chainName : TEST_CHAINS . POLYGON } ) ;
104
122
await walletPage . handleRequest ( { accept : false } ) ;
105
123
await modalValidator . expectRejectedSign ( ) ;
106
124
} ) ;
107
125
126
+ /**
127
+ * Disconnection Tests
128
+ * Tests various disconnection scenarios including:
129
+ * - Hook-based disconnection
130
+ * - Wallet-initiated disconnection
131
+ * - Manual disconnection
132
+ */
133
+
108
134
sampleWalletTest ( 'it should disconnect using hook' , async ( ) => {
109
135
await modalValidator . expectConnected ( ) ;
110
136
await modalPage . clickHookDisconnectButton ( ) ;
@@ -129,6 +155,14 @@ sampleWalletTest('it should disconnect as expected', async () => {
129
155
await modalValidator . expectDisconnected ( ) ;
130
156
} ) ;
131
157
158
+ /**
159
+ * Activity Screen Tests
160
+ * Tests the Activity screen behavior including:
161
+ * - Loader visibility on first visit
162
+ * - Loader behavior on subsequent visits
163
+ * - Loader behavior after network changes
164
+ */
165
+
132
166
sampleWalletTest ( 'shows loader behavior on first visit to Activity screen' , async ( ) => {
133
167
// Connect to wallet
134
168
await modalPage . qrCodeFlow ( modalPage , walletPage ) ;
@@ -158,8 +192,8 @@ sampleWalletTest('shows loader behavior after network change in Activity screen'
158
192
159
193
// Change network
160
194
await modalPage . goToNetworks ( ) ;
161
- await modalPage . switchNetwork ( 'Polygon' ) ;
162
- await modalValidator . expectSwitchedNetwork ( 'Polygon' ) ;
195
+ await modalPage . switchNetwork ( TEST_CHAINS . POLYGON ) ;
196
+ await modalValidator . expectSwitchedNetwork ( TEST_CHAINS . POLYGON ) ;
163
197
164
198
// Visit Activity screen after network change
165
199
await modalPage . goToActivity ( ) ;
0 commit comments