-
[OPIK-6595] [QA] feat: Dataset CRUD smoke (SDK-create + UI-create variants) (#6851)
发布于
2026-05-26 07:15:21 +00:00 - [OPIK-6595] [QA] feat: add POST /datasets bridge route
Wraps opik.Opik().create_dataset(name, description, project_name) plus
dataset.insert(items) so the e2e suite can seed datasets via the
Python SDK code path users invoke. Mirrors the projects/traces route
pattern: per-request auth via X-Opik-Api-Key header, ApiError -> HTTP
via the app-wide exception handler, flush=True on client.end() to
drain the streamer that dataset.insert() enqueues to.- feat(sdk): add createDataset on PythonSdkClient
Thin HTTP wrapper over POST /datasets, mirroring createTrace.
Snake_case fields preserved end-to-end (project_name, etc.) so the
bridge schema is the single source of truth — no per-route case
mapping to drift.- feat(backend-client): add dataset inspection + delete methods
Adds findDatasetByName, listDatasetsWithPrefix, deleteDataset, and
getDatasetItems to backendClient. Inspection methods source from
opik.api.datasets.* (public surface), enabling the UI-create test
variant ("create via UI, verify via SDK") plus orphan-sweep coverage
for datasets.deleteDataset is needed because dataset rows do not cascade-delete
with their parent project — a dataset whose project is removed
remains queryable with a dangling project_id reference. Confirmed
against staging during route verification.- feat(teardown): sweep cuj-* datasets in addition to projects
Datasets don't cascade-delete with their parent project, so the
per-run cuj-{runId}- prefix sweep needs to handle them explicitly.
Datasets are swept BEFORE projects so a sweep failure on a dataset
doesn't leave a project + dangling-reference dataset pair around.
The start-of-run orphan sweep (>6h) gets the same treatment for
crashed-run leftovers.- feat(fixtures): add dataset fixture extending trace
Seeds a dataset with 3 deterministic items via the new bridge route
under the test's project. Explicit teardown via
backendClient.deleteDataset because datasets don't cascade with
project deletion. Honors OPIK_LEAVE_FAILURES like the other entity
fixtures.Becomes the new top of the composition chain
(base -> project -> scratch -> failureArtifacts -> trace -> dataset),
re-exported from fixtures/index.ts so test files inherit the full
stack via a single barrel import.- feat(fe): add data-testids for Dataset CRUD smoke test
Adds four data-testids on the Datasets UI to give the E2E suite stable
selectors for the three near-identical "Save changes" buttons that
co-exist when a dataset is in draft mode (panel-level stager, page-
level committer, modal confirm), plus the items toolbar "Add item"
button that collapses to icon-only (no accessible name) at narrow
viewports:- dataset-items-add-button on the items toolbar Add button
- dataset-items-commit-button on the page header Save changes
- dataset-items-discard-button on the page header Discard changes
- dataset-version-commit-dialog on the version-commit modal root
All four are additive: no behavior change, no visual change. The
buttons share accessible names with sibling components so role+name
selectors return multiple matches under contention — the testids are
the unambiguous selectors.- feat(pom): add DatasetsPage and DatasetItemsPage
DatasetsPage models the project-scoped /datasets/ list view plus the
three-step "Create dataset" side-pane dialog (name+description, then
empty-state CSV/SDK chooser, then Dataset-created success).DatasetItemsPage models the per-dataset items view, including the
two-phase write workflow that's the defining UX of this surface:
panel-level Save stages a local Draft; page-level Save commits the
draft as a new dataset version via a confirmation modal. Both add
(via panel) and delete (via row Actions -> confirm dialog) are draft
operations until commitDraft() persists them.addItemViaEmptyStateModal handles the alternate JSON-editor modal the
FE shows when an empty dataset's "Add item" trigger is clicked — a
separate code path that commits directly without going through the
draft cycle.Selectors prefer the four data-testids added in this PR; fall back to
getByRole + name where the testid is not yet deployed (so the test
runs cleanly against current staging before the FE testid changes
ship).- test(datasets): Dataset CRUD smoke (SDK-create + UI-create variants)
Two T1 cases tagged @t1-smoke @datasets:
Test A (SDK-create -> UI-verify): the dataset fixture seeds a 3-item
dataset via the bridge. The test drills into the items page, exercises
the side-panel Add Item flow + page-level commit (v2), then the
Actions-menu Delete flow + commit (v3), asserting both Draft and
committed-version states throughout.Test B (UI-create -> SDK-verify): drives the Create-dataset dialog
end-to-end (name + description -> Next -> Create -> success ->
Close), verifies via backendClient.findDatasetByName that the
metadata round-trips, then drills into the items page and exercises
the empty-state Add-item modal, verifying the item via
backendClient.getDatasetItems.Wider 1600x900 viewport so the items toolbar isn't collapsed to
icon-only (where the Add item button loses its accessible name in
deployments that don't yet carry the dataset-items-add-button
testid).- chore: tighten comments across dataset POMs, fixture, teardown
Collapse multi-line // blocks into single-line /** */ where a comment
is load-bearing, drop redundant "what the code does" prose. The two
non-obvious behaviors callers actually need to know about — datasets
not cascading with project delete, and the items panel being kept
mounted with CSS transforms — stay called out.- docs(pom): note countItems() returns current-page count, not total
The items table is paginated (default 10/page); a future test that
seeds beyond the page size should sum across pages or read the
"Showing X of Y" text (and account for it being stale during drafts).下载附件