Files
openobserve/tests/ui-testing/playwright-tests/Functions
Shrinath Rao 8bf9eac8a2 test: Functions test suite rework - 67% reduction with full validation coverage (#9957)
## Summary

Rework of the Functions test suite to reduce test count while
maintaining 100% validation coverage.

| Metric | Before | After | Change |
|--------|--------|-------|--------|
| **UI Tests** | 36 | 12 | **-67%** |
| **API Tests (Python)** | 0 | 16 | +16 new |
| **Validation coverage** | 100% | 100% | Preserved |
| **CI Integration** | ❌ | ✅ | Added |

**Cleanup performed:**
- 3 placeholder tests removed (only had logging, no assertions)
- 1 duplicate test removed
- 4 cross-file duplicates deduplicated

## What Changed

### Test File Consolidation

| Original Spec Files | Final Spec File | Original | Final | Reduction |
|---------------------|-----------------|----------|-------|-----------|
| `meta-org-js-restriction.spec.js` + `javascript-functions.spec.js` |
`js-transform-type.spec.js` | 22 | 6 | 73% |
| `result-array-functions.spec.js` | `row-expansion.spec.js` | 14 | 6 |
57% |
| **Total** | **2 files** | **36** | **12** | **67%** |

### New Python API Tests

Added 16 comprehensive API tests in
`tests/api-testing/tests/test_functions_meta_org_restriction.py`:

| Category | Count | Tests |
|----------|-------|-------|
| JS Restriction (blocked in default org) | 5 | create/test/update
blocked |
| VRL Functions (work in default org) | 4 | create/test/update works |
| Auto-Detection | 2 | trans_type auto-detection |
| Error Messages | 2 | content and consistency |
| Edge Cases | 3 | empty/invalid/case-sensitivity |

### Critical Bugs Fixed

1. **Missing `_meta` org navigation** - JavaScript functions are ONLY
allowed in `_meta` organization. Tests were navigating to default org.
2. **Python API tests using wrong field names** - Create/Update use
`transType` (camelCase), Test endpoint uses `trans_type` (snake_case).
3. **Missing pipeline cleanup pattern** - Added `realfile*` pattern that
was causing 409 errors.

## Files Modified

### UI Tests (Final)
-
`tests/ui-testing/playwright-tests/Functions/js-transform-type.spec.js`
(6 tests)
- `tests/ui-testing/playwright-tests/Functions/row-expansion.spec.js` (6
tests)

### UI Tests (Removed/Consolidated)
- `meta-org-js-restriction.spec.js` → merged into
`js-transform-type.spec.js`
- `javascript-functions.spec.js` → merged into
`js-transform-type.spec.js`
- `result-array-functions.spec.js` → renamed to `row-expansion.spec.js`

### Cleanup Infrastructure
- `tests/ui-testing/playwright-tests/cleanup.spec.js` - Consolidated
function cleanup, added realfile* pattern
- `tests/ui-testing/pages/apiCleanup.js` - Added org-aware cleanup
methods

### API Tests (New)
- `tests/api-testing/tests/test_functions_meta_org_restriction.py` - 16
new tests

### CI Integration
- `.github/workflows/playwright.yml` - Added Functions test matrix entry

## Final Test List (12 UI Tests)

### js-transform-type.spec.js (6 tests)
| # | Test | Priority |
|---|------|----------|
| 1 | P0: JavaScript function creation flow in _meta org | @smoke, @P0 |
| 2 | P0: JS function creation and validation flow | @smoke, @P0 |
| 3 | P1: JS function execution and error handling | @P1 |
| 4 | P1: JS function error cases | @P1 |
| 5 | P0: Default org - JS hidden, VRL works | @smoke, @P0 |
| 6 | P1: Radio visibility across orgs | @P1 |

### row-expansion.spec.js (6 tests)
| # | Test | Priority |
|---|------|----------|
| 1 | P0: VRL row expansion creation and validation flow | @smoke, @P0 |
| 2 | P2: VRL row expansion edge cases | @P2 |
| 3 | P0: JS row expansion creation and validation flow | @smoke, @P0 |
| 4 | P1: JS row expansion edge cases and transformations | @P1 |
| 5 | P1: Compare VRL and JS row expansion output | @P1 |
| 6 | P1: Pipeline integration and error handling | @P1 |

## Test plan

- [x] All 12 UI tests passing locally
- [x] All 16 Python API tests passing locally
- [x] Sentinel audit passed (POM compliant, no raw selectors)
- [x] Hard assertions applied (no soft assertions)
- [ ] CI pipeline runs successfully
2026-01-10 07:49:28 +05:30
..