Skip to content

Commit 83aa576

Browse files
authored
Merge pull request #801 from rsksmart/feat/add-data-testids
data-testid attributes in login and configuration sections
2 parents d8f6276 + 7de294d commit 83aa576

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

internal/adapters/entrypoints/rest/assets/login.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
<input type="hidden" name="csrf" value="{{ .CsrfToken }}" required/>
1717
<div class="mb-3">
1818
<label for="username" class="form-label">Username</label>
19-
<input type="text" name="username" id="username" class="form-control" required/>
19+
<input type="text" name="username" id="username" data-testid="login-username-input" class="form-control" required/>
2020
</div>
2121
<div class="mb-3">
2222
<label for="password" class="form-label">Password</label>
23-
<input type="password" name="password" id="password" class="form-control" required/>
23+
<input type="password" name="password" id="password" data-testid="login-password-input" class="form-control" required/>
2424
</div>
2525
{{if not .CredentialsSet}}
2626
<div class="mb-3">
@@ -35,7 +35,7 @@
3535
<div class="alert alert-danger d-none" id="error-message" role="alert">
3636
Invalid username or password.
3737
</div>
38-
<button type="submit" class="btn btn-primary">Login</button>
38+
<button type="submit" class="btn btn-primary" data-testid="login-submit-button">Login</button>
3939
</form>
4040
</div>
4141
</div>

internal/adapters/entrypoints/rest/assets/management.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ <h5 class="card-title">Accounts List</h5>
108108
<h5 class="card-title">Current Configuration</h5>
109109
<ul class="nav nav-tabs" id="configTabs" role="tablist">
110110
<li class="nav-item" role="presentation">
111-
<a class="nav-link active" id="general-tab" data-bs-toggle="tab" href="#general" role="tab" aria-controls="general" aria-selected="true">General</a>
111+
<a class="nav-link active" id="general-tab" data-bs-toggle="tab" href="#general" role="tab" data-testid="config-tab-general" aria-controls="general" aria-selected="true">General</a>
112112
</li>
113113
<li class="nav-item" role="presentation">
114-
<a class="nav-link" id="peginConfig-tab" data-bs-toggle="tab" href="#peginConfig" role="tab" aria-controls="peginConfig" aria-selected="false">Pegin</a>
114+
<a class="nav-link" id="peginConfig-tab" data-bs-toggle="tab" href="#peginConfig" role="tab" data-testid="config-tab-pegin" aria-controls="peginConfig" aria-selected="false">Pegin</a>
115115
</li>
116116
<li class="nav-item" role="presentation">
117-
<a class="nav-link" id="pegoutConfig-tab" data-bs-toggle="tab" href="#pegoutConfig" role="tab" aria-controls="pegoutConfig" aria-selected="false">Pegout</a>
117+
<a class="nav-link" id="pegoutConfig-tab" data-bs-toggle="tab" href="#pegoutConfig" role="tab" data-testid="config-tab-pegout" aria-controls="pegoutConfig" aria-selected="false">Pegout</a>
118118
</li>
119119
</ul>
120120
<div class="tab-content" id="configTabContent">
@@ -143,7 +143,7 @@ <h5 class="card-title">Current Configuration</h5>
143143
<div id="pegoutConfig"></div>
144144
</div>
145145
</div>
146-
<button type="button" class="btn btn-primary" id="saveConfig">Save Configuration</button>
146+
<button type="button" class="btn btn-primary" data-testid="config-save-button" id="saveConfig">Save Configuration</button>
147147
</div>
148148
</div>
149149
</div>

internal/adapters/entrypoints/rest/assets/static/management.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const createCheckboxInput = (inputContainer, section, key, value) => {
7373
checkbox.classList.add('form-check-input');
7474
checkbox.style.marginRight = '10px';
7575
checkbox.dataset.key = key;
76+
checkbox.setAttribute('data-testid', `config-${section.id.replace('Config','')}-${key}-checkbox`);
7677
checkbox.checked = value;
7778
checkbox.addEventListener('change', () => setChanged(section.id));
7879
inputContainer.appendChild(checkbox);
@@ -84,12 +85,14 @@ const createToggableFeeInput = (inputContainer, label, section, key, value) => {
8485
checkbox.classList.add('form-check-input');
8586
checkbox.style.marginRight = '10px';
8687
checkbox.dataset.key = `${key}_enabled`;
88+
checkbox.setAttribute('data-testid', `config-${section.id.replace('Config','')}-${key}-checkbox`);
8789

8890
const input = document.createElement('input');
8991
input.type = 'text';
9092
input.style.width = '40%';
9193
input.classList.add('form-control');
9294
input.dataset.key = key;
95+
input.setAttribute('data-testid', `config-${section.id.replace('Config','')}-${key}-input`);
9396
input.dataset.originalValue = value;
9497

9598
if (value === '0' || value === 0) {
@@ -128,6 +131,7 @@ const createFeeInput = (inputContainer, label, section, key, value) => {
128131
input.style.width = '40%';
129132
input.classList.add('form-control');
130133
input.dataset.key = key;
134+
input.setAttribute('data-testid', `config-${section.id.replace('Config','')}-${key}-input`);
131135
input.value = isFeeKey(key) ? weiToEther(value) : value;
132136
input.addEventListener('input', () => setChanged(section.id));
133137
inputContainer.appendChild(input);
@@ -141,6 +145,7 @@ const createFeePercentageInput = (inputContainer, section, key, value) => {
141145
input.style.width = '40%';
142146
input.classList.add('form-control');
143147
input.dataset.key = key;
148+
input.setAttribute('data-testid', `config-${section.id.replace('Config','')}-${key}-input`);
144149
input.value = typeof value === 'number' ? value.toString() : value;
145150
input.addEventListener('input', () => setChanged(section.id));
146151
inputContainer.appendChild(input);
@@ -152,6 +157,7 @@ const createDefaultInput = (inputContainer, section, key, value) => {
152157
input.style.width = '40%';
153158
input.classList.add('form-control');
154159
input.dataset.key = key;
160+
input.setAttribute('data-testid', `config-${section.id.replace('Config','')}-${key}-input`);
155161
input.value = value;
156162
input.addEventListener('input', () => setChanged(section.id));
157163
inputContainer.appendChild(input);
@@ -270,6 +276,7 @@ const createConfirmationEntry = (container, configKey, index, amount = '', confi
270276
confirmationInput.dataset.field = 'confirmation';
271277
confirmationInput.dataset.index = index;
272278
confirmationInput.style.maxWidth = fieldWidth;
279+
confirmationInput.setAttribute('data-testid', `config-${configKey}-${index}`);
273280

274281
const confirmationInputAppend = document.createElement('span');
275282
confirmationInputAppend.classList.add('input-group-text', 'input-group-text-sm');

0 commit comments

Comments
 (0)