Files
openobserve/tests/ui-testing/playwright-tests/Streams/streaming.spec.js
T
Shrinath RaoandClaude Opus 4.7 e2813291ce test: stabilise alpha1 e2e tests via UI org-switch (#11528)
## Summary

Stabilises alpha1 cloud E2E tests across the Logs-Core shard. Fixes a
UI/API org mismatch root cause, adds env-aware query execution helpers,
and brings all 10 changed spec files into POM compliance.

## Root cause (original)

After Dex login, the Pinia store binds all API calls to the user's
*default* org. The URL `?org_identifier=...` alone does not update the
store. Ingestion went to the `.env` org while UI searches went to the
user's default org → empty results → cascading test failures.

## Changes

### Alpha1 environment / authentication
- **`global-setup-alpha1.js`** — switches active org via the navbar
dropdown after Dex login so the Pinia store adopts the correct org;
`context.storageState` captures the result for all test contexts
- **`playwright-alpha1.config.js`** — `ORGNAME` sourced purely from
`.env`; cloud-config override removed
- **`loginPage.login()` / `unflattened.spec.js`** — include
`?org_identifier=${ORGNAME}` in SPA navigation to prevent defaulting to
`_meta`
- **`unflattened.js openStreamDetail()`** — replaced broken
stream-name-text click with `Stream Detail` action button + Schema-tab
visibility wait

### Auto-run query handling (`auto_query_enabled` flag)
- **`logsPage.js`** — added `runQueryAfterModeChange()`: on alpha1
(`auto_query_enabled=true`) waits for the in-flight auto-query to
complete; on local triggers a fresh query. Fixes
`@interestingFieldsCRUD` and `@quickModeResults` tests that were passing
on alpha1 but failing locally because the old fix clicked Refresh
mid-auto-run (hitting Cancel)
- **`logsQueryPage.js`** — null-guard `textContent()` return in
`_toggleAutoRun()` (`|| ''`) to satisfy Playwright's `string | null`
type contract

### Merge conflict resolution
- **`logsPage.js enableQuickModeIfDisabled()`** — kept HEAD's version
that defines `quickModeIndicator` at the top of the function (used in
the retry loop); discarded main's version that opened the utilities menu
before the variable was defined

### POM compliance (Sentinel audit)
Added three new POM methods to **`logsPage.js`**:
- `watchForNotification(timeout)` — returns a promise for pre-action
race-condition-safe notification watching
- `expectNotificationContainsText(text)` — notification text assertion
- `waitForNotificationWithText(text, timeout)` — notification waiter
with text filter

Removed raw locators from spec files:
- **`logspage.spec.js`** — notification race pattern →
`watchForNotification()` + `expectNotificationContainsText()`; 5-line
raw histogram toggle block → `ensureHistogramState(true)` (POM method
already existed)
- **`logsqueries.spec.js`** —
`pm.logsPage.page.waitForSelector('.q-notification__message:has-text(...)')`
→ `waitForNotificationWithText()`
- **`jobSearch.spec.js`** — added `testLogger` import; replaced 14×
`console.log` with `testLogger.info`; raw Monaco editor locators (lines
158–168) → `logsPage.waitForQueryEditorVisible()` +
`logsPage.getQueryEditorText()` (both already in POM)

### Tags
- **`jobSearch.spec.js`** — all 8 tests now tagged: `@jobSearch,
@P0/@P1` with functional sub-tags (`@smoke`, `@crud`, `@validation`)
- **`logshistogram.spec.js`** — all 5 tests now include `@P1`

## Results

- All `logsquickmode.spec.js` tests pass on both local and alpha1
- Zero Sentinel critical issues remaining across all 10 changed spec
files
- Remaining warnings (old-style auth in `jobSearch.spec.js` /
`pagination.spec.js`, `pm.logsPage.page.reload()` in
`logsquickmode.spec.js`) are pre-existing tech debt deferred to a
separate PR

## Test plan

- [ ] Run `logsquickmode.spec.js` locally and on alpha1 — both should
pass
- [ ] Run full Logs-Core shard on alpha1: `npx playwright test --config
playwright-alpha1.config.js
playwright-tests/Logs/{join,logspage,logsquickmode,pagination,unflattened,logshistogram,jobSearch,logsqueries,logsAnalyzeDimensions}.spec.js`
- [ ] Verify global setup logs: `Switching active org to: <ORGNAME>` →
`Org switch complete`
- [ ] Confirm no `console.log` output in `jobSearch.spec.js` test run
(all replaced by `testLogger`)

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

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 16:19:54 +00:00

189 lines
8.6 KiB
JavaScript

const { test, expect, navigateToBase } = require('../utils/enhanced-baseFixtures.js');
const PageManager = require('../../pages/page-manager.js');
const testLogger = require('../utils/test-logger.js');
test.describe.configure({ mode: 'parallel' });
test.describe("Streaming for logs", () => {
let pm;
test.beforeEach(async ({ page }, testInfo) => {
testLogger.testStart(testInfo.title, testInfo.file);
await navigateToBase(page);
pm = new PageManager(page);
await pm.streamsPage.ingestion();
await pm.streamsPage.ingestionJoin();
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.goToManagement();
await page.waitForTimeout(2000);
testLogger.info('Test setup completed - ready for streaming tests');
});
test.afterEach(async ({}, testInfo) => {
if (testInfo.status) {
testLogger.testEnd(testInfo.title, testInfo.status, testInfo.duration);
}
});
test("Run query after selecting two streams after enabling streaming", {
tag: ['@streaming', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.displayTwoStreams();
await pm.streamsPage.selectRunQuery();
});
test("Enable Streaming for running query after selecting two streams and SQL Mode On", {
tag: ['@streaming', '@sqlMode', '@all', '@streams']
}, async ({ page }) => {
testLogger.info('Testing streaming with two streams and SQL Mode');
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.displayTwoStreams();
});
test("Enable Streaming for running query after selecting two streams, selecting field and SQL Mode On", {
tag: ['@streaming', '@sqlMode', '@all', '@streams']
}, async ({ page }) => {
testLogger.info('Testing streaming with two streams and field selection');
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerName();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for running query after selecting two streams, SQL Mode On and entering join queries", {
tag: ['@streaming', '@sqlMode', '@joins', '@all', '@streams']
}, async ({ page }) => {
testLogger.info('Testing streaming with join queries');
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerNameJoin();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.displayCountQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for running query after selecting two streams, SQL Mode On and entering join limit", {
tag: ['@streaming', '@sqlMode', '@joins', '@all', '@streams']
}, async ({ page }) => {
testLogger.info('Testing streaming with join limit');
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerNameJoinLimit();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for running query after selecting two streams, SQL Mode On and entering join like", {
tag: ['@streaming', '@sqlMode', '@joins', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerNameJoinLike();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for running query after selecting two streams, SQL Mode On and entering Left join queries", {
tag: ['@streaming', '@sqlMode', '@joins', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerNameLeftJoin();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for running query after selecting two streams, SQL Mode On and entering Right join queries", {
tag: ['@streaming', '@sqlMode', '@joins', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerNameRightJoin();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for running query after selecting two streams, SQL Mode On and entering Full join queries", {
tag: ['@streaming', '@sqlMode', '@joins', '@all', '@streams']
}, async ({ page }) => {
testLogger.info('Testing streaming with FULL JOIN queries');
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.kubernetesContainerNameFullJoin();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.validateResult();
});
test("Enable Streaming for clicking on interesting field icon and display field in editor", {
tag: ['@streaming', '@interestingFields', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.clickQuickModeToggle();
await pm.streamsPage.clickAllFieldsButton();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.clickInterestingFields();
await pm.streamsPage.validateInterestingFields();
});
test("Enable Streaming for clicking on interesting field icon and display query in editor", {
tag: ['@streaming', '@interestingFields', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.clickQuickModeToggle();
await pm.streamsPage.clickAllFieldsButton();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.clickInterestingFields();
await pm.streamsPage.validateInterestingFieldsQuery();
});
test("Enable Streaming for Adding or removing interesting field removes it from editor and results too", {
tag: ['@streaming', '@interestingFields', '@all', '@streams']
}, async ({ page }) => {
testLogger.info('Testing add/remove interesting fields');
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexAndStreamJoin();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.clickQuickModeToggle();
await pm.streamsPage.clickAllFieldsButton();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.clickInterestingFields();
await pm.streamsPage.addRemoveInteresting();
});
test("Streaming enabled histogram is disabled and run query, results appear and then user switches on Histogram, getting error", {
tag: ['@streaming', '@histogram', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexStreamDefault();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.toggleHistogram();
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.toggleHistogram();
await pm.streamsPage.verifyNoHistogramError();
});
test("No Histogram should be displayed if Data is not available", {
tag: ['@streaming', '@histogram', '@all', '@streams']
}, async ({ page }) => {
await pm.streamsPage.navigateToLogs();
await pm.streamsPage.selectIndexStreamDefault();
await pm.streamsPage.enableSQLMode();
await pm.streamsPage.clearAndFillQueryEditor('SELECT count(_timestamp) FROM "default" where code = 201');
await pm.streamsPage.selectRunQuery();
await pm.streamsPage.expectNoDataFoundForHistogram();
});
});