Files
openobserve/tests/ui-testing/pages/generalPages/correlationDrawerPage.js
Shrinath Rao cb78ef36fd test(sentinel): complete POM compliance — Dashboards + Correlation (follow-up to #13727) (#13735)
## Summary

Completes the Sentinel **Page Object Model** compliance sweep of the
Playwright suite (follow-up to #13727, which covered the non-Dashboards
shards). Every raw `page.locator(...)` / `page.getBy*(...)` selector —
in **actions and assertions** — is relocated out of the spec files into
the relevant page object; specs now call page-object methods/getters
only.

**Result: 0 raw fixture-`page` selectors across the entire
`playwright-tests` suite** (single-line *and* multi-line, verified with
a dotall/multiline scanner). Together with #13727, the whole suite is
POM-clean.

## What's in this PR

**Dashboards shards — ~1,460 selectors** relocated into their page
objects (`dashboard-panel-configs/actions/edit/time`, `dashboard-chart`,
`dashboard-variables-scoped`, `dashboard-filter`, `dashboard-drilldown`,
`crossLinkPage`, `visualise`, `dashboard-share-export`,
`dashboard-create`, `dashboard-settings`, `dashboard-variables`):

| Shard | selectors |
|-------|----------:|
| Dashboard-Config-Settings (11 specs) | ~255 |
| Dashboards-Variables (12 specs, 4 batches) | ~693 |
| Dashboards-Tables (7 specs) | ~127 |
| Dashboards-Charts (9 specs) | ~81 |
| Dashboards-Core + Visualize (10 specs) | ~144 |
| Dashboards-Settings + Panel-DateTime (8 specs) | ~107 |
| Dashboard-Regression (1 spec) | ~52 |

**Correlation UI specs** (3 new `Correlation/*.ui.spec.js` that arrived
via main's merge, after the original audit) — converted into a new
`correlationDrawerPage` + an extended `correlationSettingsPage`, with
`PageManager` wired into specs that previously used none.

**Audit stragglers** the original **single-line** audit grep
undercounted — multi-line `page\n.locator(...)` chains in
`logstable.spec.js` (→ `logsPage.getTableHeaderByField()`) and
`dashboard-streaming.spec.js` (2 add-panel selectors).

**AI-review fixes** (DeepSeek, on this PR) — removed 2 dead-code
duplicate getters + 1 redundant method alias (merge artifacts from the
sequential batch commits).

One Node-context `console.log` (`dashboard-general-setting`'s
`beforeEach`) → `testLogger.info`.

## Approach

Nearly every Dashboards spec shares the same page objects, so the work
was done in **sequential batches** (one committed, verified unit at a
time) to keep page-object edits conflict-free. 13 commits, mapping 1:1
to those batches.

## Not changed (by design)

- **`waitForTimeout`** left as-is — logged in the audit, not rewritten
(per direction).
- **Browser-context code inside `page.evaluate()` /
`waitForFunction()`** (`document.querySelector`, `window.*`) left as-is
— it runs in the page's JS engine, not Node, so `testLogger` (a Node
module) can't be called there. *No `console.*` remained in dashboards
specs*; the Node-context ones were converted to `testLogger`.
- **`newPage.locator(...)`** on separate popup `Page` instances left
as-is (not the fixture `page`).

## Verification

- **0 raw fixture-`page` selectors** across all specs — single- and
multi-line, comments stripped.
- All changed `.js` files pass `node --check`.
- **CI-gated** for browser execution (no local runs), consistent with
#13727. The enterprise E2E crosscheck already passed against this PR.

## Stats

82 files changed (+3,355 / −2,211) — 61 specs, 21 page objects.
Selectors **moved into page objects, not deleted**.
2026-08-11 06:09:06 +00:00

122 lines
4.0 KiB
JavaScript

import { expect } from '@playwright/test';
/**
* Page Object for the Correlation Event Drawer.
*
* This is the "correlate-from-a-log" drawer surfaced from the Logs page: the
* correlated-logs tab/table, the correlation event-header chips, the error
* state, and the log-correlation entry button. Distinct from the Correlation
* Settings screen (see CorrelationSettingsPage).
*/
export class CorrelationDrawerPage {
constructor(page) {
this.page = page;
// ==================== Drawer Selectors ====================
this.correlatedLogsTab = '[data-test="correlated-logs-tab"]';
this.correlatedLogsTable = '[data-test="correlated-logs-table"]';
this.correlatedMetricsTab = '[data-test="correlated-metrics-tab"]';
// Chips render per matched dimension; match by data-test prefix.
this.eventHeaderChips = '[data-test^="correlation-event-header"]';
this.errorState = '[data-test="error-state"]';
this.logCorrelationBtn = '[data-test="log-correlation-btn"]';
// Logs result table (source of the correlate journey).
this.logsResultTable = '[data-test="logs-search-result-logs-table"]';
// Apply button on the editable DimensionFiltersBar.
this.applyDimensionFiltersBtn = '[data-test="apply-dimension-filters"]';
}
// ==================== Getters (raw-selector relocation) ====================
/**
* Correlated logs tab locator (first match).
* @returns {import('@playwright/test').Locator}
*/
getCorrelatedLogsTab() {
return this.page.locator(this.correlatedLogsTab).first();
}
/**
* Correlated logs table locator (first match).
* @returns {import('@playwright/test').Locator}
*/
getCorrelatedLogsTable() {
return this.page.locator(this.correlatedLogsTable).first();
}
/**
* Correlation event-header chips locator (all matches).
* @returns {import('@playwright/test').Locator}
*/
getEventHeaderChips() {
return this.page.locator(this.eventHeaderChips);
}
/**
* Error-state locator (first match).
* @returns {import('@playwright/test').Locator}
*/
getErrorState() {
return this.page.locator(this.errorState).first();
}
/**
* Log-correlation entry button locator (first match).
* @returns {import('@playwright/test').Locator}
*/
getLogCorrelationBtn() {
return this.page.locator(this.logCorrelationBtn).first();
}
/**
* Event text (e.g. a dimension value) matched by visible text, non-exact.
* @param {string} name - Text to match.
* @returns {import('@playwright/test').Locator}
*/
getEventTextByName(name) {
return this.page.getByText(name, { exact: false });
}
/**
* Correlated metrics tab locator (first match).
* @returns {import('@playwright/test').Locator}
*/
getCorrelatedMetricsTab() {
return this.page.locator(this.correlatedMetricsTab).first();
}
/**
* Logs result table rows (`tbody tr`).
* @returns {import('@playwright/test').Locator}
*/
getLogsResultTableRows() {
return this.page.locator(`${this.logsResultTable} tbody tr`);
}
/**
* Dimension-filter control for a given dimension key.
* @param {string} key - Dimension key (e.g. "k8s-cluster").
* @returns {import('@playwright/test').Locator}
*/
getDimensionFilter(key) {
return this.page.locator(`[data-test="dimension-filter-${key}"]`).first();
}
/**
* Apply button on the editable DimensionFiltersBar (first match).
* @returns {import('@playwright/test').Locator}
*/
getApplyDimensionFiltersButton() {
return this.page.locator(this.applyDimensionFiltersBtn).first();
}
/**
* Role=option locator matched by name (string or RegExp).
* @param {string|RegExp} name - Option accessible name.
* @returns {import('@playwright/test').Locator}
*/
getOptionByName(name) {
return this.page.getByRole('option', { name });
}
}