Skip to content

test(e2e): use stable cron test ids#2301

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
aqilaziz:codex/1861-cron-e2e-testids
May 20, 2026
Merged

test(e2e): use stable cron test ids#2301
senamakel merged 1 commit into
tinyhumansai:mainfrom
aqilaziz:codex/1861-cron-e2e-testids

Conversation

@aqilaziz
Copy link
Copy Markdown
Contributor

@aqilaziz aqilaziz commented May 20, 2026

Summary

  • Adds shared waitForTestId and clickTestId E2E helpers for stable DOM hooks.
  • Adds missing cron-jobs-panel and cron-refresh hooks to the Cron Jobs settings panel.
  • Migrates the reference cron E2E flow away from Tailwind class/DOM walking to cron row/action test IDs.
  • Documents the E2E data-testid naming taxonomy in the E2E guide.

Problem

Solution

  • Use existing CoreJobList cron row/action hooks directly from the spec.
  • Add the missing panel/refresh hooks so the whole cron flow can avoid text/button discovery for row actions.
  • Centralize test ID waiting/clicking in element-helpers.ts instead of keeping local DOM snippets in specs.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy - updated the reference cron E2E spec and helper path.
  • Diff coverage >= 80% - N/A locally: E2E helper/spec/doc change; CI diff coverage is authoritative.
  • Coverage matrix updated - N/A: E2E selector-hardening change, no feature row added/removed/renamed.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related - N/A: no matrix feature ID applies.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) - N/A: no release-cut surface.
  • Linked issue closed via Closes #NNN in the ## Related section - N/A: this is a scoped slice that references Add data-testid hooks to UI affordances exercised by E2E specs #1861 without closing the broader audit issue.

Impact

  • Runtime impact: none outside stable data-testid attributes on the Cron Jobs panel.
  • Test impact: cron E2E is less coupled to Tailwind classes and container structure.
  • Compatibility: waitForTestId is documented as tauri-driver/DOM-backed; Mac2 specs should keep accessibility/text helpers unless IDs are mirrored into accessible labels.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: codex/1861-cron-e2e-testids
  • Commit SHA: 28eca40a3d2e3a75b61105887e4faf58d4c0866e

Validation Run

  • pnpm --filter openhuman-app exec prettier --check src/components/settings/panels/CronJobsPanel.tsx test/e2e/helpers/element-helpers.ts test/e2e/specs/cron-jobs-flow.spec.ts - passed
  • pnpm typecheck - passed
  • Focused tests: N/A, E2E spec migration not run locally
  • Rust fmt/check (if changed): cargo fmt --all --check - passed; git diff --check - passed
  • Tauri fmt/check (if changed): N/A

Validation Blocked

  • command: pnpm --filter openhuman-app exec tsc -p test/tsconfig.e2e.json --noEmit
  • error: local command could not find tsc / @wdio/globals/types via that invocation
  • impact: app-wide pnpm typecheck passes; remote E2E/TS jobs remain authoritative for the E2E tsconfig

Behavior Changes

  • Intended behavior change: none for users; E2E selectors now target stable hooks.
  • User-visible effect: none.

Parity Contract

  • Legacy behavior preserved: cron load, refresh, pause/resume, run-history, and remove behavior unchanged.
  • Guard/fallback/dispatch parity checks: spec still asserts the same UI and sidecar persistence behavior.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • Tests

    • Added E2E helpers and updated cron-jobs flow to use stable test identifiers for more reliable UI interactions and polling.
  • Documentation

    • Added guidance on stable test ID naming and how to use the new E2E helpers in the testing guide.
  • Maintenance

    • Cron Jobs panel and controls now expose stable identifiers for testing (no user-facing behavior changes).

Review Change Stack

@aqilaziz aqilaziz requested a review from a team May 20, 2026 07:47
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03776ba5-3f8f-4f65-8f10-fd347a99f58f

📥 Commits

Reviewing files that changed from the base of the PR and between c11dca9 and 29d5446.

📒 Files selected for processing (4)
  • app/src/components/settings/panels/CronJobsPanel.tsx
  • app/test/e2e/helpers/element-helpers.ts
  • app/test/e2e/specs/cron-jobs-flow.spec.ts
  • gitbooks/developing/e2e-testing.md
✅ Files skipped from review due to trivial changes (1)
  • gitbooks/developing/e2e-testing.md

📝 Walkthrough

Walkthrough

Adds tauri-only E2E helpers (waitForTestId, clickTestId), documents a data-testid naming taxonomy, instruments CronJobsPanel with cron-jobs-panel and cron-refresh, and migrates the Cron Jobs E2E spec to use test-id–driven selectors with fallbacks.

Changes

Stable E2E Test Selectors

Layer / File(s) Summary
Test ID helpers and naming convention
app/test/e2e/helpers/element-helpers.ts, gitbooks/developing/e2e-testing.md
New waitForTestId and clickTestId helpers added for tauri-driver-only data-testid targeting; docs add a <surface>-<element>-<id?> naming convention and usage guidance.
CronJobsPanel test ID attributes
app/src/components/settings/panels/CronJobsPanel.tsx
Panel container and refresh button instrumented with data-testid="cron-jobs-panel" and data-testid="cron-refresh".
Cron Jobs E2E spec migration
app/test/e2e/specs/cron-jobs-flow.spec.ts
Spec updated to use waitForTestId/clickTestId, derive per-action data-testids from job IDs, wait on row test IDs with refresh-and-retry, and click refresh via cron-refresh.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through tests with glee,

I tagged the panel, made clicks worry-free.
No flaky hunts for text to find,
Test IDs now keep checks aligned.
🌱🧪

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding stable test IDs for cron-related E2E tests, which is exactly what the changeset accomplishes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@coderabbitai coderabbitai Bot added the working A PR that is being worked on by the team. label May 20, 2026
Copy link
Copy Markdown
Contributor

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/test/e2e/specs/cron-jobs-flow.spec.ts`:
- Line 31: The spec currently imports and calls tauri-driver-only helpers
waitForTestId and clickTestId (used in cron-jobs-flow.spec.ts) unguarded,
causing hard failures on non-tauri sessions (macOS/Appium); update the test to
detect the driver/session type or use the cross-platform element helpers (e.g.,
textExists, waitForText or the provided crossPlatformClick/wait helpers) before
invoking waitForTestId/clickTestId, wrapping all uses of waitForTestId and
clickTestId (including the occurrences referenced by the reviewer) in a
conditional that falls back to the tauri-agnostic helper so the spec can run on
both tauri and Appium.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba3d11ed-0310-44fa-9acb-8db2d81050a2

📥 Commits

Reviewing files that changed from the base of the PR and between 65d92bf and 28eca40.

📒 Files selected for processing (4)
  • app/src/components/settings/panels/CronJobsPanel.tsx
  • app/test/e2e/helpers/element-helpers.ts
  • app/test/e2e/specs/cron-jobs-flow.spec.ts
  • gitbooks/developing/e2e-testing.md

Comment thread app/test/e2e/specs/cron-jobs-flow.spec.ts Outdated
@aqilaziz aqilaziz force-pushed the codex/1861-cron-e2e-testids branch from 28eca40 to c3e4004 Compare May 20, 2026 08:34
Copy link
Copy Markdown
Contributor

@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.

♻️ Duplicate comments (1)
app/test/e2e/specs/cron-jobs-flow.spec.ts (1)

31-31: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard tauri-only test-id helpers with cross-platform fallbacks.

waitForTestId / clickTestId are still called unguarded (Line 81, Line 98, Line 125, Line 153, Line 156, Line 158, Line 176). This can hard-fail on Mac2/Appium runs.

Suggested minimal fix
-import { clickTestId, textExists, waitForTestId, waitForText } from '../helpers/element-helpers';
+import {
+  clickNativeButton,
+  clickTestId,
+  textExists,
+  waitForTestId,
+  waitForText,
+} from '../helpers/element-helpers';
+import { isTauriDriver } from '../helpers/platform';

+async function waitForCronPanel(timeout = 5_000): Promise<void> {
+  if (isTauriDriver()) {
+    await waitForTestId('cron-jobs-panel', timeout);
+  } else {
+    await waitForText('Cron Jobs', timeout);
+  }
+}
+
+async function clickCronRefresh(): Promise<void> {
+  if (isTauriDriver()) {
+    await clickTestId('cron-refresh');
+  } else {
+    await clickNativeButton('Refresh Cron Jobs');
+  }
+}

As per coding guidelines: “Ensure each spec is runnable in isolation… Use clickNativeButton(), waitForWebView(), clickToggle() for cross-platform element interaction.”

Also applies to: 81-82, 98-99, 125-126, 153-159, 176-176

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/test/e2e/specs/cron-jobs-flow.spec.ts` at line 31, The spec calls
Tauri-only helpers waitForTestId and clickTestId directly (in
cron-jobs-flow.spec.ts) which can fail on non-Tauri runners; update the call
sites (the uses at the locations flagged) to use cross-platform fallbacks:
either replace with clickNativeButton / clickToggle / waitForWebView as
appropriate, or wrap the existing waitForTestId/clickTestId calls in a small
runtime guard that detects the platform and falls back to web-friendly helpers
(e.g., try waitForTestId and on failure call waitForWebView, or use
clickNativeButton instead of clickTestId for buttons). Ensure you update every
occurrence of waitForTestId and clickTestId in this spec so the spec runs on
Mac2/Appium and web runners.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@app/test/e2e/specs/cron-jobs-flow.spec.ts`:
- Line 31: The spec calls Tauri-only helpers waitForTestId and clickTestId
directly (in cron-jobs-flow.spec.ts) which can fail on non-Tauri runners; update
the call sites (the uses at the locations flagged) to use cross-platform
fallbacks: either replace with clickNativeButton / clickToggle / waitForWebView
as appropriate, or wrap the existing waitForTestId/clickTestId calls in a small
runtime guard that detects the platform and falls back to web-friendly helpers
(e.g., try waitForTestId and on failure call waitForWebView, or use
clickNativeButton instead of clickTestId for buttons). Ensure you update every
occurrence of waitForTestId and clickTestId in this spec so the spec runs on
Mac2/Appium and web runners.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a4bfe317-6be1-43ff-a15a-d584b7a3bb3b

📥 Commits

Reviewing files that changed from the base of the PR and between 28eca40 and c3e4004.

📒 Files selected for processing (4)
  • app/src/components/settings/panels/CronJobsPanel.tsx
  • app/test/e2e/helpers/element-helpers.ts
  • app/test/e2e/specs/cron-jobs-flow.spec.ts
  • gitbooks/developing/e2e-testing.md
✅ Files skipped from review due to trivial changes (2)
  • gitbooks/developing/e2e-testing.md
  • app/src/components/settings/panels/CronJobsPanel.tsx

@aqilaziz aqilaziz force-pushed the codex/1861-cron-e2e-testids branch from c3e4004 to c11dca9 Compare May 20, 2026 09:37
@aqilaziz aqilaziz force-pushed the codex/1861-cron-e2e-testids branch from c11dca9 to 29d5446 Compare May 20, 2026 10:01
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

Solid work migrating the cron E2E flow off brittle Tailwind class selectors to stable data-testid hooks. The fallback pattern (try testid → catch → text/button helper) is well-structured and keeps the spec runnable on non-tauri drivers. Helpers are clean, taxonomy doc is useful.

CI is fully green including the Linux/Appium E2E run, and the scoped slice of #1861 is delivered as described.

Area Files Changes
Frontend CronJobsPanel.tsx +2 data-testid attributes (cron-jobs-panel, cron-refresh)
E2E helpers element-helpers.ts +waitForTestId, clickTestId (tauri-driver guarded)
E2E spec cron-jobs-flow.spec.ts Replaced DOM-walking with testid selectors + cross-platform fallbacks
Docs e2e-testing.md Testid naming taxonomy

One minor note below — otherwise LGTM. Nice incremental improvement to the E2E foundation.

- `skill-row-<skillId>`, `skill-install-<skillId>`, `skill-uninstall-<skillId>`
- `thread-row-<threadId>`, `new-thread-button`, `send-message-button`
- `onboarding-next-button`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] The taxonomy section documents test IDs for surfaces not yet implemented (settings-nav-<routeId>, skill-row-<skillId>, thread-row-<threadId>, etc.). This is fine as a forward-looking convention guide, but consider adding a note like "IDs marked with ★ are planned but not yet wired" — saves someone from writing waitForTestId('skill-row-...') and wondering why it times out.

@senamakel senamakel merged commit 0f5e914 into tinyhumansai:main May 20, 2026
27 checks passed
@senamakel
Copy link
Copy Markdown
Member

huge thanks @aqilaziz, locking in stable test ids and ditching the tailwind/dom walking is gonna make these e2e flows so much less flaky 🙌 love that you also documented the testid taxonomy in the guide, future contributors will thank you. cheers for another solid one 🚀

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

Labels

working A PR that is being worked on by the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants