Skip to content

Commit 6f7e302

Browse files
Add data-testid attribute to Button components (#1118)
* feat: add data-testid attributes for E2E testing To improve E2E test stability and enable better component selection, this change adds `data-testid` attributes to several key button elements. Since a generic `Button.tsx` component does not exist, the attributes were added directly to Material-UI `Button` components in the following locations: - HR Zone buttons in `app/client/mock/page.tsx` - Streaming `START`/`STOP` buttons in `app/client/mock/page.tsx` This provides stable selectors for automated testing tools to target these critical interactive elements. * feat: add data-testid attributes for E2E testing To improve E2E test stability and enable better component selection, this change adds `data-testid` attributes to several key button elements. Since a generic `Button.tsx` component does not exist, the attributes were added directly to Material-UI `Button` components in the following locations: - HR Zone buttons in `app/client/mock/page.tsx` - Streaming `START`/`STOP` buttons in `app/client/mock/page.tsx` This provides stable selectors for automated testing tools to target these critical interactive elements. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 9377680 commit 6f7e302

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/client/mock/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export default function MockPage() {
163163
variant="contained"
164164
sx={{ backgroundColor: '#9E9E9E' }}
165165
onClick={() => setHrByZone('grey')}
166+
data-testid="zone-1-button"
166167
>
167168
Zone 1
168169
</Button>
@@ -173,6 +174,7 @@ export default function MockPage() {
173174
variant="contained"
174175
sx={{ backgroundColor: '#2196F3' }}
175176
onClick={() => setHrByZone('blue')}
177+
data-testid="zone-2-button"
176178
>
177179
Zone 2
178180
</Button>
@@ -183,6 +185,7 @@ export default function MockPage() {
183185
variant="contained"
184186
sx={{ backgroundColor: '#4CAF50' }}
185187
onClick={() => setHrByZone('green')}
188+
data-testid="zone-3-button"
186189
>
187190
Zone 3
188191
</Button>
@@ -193,6 +196,7 @@ export default function MockPage() {
193196
variant="contained"
194197
sx={{ backgroundColor: '#FFEB3B', color: 'black' }}
195198
onClick={() => setHrByZone('yellow')}
199+
data-testid="zone-4-button"
196200
>
197201
Zone 4
198202
</Button>
@@ -203,6 +207,7 @@ export default function MockPage() {
203207
variant="contained"
204208
sx={{ backgroundColor: '#F44336' }}
205209
onClick={() => setHrByZone('red')}
210+
data-testid="zone-5-button"
206211
>
207212
Zone 5
208213
</Button>
@@ -218,6 +223,9 @@ export default function MockPage() {
218223
startIcon={<HeartBroken />}
219224
fullWidth
220225
sx={{ mb: 3 }}
226+
data-testid={
227+
isStreaming ? 'streaming-stop-button' : 'streaming-start-button'
228+
}
221229
>
222230
{isStreaming
223231
? `STOP Streaming HR: ${hrValue} BPM`

0 commit comments

Comments
 (0)