mikebridge opened a new pull request, #45103:
URL: https://github.com/apache/superset/pull/45103

   ### SUMMARY
   
   The Playwright suite has no coverage for dashboards built on semantic views. 
Every semantic-layer provider needs a live warehouse, and the semantic-view 
structure endpoint calls the provider directly, so browser-level regressions 
there can only be caught by hand today.
   
   This PR adds a test-only in-memory semantic-layer provider and the first two 
specs that use it.
   
   - **Stub provider** (`tests/e2e_extensions/semantic_stub/`): a backend-only 
`LOCAL_EXTENSIONS` bundle that registers with the public `@semantic_layer` 
decorator, inside the extension context. Its layer type is therefore 
`extensions.superset-e2e.semantic-stub.stub`, and the host code under test is 
the same code a real provider runs through. It has one `orders` view 
(dimensions `category`/`region`; metrics `total_amount` SUM and `order_count` 
COUNT) over four fixed rows. Query shapes it doesn't implement (HAVING, other 
operators, ad-hoc ordering, group limits) raise an error rather than returning 
unfiltered rows. A future change to the host's query shape then fails the test 
instead of rendering plausible but wrong data.
   - **Test-only config** 
(`tests/integration_tests/superset_test_config_semantic.py`): the base test 
config plus `ENABLE_EXTENSIONS`, `SEMANTIC_LAYERS` and `LOCAL_EXTENSIONS`. Only 
the new E2E step uses it, so the stub never loads for the unit, integration or 
required Playwright runs. It follows the existing `superset_test_config_gaq.py` 
pattern. A narrow `.gitignore` negation commits the bundle's `dist/` directory, 
which the extension loader requires.
   - **Playwright helpers:** seeding for a layer and its view over the REST 
API, with the view id resolved through `GET /api/v1/datasource/` (the 
semantic-view API has no GET). `testAssets` gains `trackSemanticLayer`; 
deleting a layer deletes its views. `buildSelectFilter` gains an optional 
`datasourceType: 'semantic_view'`.
   - **Specs** (`playwright/tests/semantic-view/`):
     1. A semantic-view table chart renders on a dashboard: chart-data returns 
200, and the totals are Books 15, Games 7, Music 3.
     2. A native filter on a semantic-view dimension (region = West) filters 
that chart: Books 5, Music 3, no Games row. With the filter dropped, Books 
would show 15, which the spec rejects.
   - **Skip vs fail:** the specs skip unless the stub is registered, so the 
required run collects and skips them. The new step sets 
`PLAYWRIGHT_REQUIRE_SEMANTIC_STUB=true`, which turns a missing stub into a 
failure. A broken extension load can't pass as an empty run.
   - **Unit test** 
(`tests/unit_tests/semantic_layers/e2e_stub_extension_test.py`): loads the 
bundle through `SupersetAppInitializer.init_extensions()`, asserts the 
extension-prefixed registration, and runs `/api/v1/chart/data` through the host 
mapper into the stub, for unfiltered, dimension-filtered and 
unsupported-operator requests.
   
   **Follow-up:** a third spec is ready and will come in a separate PR once 
#45069 merges. It opens the native-filter config modal on a semantic-view 
dashboard and asserts that the semantic view is the preselected datasource and 
that it is never requested as a SQL dataset. It's left out here because it 
fails until #45069 lands.
   
   **CI cost:** one new step per E2E matrix entry (`app_root` `""` and 
`/app/prefix`), shaped like the existing Soft-delete step: it boots its own 
gunicorn, then runs two specs. Locally, the two specs take about 1.2–1.6 s 
each, and a full run including global login takes 4.4–5.4 s. With the gunicorn 
boot, expect roughly 20–40 s per matrix entry. No new services, containers or 
dependencies.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (tests only).
   
   ### TESTING INSTRUCTIONS
   
   Unit test:
   
   ```bash
   pytest tests/unit_tests/semantic_layers/e2e_stub_extension_test.py
   ```
   
   Playwright, against a backend started with the semantic test config:
   
   ```bash
   export SUPERSET_CONFIG=tests.integration_tests.superset_test_config_semantic
   superset db upgrade && superset load_test_users && superset init
   # build the frontend, then start the server (e.g. gunicorn 
"superset.app:create_app()" on :8088)
   cd superset-frontend
   PLAYWRIGHT_REQUIRE_SEMANTIC_STUB=true npx playwright test semantic-view/
   ```
   
   Local results with retries disabled: each spec passed 3 runs out of 3, and a 
parallel pass (`--workers=2 --repeat-each=5`) passed 10/10. All semantic layers 
the tests created were cleaned up.
   
   The local run used SQLite and in-process caches; this PR's E2E job is the 
Postgres/Redis check. One thing that job verifies: CI runs `superset init` 
under the base config, so the semantic-layer API permissions have to be created 
when gunicorn starts. If the job reports a 403 on `/api/v1/semantic_layer/`, 
the step also needs `superset init` under the semantic config.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [x] Required feature flags: `SEMANTIC_LAYERS`, `ENABLE_EXTENSIONS` (test 
config only)
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to