-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathTransactionForm.page-object.ts
More file actions
162 lines (132 loc) · 4.66 KB
/
TransactionForm.page-object.ts
File metadata and controls
162 lines (132 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import { AddressBookSelectPo } from "$tests/page-objects/AddressBookSelect.page-object";
import { AmountInputPo } from "$tests/page-objects/AmountInput.page-object";
import type { ButtonPo } from "$tests/page-objects/Button.page-object";
import { SelectDestinationAddressPo } from "$tests/page-objects/SelectDestinationAddress.page-object";
import { TransactionFormFeePo } from "$tests/page-objects/TransactionFormFee.page-object";
import { TransactionFromAccountPo } from "$tests/page-objects/TransactionFromAccount.page-object";
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";
export class TransactionFormPo extends BasePageObject {
private static readonly TID = "transaction-step-1";
static under(element: PageObjectElement): TransactionFormPo {
return new TransactionFormPo(element.byTestId(TransactionFormPo.TID));
}
getTransactionFromAccountPo(): TransactionFromAccountPo {
return TransactionFromAccountPo.under(this.root);
}
getTransactionFormFeePo(): TransactionFormFeePo {
return TransactionFormFeePo.under(this.root);
}
getSourceAccounts(): Promise<string[]> {
return this.getTransactionFromAccountPo().getAccounts();
}
getSelectDestinationAddressPo(): SelectDestinationAddressPo {
return SelectDestinationAddressPo.under(this.root);
}
getAmountInputPo(): AmountInputPo {
return AmountInputPo.under(this.root);
}
getContinueButtonPo(): ButtonPo {
return this.getButton("transaction-button-next");
}
enterAmount(amount: number): Promise<void> {
return this.getAmountInputPo().enterAmount(amount);
}
async isContinueButtonEnabled(): Promise<boolean> {
return !(await this.getContinueButtonPo().isDisabled());
}
clickContinue(): Promise<void> {
return this.getContinueButtonPo().click();
}
enterAddress(address: string): Promise<void> {
return this.getSelectDestinationAddressPo().enterAddress(address);
}
async transferToAccount({
accountName,
amount,
}: {
accountName: string;
amount: number;
}): Promise<void> {
await this.getSelectDestinationAddressPo().selectAccount(accountName);
await this.enterAmount(amount);
await this.clickContinue();
}
async transferToAddress({
destinationAddress,
amount,
}: {
destinationAddress: string;
amount: number;
}): Promise<void> {
await this.enterAddress(destinationAddress);
await this.enterAmount(amount);
await this.clickContinue();
}
// Address book methods
getAddressBookSelectPo(): AddressBookSelectPo {
return AddressBookSelectPo.under(this.root);
}
async isAddressBookToggleEnabled(): Promise<boolean> {
const toggle = this.root.querySelector(
'input[aria-label="Use address book"]'
);
return (await toggle.getAttribute("disabled")) === null;
}
async isAddressBookToggleChecked(): Promise<boolean> {
const toggle = this.root.querySelector(
'input[aria-label="Use address book"]'
);
return toggle.isChecked();
}
async toggleAddressBook(): Promise<void> {
const toggle = this.root.querySelector(
'input[aria-label="Use address book"]'
);
await toggle.click();
}
async transferToAddressBookEntry({
nickname,
amount,
}: {
nickname: string;
amount: number;
}): Promise<void> {
await this.getAddressBookSelectPo().selectAddress(nickname);
await this.enterAmount(amount);
await this.clickContinue();
}
getSelectDestinationElement(): PageObjectElement {
return this.root.byTestId("select-destination");
}
getDestinationSection(): PageObjectElement {
return this.root.byTestId("destination-wrapper");
}
async hasDestinationSection(): Promise<boolean> {
return this.getDestinationSection().isPresent();
}
async hasAddressBookDropdown(): Promise<boolean> {
return this.root.byTestId("address-book-dropdown").isPresent();
}
getManualAddressInput(): PageObjectElement {
return this.root.querySelector('input[name="accounts-address"]');
}
getManualAddressWarning(): PageObjectElement {
return this.root.byTestId("manual-address-warning");
}
getManualAddressLink(): PageObjectElement {
return this.root.byTestId("manual-address-warning-link");
}
async hasManualAddressWarning(): Promise<boolean> {
return this.getManualAddressWarning().isPresent();
}
async hasManualAddressLink(): Promise<boolean> {
return this.getManualAddressLink().isPresent();
}
hasBurnAddressLabel(): Promise<boolean> {
return this.root.byTestId("burn-address-label").isPresent();
}
async hasFee(): Promise<boolean> {
return this.getTransactionFormFeePo().isPresent();
}
}