Skip to content

EDM-3455: Add data-testid attributes for Cypress device E2E tests#551

Open
talhil-rh wants to merge 2 commits intoflightctl:mainfrom
talhil-rh:add-device-cypress-data-testids
Open

EDM-3455: Add data-testid attributes for Cypress device E2E tests#551
talhil-rh wants to merge 2 commits intoflightctl:mainfrom
talhil-rh:add-device-cypress-data-testids

Conversation

@talhil-rh
Copy link
Collaborator

@talhil-rh talhil-rh commented Mar 3, 2026

  • AppLayout: nav-toggle on sidebar toggle
  • ListPage: list-page-title on page title
  • EnrollmentRequestTableRow: enrollment-request-approve-button
  • ApproveDeviceForm: approve-device-form-submit
  • EnrolledDevicesTable: enrolled-devices-table, toolbar-decommission-devices, show-decommissioned-devices-switch
  • EnrolledDeviceTableRow: enrolled-device-row, device-name-link, device-row-actions
  • ResourceLink: optional data-testid prop
  • FlightCtlWizardFooter: wizard-next-button, wizard-save-button, wizard-back-button
  • DetailsPage: optional titleDataTestId (device-details-title from DeviceDetailsPage)
  • MassDecommissionDeviceModal: modal-decommission-confirm
  • MassDeleteDeviceModal: modal-delete-devices-confirm
  • DecommissionedDevicesTable: toolbar-delete-forever, show-decommissioned-devices-switch
  • Table: data-testid prop support

Made-with: Cursor

Summary by CodeRabbit

  • Tests
    • Added data-testids across the UI (navigation toggle, page/list titles, tables, rows/links, action buttons, switches, wizard controls, approve/delete/decommission modals) to improve end-to-end and UI testing.
  • New Features
    • Introduced optional test-id props on several UI components (titles, tables, resource links, details pages) to enable precise test targeting without changing behavior.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Added data-testid attributes across numerous UI components and introduced optional 'data-testid'/titleDataTestId props on some shared components; no logic, control flow, or behavioral changes.

Changes

Cohort / File(s) Summary
Device Components
libs/ui-components/src/components/Device/.../DeviceDetailsPage.tsx, libs/ui-components/src/components/Device/.../DecommissionedDevicesTable.tsx, libs/ui-components/src/components/Device/.../EnrolledDeviceTableRow.tsx, libs/ui-components/src/components/Device/.../EnrolledDevicesTable.tsx
Added data-testid attributes to device-related UI: details title, decommission/delete toolbar buttons, switches, table, rows, links, and actions cell. No behavioral changes.
Modal Components
libs/ui-components/src/components/modals/.../ApproveDeviceForm.tsx, libs/ui-components/src/components/modals/.../massModals/MassDecommissionDeviceModal.tsx, libs/ui-components/src/components/modals/.../massModals/MassDeleteDeviceModal.tsx
Added data-testid attributes to modal action buttons (Approve, Decommission confirm, Delete). No control-flow changes.
Shared UI Props & Links
libs/ui-components/src/components/DetailsPage/DetailsPage.tsx, libs/ui-components/src/components/Table/Table.tsx, libs/ui-components/src/components/common/ResourceLink.tsx
Introduced optional props: titleDataTestId?: string on DetailsPage, 'data-testid'?: string on Table props, and 'data-testid'?: string on ResourceLink; passed through to rendered elements.
Page & Layout
apps/standalone/src/app/components/AppLayout/AppLayout.tsx, libs/ui-components/src/components/ListPage/ListPage.tsx
Added data-testid to navigation toggle and list page title elements.
Wizard Footer
libs/ui-components/src/components/common/FlightCtlWizardFooter.tsx
Added data-testid attributes to Save, Next, and Back buttons in wizard footer.
Enrollment Components
libs/ui-components/src/components/EnrollmentRequest/EnrollmentRequestTableRow.tsx
Added data-testid to the Approve button in enrollment request row.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding data-testid attributes across multiple UI components to support Cypress E2E testing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@talhil-rh talhil-rh force-pushed the add-device-cypress-data-testids branch 2 times, most recently from 2ed33a1 to 3988646 Compare March 3, 2026 19:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
libs/ui-components/src/components/common/ResourceLink.tsx (1)

43-49: data-testid is ignored when routeLink is missing.

If callers pass data-testid and routeLink is falsy, no test id is rendered. Consider applying it to the fallback text element so the prop contract is consistent across both branches.

Proposed diff
-  const textEl = <span className="fctl-resource-link__text">{variant === 'full' ? nameOrId : displayText}</span>;
+  const textEl = (
+    <span className="fctl-resource-link__text" data-testid={!routeLink ? dataTestId : undefined}>
+      {variant === 'full' ? nameOrId : displayText}
+    </span>
+  );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/ui-components/src/components/common/ResourceLink.tsx` around lines 43 -
49, The fallback branch in ResourceLink.tsx currently returns <> {textEl} </>
which drops the data-testid when routeLink is falsy; update the fallback to
render an element that accepts props (e.g., a span or the same component used
for link children) and pass dataTestId to it so data-testid is present in both
branches—ensure the Link branch still uses data-testid={dataTestId} and the
fallback uses the same prop on the wrapper around textEl (reference symbols:
ResourceLink.tsx, routeLink, Link, dataTestId, textEl, id).
libs/ui-components/src/components/common/FlightCtlWizardFooter.tsx (1)

63-69: Consider adding test IDs to Close and Cancel buttons for completeness.

The Close button (read-only mode) and Cancel button don't have data-testid attributes. If these actions might be tested in future E2E flows, consider adding them now for consistency (e.g., wizard-close-button, wizard-cancel-button).

♻️ Optional: Add test IDs for completeness
     primaryBtn = (
-      <Button variant="primary" onClick={() => navigate(-1)}>
+      <Button variant="primary" onClick={() => navigate(-1)} data-testid="wizard-close-button">
         {t('Close')}
       </Button>
     );
-            <Button variant="link" onClick={onCancel ?? (() => navigate(-1))} isDisabled={isSubmitting}>
+            <Button variant="link" onClick={onCancel ?? (() => navigate(-1))} isDisabled={isSubmitting} data-testid="wizard-cancel-button">
               {t('Cancel')}
             </Button>

Also applies to: 100-104

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/ui-components/src/components/common/FlightCtlWizardFooter.tsx` around
lines 63 - 69, The Close and Cancel buttons lack test IDs; update the JSX where
primaryBtn is set for the read-only "Review" step (when isSubmitStep assigns
primaryBtn with <Button variant="primary" onClick={() => navigate(-1)}>...) to
include data-testid="wizard-close-button", and likewise add
data-testid="wizard-cancel-button" to the Cancel button element (where the
cancel/secondary Button is rendered, e.g., the variable/JSX that sets the cancel
action). Ensure you only add the data-testid attributes and keep existing
onClick/props intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@libs/ui-components/src/components/common/FlightCtlWizardFooter.tsx`:
- Around line 63-69: The Close and Cancel buttons lack test IDs; update the JSX
where primaryBtn is set for the read-only "Review" step (when isSubmitStep
assigns primaryBtn with <Button variant="primary" onClick={() =>
navigate(-1)}>...) to include data-testid="wizard-close-button", and likewise
add data-testid="wizard-cancel-button" to the Cancel button element (where the
cancel/secondary Button is rendered, e.g., the variable/JSX that sets the cancel
action). Ensure you only add the data-testid attributes and keep existing
onClick/props intact.

In `@libs/ui-components/src/components/common/ResourceLink.tsx`:
- Around line 43-49: The fallback branch in ResourceLink.tsx currently returns
<> {textEl} </> which drops the data-testid when routeLink is falsy; update the
fallback to render an element that accepts props (e.g., a span or the same
component used for link children) and pass dataTestId to it so data-testid is
present in both branches—ensure the Link branch still uses
data-testid={dataTestId} and the fallback uses the same prop on the wrapper
around textEl (reference symbols: ResourceLink.tsx, routeLink, Link, dataTestId,
textEl, id).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed33a1 and 3988646.

📒 Files selected for processing (14)
  • apps/standalone/src/app/components/AppLayout/AppLayout.tsx
  • libs/ui-components/src/components/DetailsPage/DetailsPage.tsx
  • libs/ui-components/src/components/Device/DeviceDetails/DeviceDetailsPage.tsx
  • libs/ui-components/src/components/Device/DevicesPage/DecommissionedDevicesTable.tsx
  • libs/ui-components/src/components/Device/DevicesPage/EnrolledDeviceTableRow.tsx
  • libs/ui-components/src/components/Device/DevicesPage/EnrolledDevicesTable.tsx
  • libs/ui-components/src/components/EnrollmentRequest/EnrollmentRequestTableRow.tsx
  • libs/ui-components/src/components/ListPage/ListPage.tsx
  • libs/ui-components/src/components/Table/Table.tsx
  • libs/ui-components/src/components/common/FlightCtlWizardFooter.tsx
  • libs/ui-components/src/components/common/ResourceLink.tsx
  • libs/ui-components/src/components/modals/ApproveDeviceModal/ApproveDeviceForm.tsx
  • libs/ui-components/src/components/modals/massModals/MassDecommissionDeviceModal/MassDecommissionDeviceModal.tsx
  • libs/ui-components/src/components/modals/massModals/MassDeleteDeviceModal/MassDeleteDeviceModal.tsx
✅ Files skipped from review due to trivial changes (1)
  • libs/ui-components/src/components/modals/ApproveDeviceModal/ApproveDeviceForm.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
  • libs/ui-components/src/components/Device/DevicesPage/EnrolledDevicesTable.tsx
  • libs/ui-components/src/components/modals/massModals/MassDecommissionDeviceModal/MassDecommissionDeviceModal.tsx
  • libs/ui-components/src/components/Device/DevicesPage/EnrolledDeviceTableRow.tsx
  • libs/ui-components/src/components/Device/DevicesPage/DecommissionedDevicesTable.tsx
  • libs/ui-components/src/components/Device/DeviceDetails/DeviceDetailsPage.tsx

@talhil-rh talhil-rh force-pushed the add-device-cypress-data-testids branch 4 times, most recently from 1c1e5e6 to 88f6939 Compare March 3, 2026 20:12
- AppLayout: nav-toggle on sidebar toggle
- ListPage: list-page-title
- Enrollment: enrollment-request-approve-button, approve-device-form-submit
- EnrolledDevicesTable: enrolled-devices-table, toolbar-decommission-devices, show-decommissioned-devices-switch
- EnrolledDeviceTableRow: enrolled-device-row, device-name-link, device-row-actions
- ResourceLink: optional data-testid prop (including fallback when routeLink is missing)
- FlightCtlWizardFooter: wizard-next-button, wizard-save-button, wizard-back-button, wizard-close-button, wizard-cancel-button
- DetailsPage: optional titleDataTestId (device-details-title from DeviceDetailsPage)
- MassDecommissionDeviceModal: modal-decommission-confirm
- MassDeleteDeviceModal: modal-delete-devices-confirm
- DecommissionedDevicesTable: toolbar-delete-forever, show-decommissioned-devices-switch
- Table: data-testid prop support

Addresses CodeRabbit nitpicks for ResourceLink fallback and wizard buttons.

Made-with: Cursor
@talhil-rh talhil-rh force-pushed the add-device-cypress-data-testids branch from 88f6939 to 94fba6c Compare March 3, 2026 20:15
@talhil-rh talhil-rh changed the title Add data-testid attributes for Cypress device E2E tests EDM-3455: Add data-testid attributes for Cypress device E2E tests Mar 3, 2026

return (
<Tr>
<Tr data-testid="enrolled-device-row">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if it's preferable to have unique data-testid
In this case, all enrolled devices rows would have the same ID and we'd need to target them by position. Is that OK?

id={deviceName}
name={deviceAlias || t('Untitled')}
routeLink={ROUTE.DEVICE_DETAILS}
data-testid="device-name-link"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here, is it OK to share the same ID for multiple row elements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants