@gravitee/graphene-core 3.30.0 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/USAGE_GUIDE.md +26 -1
  2. package/package.json +3 -2
package/USAGE_GUIDE.md CHANGED
@@ -1043,9 +1043,34 @@ const editForm = screen.getByRole('form', { name: 'edit' });
1043
1043
  inputHarness({ name: /email/i, within: editForm }).type('new@test.com');
1044
1044
 
1045
1045
  // Disambiguate by data-testid (escape hatch)
1046
- buttonHarness({ selector: '[data-testid="row-3-delete"]' }).click();
1046
+ buttonHarness({ selector: '[data-testid="apis-list-delete-petstore"]' }).click();
1047
1047
  ```
1048
1048
 
1049
+ ### Test ids
1050
+
1051
+ The platform e2e suite selects elements by `data-testid` only. These are the rules Graphene follows, and what you can rely on across releases.
1052
+
1053
+ **Rules**
1054
+
1055
+ - **One attribute.** The test id is the `data-testid` attribute, on every component, base and composed. There is no `testId` or `testIdPrefix` prop, and no `data-test`, `data-cy` or `id` alias.
1056
+ - **Your id wins.** The id you pass always wins. An element you compose yourself (a `DialogClose`, a `SelectItem`, a `Button` placed in a slot such as `actions` or `children`) keeps your own id.
1057
+ - **No default ids.** Graphene never sets an id when you pass none.
1058
+ - **Where the id lands.**
1059
+ - Form fields: the native control (`button`, `input`, `textarea`, the `button[role=checkbox|switch|radio]`).
1060
+ - Anything that opens an overlay: the trigger.
1061
+ - Dialogs, sheets, drawers and popovers: the content node inside the portal, not the overlay.
1062
+ - Rows: the `<tr>`.
1063
+ - Radix roots that render no element (`Dialog`, `Select`, `DropdownMenu`, `Popover`, `Tooltip`, …) have no target: put the id on their Trigger, Content or Item.
1064
+ - Each component's docs page names its element and its derived parts: "Test id lands on …". Only what a docs page states is guaranteed.
1065
+ - **Derived ids.** A component may give the parts it renders itself, that you can't compose, an id derived from yours: `${id}-<part>`, or `${id}-<part>-<key>` with a key taken verbatim from your data (a built-in close button would be `${id}-close`). Which parts exist is on each component's docs page: don't assume one it doesn't list. Match exact ids, not prefixes.
1066
+ - **Stability.** Documented targets and part names are public API. Renaming or removing one, or moving it to another element, ships only in a major version, with a release note.
1067
+ - **Ids never change rendering.** An id never adds an element or a wrapper.
1068
+ - **Naming is yours.** The naming convention (`<context>-<subject>-<role>`, kebab-case, a stable key after a static prefix, never a label or an index), your id registry and its enforcement belong to your module.
1069
+
1070
+ **Exception: toasts**
1071
+
1072
+ A toast is created by a function call, so pass `toast(message, { testId })`. Sonner renders it as `data-testid` on the toast element. It is the only entry point that is not the `data-testid` attribute. Sonner's built-in close and action buttons can't be tagged.
1073
+
1049
1074
  ## Common mistakes to avoid
1050
1075
 
1051
1076
  - Importing `@gravitee/graphene-core/styles` **before** the app Tailwind entry when using Tier 2 (preflight can override Graphene base styles such as default border color).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravitee/graphene-core",
3
- "version": "3.30.0",
3
+ "version": "3.31.0",
4
4
  "type": "module",
5
5
  "description": "Gravitee's Graphene design system: accessible React components, design tokens, icons, and shared ESLint/TypeScript configs. Built on shadcn/ui and Tailwind.",
6
6
  "keywords": [
@@ -77,7 +77,8 @@
77
77
  "build-storybook": "storybook build",
78
78
  "shadcn": "shadcn",
79
79
  "sync-ai-rules": "node scripts/sync-ai-rules.mjs",
80
- "test": "vitest run"
80
+ "test": "vitest run",
81
+ "test:ids:update": "UPDATE_PENDING_TEST_IDS=1 vitest run src/__tests__/test-ids.test.tsx"
81
82
  },
82
83
  "dependencies": {
83
84
  "@base-ui/react": "1.4.1",