@@ -6,28 +6,49 @@ import { MetadataProvider } from '../mocks/metadataProviderMock';
6
6
import { DevicePromptActions } from './devicePromptActions' ;
7
7
import { step } from '../common' ;
8
8
9
+ interface MetadataSubmitOptions {
10
+ useButton ?: boolean ;
11
+ }
12
+
9
13
export class MetadataActions {
10
14
private readonly metadataSubmitButton : Locator ;
15
+ readonly metadataCancelButton : Locator ;
11
16
readonly metadataInput : Locator ;
12
- readonly editLabelButton = ( accountId : string ) =>
17
+
18
+ readonly editAccountLabelButton = ( accountId : string ) =>
13
19
this . page . getByTestId ( `${ this . getAccountLabelTestId ( accountId ) } /edit-label-button` ) ;
14
- readonly successLabel = ( accountId : string ) =>
20
+ readonly successAccountLabel = ( accountId : string ) =>
15
21
this . page . getByTestId ( `${ this . getAccountLabelTestId ( accountId ) } /success` ) ;
16
22
readonly accountLabel = ( accountId : string ) =>
17
23
this . page . getByTestId ( `${ this . getAccountLabelTestId ( accountId ) } /hover-container` ) ;
24
+ readonly outputLabel = ( outputId : string , txNumber : number ) =>
25
+ this . page . getByTestId ( `${ this . getOutputLabelTestId ( outputId , txNumber ) } /hover-container` ) ;
26
+ readonly outputDropdownCopyAddress = ( outputId : string , txNumber : number ) =>
27
+ this . page . getByTestId (
28
+ `${ this . getOutputLabelTestId ( outputId , txNumber ) } /dropdown/copy-address` ,
29
+ ) ;
30
+ readonly outputDropdownEditLabel = ( outputId : string , txNumber : number ) =>
31
+ this . page . getByTestId (
32
+ `${ this . getOutputLabelTestId ( outputId , txNumber ) } /dropdown/edit-label` ,
33
+ ) ;
18
34
19
35
constructor (
20
36
private readonly page : Page ,
21
37
private readonly devicePrompt : DevicePromptActions ,
22
38
) {
23
39
this . metadataSubmitButton = page . getByTestId ( '@metadata/submit' ) ;
40
+ this . metadataCancelButton = page . getByTestId ( '@metadata/cancel' ) ;
24
41
this . metadataInput = page . getByTestId ( '@metadata/input' ) ;
25
42
}
26
43
27
44
private getAccountLabelTestId ( accountId : string ) : string {
28
45
return `@metadata/accountLabel/${ accountId } ` ;
29
46
}
30
47
48
+ private getOutputLabelTestId ( outputId : string , txNumber : number ) : string {
49
+ return `@metadata/outputLabel/${ outputId } -${ txNumber } ` ;
50
+ }
51
+
31
52
@step ( )
32
53
async passThroughInitMetadata (
33
54
provider : MetadataProvider ,
@@ -47,25 +68,57 @@ export class MetadataActions {
47
68
}
48
69
49
70
@step ( )
50
- async editLabel ( accountId : string , newLabel : string ) {
71
+ async editAccountLabel ( accountId : string , newLabel : string ) {
51
72
await this . accountLabel ( accountId ) . click ( ) ;
52
- await this . editLabelButton ( accountId ) . click ( ) ;
53
- await this . metadataInput . fill ( newLabel ) ;
54
- await this . metadataSubmitButton . click ( ) ;
73
+ await this . editAccountLabelButton ( accountId ) . click ( ) ;
74
+ await this . fillLabelInput ( newLabel , { useButton : true } ) ;
55
75
}
56
76
57
77
@step ( )
58
- async clickAddLabelButton ( accountId : string ) {
78
+ async clickAddAccountLabelButton ( accountId : string ) {
59
79
await this . accountLabel ( accountId ) . hover ( ) ;
60
80
await this . page
61
81
. getByTestId ( `${ this . getAccountLabelTestId ( accountId ) } /add-label-button` )
62
82
. click ( ) ;
63
83
}
64
84
65
85
@step ( )
66
- async addLabel ( accountId : string , label : string ) {
67
- await this . clickAddLabelButton ( accountId ) ;
86
+ async addAccountLabel ( accountId : string , label : string ) {
87
+ await this . clickAddAccountLabelButton ( accountId ) ;
88
+ await this . fillLabelInput ( label ) ;
89
+ }
90
+
91
+ @step ( )
92
+ async clickAddOutputLabelButton ( outputId : string , txNumber : number ) {
93
+ await this . outputLabel ( outputId , txNumber ) . hover ( ) ;
94
+ await this . page
95
+ . getByTestId ( `${ this . getOutputLabelTestId ( outputId , txNumber ) } /add-label-button` )
96
+ . click ( ) ;
97
+ }
98
+
99
+ @step ( )
100
+ async addOutputLabel ( outputId : string , txNumber : number , label : string ) {
101
+ await this . clickAddOutputLabelButton ( outputId , txNumber ) ;
102
+ await this . fillLabelInput ( label ) ;
103
+ }
104
+
105
+ @step ( )
106
+ async editOutputLabel ( outputId : string , txNumber : number , newLabel : string ) {
107
+ await this . outputLabel ( outputId , txNumber ) . click ( ) ;
108
+ await this . outputDropdownEditLabel ( outputId , txNumber ) . click ( ) ;
109
+ await this . fillLabelInput ( newLabel ) ;
110
+ }
111
+
112
+ @step ( )
113
+ async fillLabelInput ( label : string , options ?: MetadataSubmitOptions ) {
68
114
await this . metadataInput . fill ( label ) ;
115
+
116
+ if ( options ?. useButton ) {
117
+ await this . metadataSubmitButton . click ( ) ;
118
+
119
+ return ;
120
+ }
121
+
69
122
await this . page . keyboard . press ( 'Enter' ) ;
70
123
}
71
124
}
0 commit comments