mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
## 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>
103 lines
3.6 KiB
JavaScript
103 lines
3.6 KiB
JavaScript
// @ts-check
|
|
const { defineConfig, devices } = require('@playwright/test');
|
|
const path = require('path');
|
|
const dotenv = require('dotenv');
|
|
const testLogger = require('./playwright-tests/utils/test-logger.js');
|
|
|
|
// Mark this as a cloud environment for page objects and auth helpers
|
|
process.env.IS_CLOUD = 'true';
|
|
|
|
// Load environment variables from .env file
|
|
const envResult = dotenv.config();
|
|
if (envResult.error) {
|
|
testLogger.warn('No .env file found, using system environment variables');
|
|
} else {
|
|
testLogger.info('Environment variables loaded from .env file');
|
|
}
|
|
|
|
// Check alpha1-specific environment variables
|
|
if (!process.env.ZO_BASE_URL) {
|
|
testLogger.warn('ZO_BASE_URL not set. Must be provided for alpha1 cloud tests.');
|
|
throw new Error('ZO_BASE_URL must be set to run alpha1 tests');
|
|
}
|
|
if (!process.env.ALPHA1_USER_EMAIL || !process.env.ALPHA1_USER_PASSWORD) {
|
|
testLogger.warn('ALPHA1_USER_EMAIL and ALPHA1_USER_PASSWORD must be set for Dex email login');
|
|
}
|
|
|
|
// Set ZO_ROOT_USER_* as fallbacks from ALPHA1_* env vars so that spec files
|
|
// and utility modules that reference ZO_ROOT_USER_EMAIL/PASSWORD work on cloud
|
|
if (!process.env.ZO_ROOT_USER_EMAIL && process.env.ALPHA1_USER_EMAIL) {
|
|
process.env.ZO_ROOT_USER_EMAIL = process.env.ALPHA1_USER_EMAIL;
|
|
}
|
|
if (!process.env.ZO_ROOT_USER_PASSWORD && process.env.ALPHA1_USER_PASSWORD) {
|
|
process.env.ZO_ROOT_USER_PASSWORD = process.env.ALPHA1_USER_PASSWORD;
|
|
}
|
|
|
|
// On cloud, INGESTION_URL must point to the alpha base URL (not localhost from .env)
|
|
if (!process.env.INGESTION_URL || process.env.INGESTION_URL.includes('localhost')) {
|
|
process.env.INGESTION_URL = process.env.ZO_BASE_URL;
|
|
testLogger.info(`INGESTION_URL set to ZO_BASE_URL: ${process.env.ZO_BASE_URL}`);
|
|
}
|
|
|
|
// ORGNAME comes from .env. global-setup-alpha1.js performs a UI org-switch
|
|
// post-login so the Pinia store binds API calls to this org, and writes
|
|
// cloud-config.json with the matching passcode for ingestion.
|
|
testLogger.info(`ORGNAME from .env: ${process.env.ORGNAME}`);
|
|
|
|
/**
|
|
* Alpha1 Cloud Playwright Configuration
|
|
* Uses Dex "Continue with Email" login flow
|
|
*/
|
|
module.exports = defineConfig({
|
|
testDir: './playwright-tests',
|
|
testMatch: ['**/*.spec.js'],
|
|
outputDir: './test-results',
|
|
testIgnore: ['**/test-archives/**', '**/*_old.js'],
|
|
|
|
// Custom global setup for Dex email login
|
|
globalSetup: './playwright-tests/utils/global-setup-alpha1.js',
|
|
globalTeardown: './playwright-tests/utils/global-teardown.js',
|
|
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 1 : 0,
|
|
workers: 3,
|
|
|
|
reporter: process.env.CI
|
|
? [
|
|
['blob', { outputDir: 'blob-report' }],
|
|
]
|
|
: [
|
|
['html', { outputFolder: 'playwright-results/html-report', open: 'never' }],
|
|
['json', { outputFile: 'playwright-results/report.json' }]
|
|
],
|
|
|
|
use: {
|
|
baseURL: process.env.ZO_BASE_URL,
|
|
trace: 'on-first-retry',
|
|
navigationTimeout: process.env.CI ? 90000 : 30000,
|
|
actionTimeout: process.env.CI ? 45000 : 15000,
|
|
screenshot: process.env.CI ? 'only-on-failure' : 'off',
|
|
video: process.env.CI ? 'retain-on-failure' : 'off',
|
|
},
|
|
|
|
timeout: process.env.CI ? 5 * 60 * 1000 : 3 * 60 * 1000,
|
|
|
|
expect: {
|
|
timeout: process.env.CI ? 30000 : 10000,
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: {
|
|
...devices['Desktop Chrome'],
|
|
viewport: { width: 1500, height: 1024 },
|
|
permissions: ['clipboard-read', 'clipboard-write'],
|
|
// Reuse auth state from global setup (Dex email login)
|
|
storageState: path.join(__dirname, 'playwright-tests/utils/auth/user.json'),
|
|
},
|
|
},
|
|
],
|
|
});
|