Files
openobserve/tests/ui-testing/pages/logsPages
Vamsi Karthik RandClaude Opus 4.8 30b736e6e4 test: stabilize alpha1 Logs-Queries & Logs-Features shards on cloud (monolithic download-test split + share-link redirect hydration + SQL-commit reliability) (#13241)
## What

Stabilizes the **Logs-Queries** and **Logs-Features** shards of the
alpha1 cloud E2E
suite to green. Test-infra + page-object changes only; **no product
code** (5 files
under `tests/ui-testing/`).

> **Stacked on #13240** (Logs-Core). Base is `fix/logs-core-alpha1-e2e`
— please merge
> #13240 first; GitHub will then retarget this PR to `main`. The diff
here is only the
> Logs-Queries/Features work (5 files).

## Root causes & fixes

### Logs-Queries

**`logsDownloads.spec.js` — monolithic test exceeded the test timeout
(hard failure).**
All 14 download scenarios ran sequentially in **one** `test()` (each a
full `page.reload`
+ re-setup), needing ~7–8 min against a 360s budget. It hit 360s
mid-run, Playwright tore
the page down, and the remaining scenarios failed with **"Target
page/context closed"** (a
cascade, not a download bug). A `try/catch` wrapper also swallowed
per-scenario errors and
rethrew an aggregate, hiding the real stack. → **Split into 14 isolated
per-scenario tests.**
The `beforeEach` already yields a fresh, query-loaded page, so no
per-scenario reload is
needed; each test is short, isolated (one failing download can't close
the page for the
others), and parallelizes. Removed the error-swallowing wrapper;
`@downloadAll` tag preserved.

**`searchpartition.spec.js` — Reka OSwitch state asserted within a
hardcoded 5s (flaky).**
`verifyHistogramState` waits for the histogram OSwitch
`data-state="unchecked"` element, but
the Reka switch animates the checked→unchecked transition and the
settled state can appear
>5s after the toggle+execute under CI load. → Raised the poll ceiling to
15s (still asserts
the real end-state, no sleep).

### Logs-Features

All the share-link failures were **flaky, not product bugs** — the
redirect fully restores
every param; the tests raced the SPA under CI load.

**Reading UI/URL state before the short-URL redirect finished
hydrating.** `getQueryEditorText()`
returned `""` (lazy Monaco visible but not yet pre-filled) and
`captureCurrentState()` read
`show_histogram=null` (the SPA rewrites URL params in stages). → New
page-object helpers
`waitForQueryEditorContent`, `waitForUrlParam`, and URL-stabilization
inside
`waitForRedirectComplete` (`_waitForUrlStable`). No fixed
`waitForTimeout`.

**Bare `clickRefresh()` cancelled the in-flight SQL-mode auto-search**
("Running query
cancelled" toast), so `sql_mode`/query never committed to the short URL
→ empty editor after
redirect. → Commit via `runQueryAndWaitForResults()` (waits for the
Cancel state to clear
first), then confirm `sql_mode` is in the URL before sharing.

**SQL setup itself was unreliable.** `enableSqlModeIfNeeded` (Vue
`meta.sqlMode` flag)
didn't always stick, and `clearAndFillQueryEditor`'s focus-sensitive
`Ctrl+A` select-all
silently appended in headless CI (**doubled query**). → New
`setupSqlQueryForShare(query)`:
sets the Vue flag + writes the exact query via Monaco `executeEdits`
(verified) +
`runQueryAndWaitForResults`, then confirms `sql_mode` committed to the
URL — **retries once,
then strict-asserts** (writing SELECT text alone does **not** flip
`meta.sqlMode`; the flag
is what the app serializes to `sql_mode`). `waitForUrlParam` gained a
`required` mode that
throws instead of silently letting a bad state through to the share.

**Residual Monaco lazy-mount race after the short-URL hop** — the editor
occasionally
mounted without applying the query from the (resolved) URL. →
`waitForRedirectedQueryEditorContent`
self-heals with **one** reload of the resolved URL (the reliable
URL-param prefill path).

**Share success toast strict-mode violation** — the "Link Copied
Successfully!" toast
coexisted with the cancelled-query info toast, so the broad selector
matched 2 elements. →
Match the share-result toast by message with `.first()` in the share
helpers.

**`searchPatterns.spec.js` — async pattern extraction still
empty/timeout after 60s** under
alpha indexing load. → `setupPatternsView` re-runs the query and waits
once more before giving
up (resilience for the data dependency; callers still assert the
returned state).

## Scope / safety

- **5 files:** `pages/logsPages/logsPage.js` + specs `logsDownloads`,
`monaco-query-prefill`,
  `shareLink`, `searchPatterns`. **No product code.**
- **No tests deleted, no `.only`, no unconditional skips, no assertions
removed.**
- Every fix replaces a fixed sleep / wrong assumption with a
deterministic wait on the real
  condition — no `waitForTimeout`, no `force`, no retry-based masking.

## Validation

- Local on cloud alpha (`retries:0`, stricter than CI's `retries:1`):
- `logsDownloads` **14/14** (`--workers=3`) — no timeouts, no "Target
page closed".
- Previously-flaky share-link / SQL / searchpartition tests **12/12**
under `--repeat-each=3`
(`sql_mode` committed on the first attempt every time; retry never
needed).
- Full `shareLink` + `monaco-query-prefill` files **15/15** — no
regressions.
- alpha1 Logs-Queries + Logs-Features CI: green —
https://github.com/openobserve/o2-enterprise/actions/runs/29539009573


🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 09:27:04 +00:00
..