Files
openobserve/tests/ui-testing/playwright-tests/utils/test-constants.js
T
Neha PandClaude 24b024a502 test: automation for bugs fixes (#9678)
### **User description**
## Summary
Refactored the logs regression test suite to follow the Page Object
Model (POM) pattern by centralizing all locators in the logsPage.js POM
file and updating test files to use these locators instead of hardcoded
selectors.


## Testing
All 10 regression tests passing:
- ✅ Absolute time error validation
- ✅ Stream switching with saved views (#9388)
- ✅ Field values with SUBQUERY/CTE/GROUP BY (#7751)
- ✅ Pagination count after search (#8868)
- ✅ Alert graph color display (#9311)
- ✅ Histogram query from history (#8180)
- ✅ Timestamp field in quick mode (#8180)
- ✅ Source field display logic (#8180)

Test execution: 10/10 passed in 7.2 minutes


___

### **PR Type**
Tests, Enhancement


___

### **Description**
- Refactor logs regression tests to Page Object Model
  - Centralize all locators in `logsPage.js`

- Add new POM locators for regression tests

- Add regression tests for bug #7751 (subquery, CTE, GROUP BY)

- Add regression tests for bug #8868 (pagination count update)

- Add regression test for bug #9311 (alert graph color)

- Add regression tests for bug #8180 (histogram, timestamp, source
field)


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["logsPage.js: New POM locators"] --> B["logs-regression.spec.js: Bug regression tests"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>logsPage.js</strong><dd><code>Add POM locators for
regression tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

tests/ui-testing/pages/logsPages/logsPage.js

<ul><li>Added alert-related selectors (<code>alertsMenuItem</code>,
<code>alertGraph</code>, <code>alertChart</code>)<br> <li> Added query
history selectors (<code>queryHistoryButton</code>,
<code>historyPanel</code>)<br> <li> Added table and pagination selectors
(<code>tableBottom</code>, <code>tableBodyRow</code>,
<br><code>tableHeaders</code>)<br> <li> Added dynamic field selector
functions (<code>fieldExpandButton</code>,
<br><code>subfieldAddButton</code>, etc.)<br> <li> Added streams search,
error indicators, timestamp detail selectors</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/9678/files#diff-8045b343491d8943869c1af74cdafab204dc49c02a70294417e73f47d35e0b59">+29/-0</a>&nbsp;
&nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>logs-regression.spec.js</strong><dd><code>Add
regression tests for major log search bugs</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

tests/ui-testing/playwright-tests/RegressionSet/logs-regression.spec.js

<ul><li>Added tests for bug #7751: subquery, CTE, GROUP BY field
expansion<br> <li> Added test for bug #8868: pagination count after
filtering<br> <li> Added test for bug #9311: full alert graph color
rendering<br> <li> Added tests for bug #8180: histogram query, timestamp
in quick mode, <br>source field logic</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/9678/files#diff-99da86ede55fa5f2e3d3fbef897ba7aaa5a7db702a0135f66ac4c888fc7311b6">+538/-0</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-19 16:11:51 +05:30

102 lines
2.6 KiB
JavaScript

/**
* Test Constants for Regression Tests
* Centralized configuration for test data, timeouts, and field names
*/
module.exports = {
// Test Streams
STREAMS: {
TEST_STREAM: 'e2e_automate',
MATCH_ALL: 'e2e_matchall',
},
// Field Names
FIELDS: {
POD_NAME: 'kubernetes_pod_name',
CONTAINER_NAME: 'kubernetes_container_name',
NAMESPACE: 'kubernetes_namespace',
HOST: 'kubernetes_host',
LOG_LEVEL: 'level',
MESSAGE: 'message',
TIMESTAMP: '_timestamp',
SOURCE: 'source',
},
// Wait Times (in milliseconds)
// ⚠️ WARNING: Fixed timeouts are an anti-pattern in Playwright!
// These constants are provided for legacy compatibility only.
//
// PREFERRED APPROACHES:
// 1. await page.waitForLoadState('networkidle')
// 2. await element.waitFor({ state: 'visible' })
// 3. await expect(element).toBeVisible()
// 4. await page.waitForSelector('[data-test="element"]')
//
// Only use these constants when:
// - Waiting for animations/transitions (use TRANSITION)
// - Working around race conditions that can't be fixed with explicit waits
// - Dealing with third-party components without proper loading states
//
// TODO: Replace all usages of these constants with explicit waits
TIMEOUTS: {
// Short waits for UI transitions
TRANSITION: 300,
SHORT: 500,
// Medium waits for API calls and rendering
MEDIUM: 1000,
API_RESPONSE: 1500,
// Long waits for complex operations
LONG: 2000,
NETWORK: 3000,
// Maximum timeouts for operations that should eventually complete
MAX_WAIT: 10000,
MAX_NETWORK: 15000,
},
// Test Data
TEST_DATA: {
ORG_NAME: 'default',
RELATIVE_TIME: {
FIFTEEN_MIN: '15m',
THIRTY_SEC: '30s',
ONE_HOUR: '1h',
SIX_WEEKS: '6w',
},
},
// SQL Queries (templates)
QUERIES: {
SUBQUERY: (stream, field) =>
`SELECT * FROM (SELECT * FROM "${stream}" WHERE ${field} IS NOT NULL LIMIT 100)`,
CTE: (stream, field) =>
`WITH filtered_logs AS (SELECT * FROM "${stream}" WHERE ${field} IS NOT NULL LIMIT 100) SELECT * FROM filtered_logs`,
GROUP_BY: (stream, field) =>
`SELECT ${field}, count(*) as total FROM "${stream}" WHERE ${field} IS NOT NULL GROUP BY ${field} LIMIT 50`,
},
// Error Messages
ERRORS: {
ERROR_400: '400',
NO_STREAM_SELECTED: /select.*stream/i,
NO_VALUES_FOUND: 'No values found',
},
// UI Element States
STATES: {
VISIBLE: 'visible',
HIDDEN: 'hidden',
ATTACHED: 'attached',
DETACHED: 'detached',
},
// Test Priorities
PRIORITIES: {
P0: 'P0',
P1: 'P1',
P2: 'P2',
},
};