Files
openobserve/tests/ui-testing/playwright-tests/auth-warm.spec.js
T
Shrinath Rao 82d14e8458 test(sentinel): POM compliance across Playwright suite (non-Dashboards) (#13727)
## What & why

Sentinel (Council of Agents) audit-driven **Page Object Model
compliance** across the Playwright suite. Many specs (a lot added
recently, some AI-generated) had raw `page.locator(...)` /
`page.getBy*(...)` selectors directly in spec files — including inside
`expect(...)` — which the Sentinel flags as CRITICAL. This PR relocates
those selectors into their page objects and calls page-object
methods/getters instead.

A full audit of **all 256 specs** was generated first (stored locally
under `tests/ui-testing/MD_Files/sentinel-audit-2026-08-10/`, which is
gitignored). Original totals: **1,609** raw selectors, **190** inside
assertions, plus console/testLogger items.

## Scope of THIS PR (non-Dashboards)

Every non-Dashboards spec is now **100% raw-selector clean** (verified:
0 occurrences). Shards covered:

- **GeneralTests, Logs (Core/Builder-Advanced/Features/Regression),
Traces (+Reg), Streams (+Reg), Metrics (+Reg), Pipelines, Reports
(+Reg), Anomaly, Login/auth, auth-warm, and the unmatched Alerts
specs.**
- `console.*` → `testLogger` where it was Node-context (kept `console.*`
**inside `page.evaluate()`** — that's browser context; `testLogger`
doesn't exist there).
- `testLogger` import/use added where missing.
- **`waitForTimeout` intentionally left as-is** (logged in the audit,
not rewritten — per direction).

## Deferred to a follow-up PR

The **heavy Dashboards shards** (Variables 693, Config-Settings 255,
Tables 127, Charts 81, Core 79, Visualize 65, Settings 52,
Panel-DateTime 55, Dashboard-Regression 52 raw selectors) are **not** in
this PR — they're the bulk of the work and will be a separate, focused
pass. (dashboard-streaming console cleanup is included here.)

## Verification

Fixes were applied and executed **shard by shard** against a local env,
gated green before commit where the env allowed:

| Group | Local result |
|-------|--------------|
| GeneralTests (edited specs) | 52 passed / 11 skipped / 0 failed |
| Logs (shareLink, logsQuickPick, indexquery) | 21 passed |
| Traces / Streams / Metrics | 49 passed / 2 skipped / 0 failed |
| Pipelines | 56 passed / 17 skipped / 0 failed |
| logs-bugs :548, dashboard-streaming | verified not regressed
(isolation) |

**Alerts create-wizard specs** (Alerts shard, Alerts-Regression,
unmatched Alerts) could not be gated locally — the alert-creation
wizard's stream popover times out on this env **on unmodified code too**
(reproduced on original, test `:363`), so those refactors are 1:1
selector→method mappings, syntax-clean (`node --check`), and rely on CI
to gate.

Every changed `.js` passes `node --check`. `waitForTimeout` unchanged;
no behavior changes intended.

## Stats
51 files changed. Selectors moved into page objects, not deleted.
2026-08-10 15:30:21 +00:00

38 lines
1.8 KiB
JavaScript

const { test, expect } = require('@playwright/test');
const testLogger = require('./utils/test-logger.js');
const PageManager = require('../pages/page-manager.js');
/**
* Auth-warm spec — mints a shared-auth artifact WITHOUT running the heavy
* org-wide cleanup.
*
* The alpha1 barrier (pre_test_cleanup job) splits its Dex logins across multiple
* users (ALPHA1_USER_INDEX). User 1 runs cleanup.spec.js (which also mints its
* artifact via globalSetup); users 2..N have no cleanup to do, so they run THIS
* spec instead. globalSetup already performed the Dex login and wrote
* user<N>.json / cloud-config<N>.json before this test executes — all this test
* does is confirm the session loads, so the job fails loudly if login didn't take.
*
* Runs with SKIP_INGESTION=true in the barrier (no per-shard ingestion here).
*/
test.describe('Alpha1 auth warm-up', () => {
test('minted session is usable', {
tag: ['@auth-warm', '@all']
}, async ({ page, baseURL }) => {
const userIndex = (process.env.ALPHA1_USER_INDEX || '1').trim();
testLogger.info(`[alpha1] auth-warm: verifying minted session for user index ${userIndex}`);
await page.goto(`${baseURL}/web/`, { timeout: 60000, waitUntil: 'domcontentloaded' });
// If the saved session were invalid we'd be bounced to Dex/login here.
const url = page.url();
expect(url, `expected an authenticated app URL, got ${url}`).not.toContain('dex');
expect(url, `expected an authenticated app URL, got ${url}`).not.toMatch(/\/web\/login$/);
// Home menu item is only present once the SPA has an authenticated session.
const pm = new PageManager(page);
await pm.loginPage.expectHomeMenuVisible(30000);
testLogger.info(`[alpha1] auth-warm: session for user index ${userIndex} is valid`);
});
});