From f514146fed1dd9fa1de5a4561f71d18fca7410fa Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Mon, 19 Oct 2026 22:31:13 +0200 Subject: [PATCH] feat: built-in type read-only view,s chema list, states, spec files --- features/schema_builtin_view.feature | 171 +++++++++++ features/schema_builtin_view.qa.md | 42 +++ features/schema_list_and_content_nav.feature | 7 +- features/schema_list_and_content_nav.qa.md | 2 +- web/src/components/SchemaFieldTable.vue | 74 +++++ web/src/components/SchemaTable.vue | 43 ++- web/src/components/SchemaTypeNotFound.vue | 20 ++ .../__tests__/useContentTypes.spec.ts | 15 + web/src/composables/useContentTypes.ts | 28 +- web/src/composables/useSchemaGate.ts | 61 ++++ web/src/i18n/messages.ts | 32 ++- web/src/lib/__tests__/schemaFields.spec.ts | 56 ++++ web/src/lib/schemaFields.ts | 104 +++++++ web/src/lib/schemaRows.ts | 6 +- web/src/router/__tests__/routerGuard.spec.ts | 34 +++ web/src/router/index.ts | 5 + web/src/stores/__tests__/contentTypes.spec.ts | 15 +- web/src/stores/contentTypes.ts | 23 +- web/src/views/SchemaTypeView.vue | 102 +++++++ web/src/views/SchemaView.vue | 63 ++--- .../views/__tests__/SchemaTypeView.spec.ts | 265 ++++++++++++++++++ web/src/views/__tests__/SchemaView.spec.ts | 79 +++++- web/src/views/__tests__/schemaTestKit.ts | 29 +- web/visual/states.ts | 32 ++- 24 files changed, 1220 insertions(+), 88 deletions(-) create mode 100644 features/schema_builtin_view.feature create mode 100644 features/schema_builtin_view.qa.md create mode 100644 web/src/components/SchemaFieldTable.vue create mode 100644 web/src/components/SchemaTypeNotFound.vue create mode 100644 web/src/composables/useSchemaGate.ts create mode 100644 web/src/lib/__tests__/schemaFields.spec.ts create mode 100644 web/src/lib/schemaFields.ts create mode 100644 web/src/views/SchemaTypeView.vue create mode 100644 web/src/views/__tests__/SchemaTypeView.spec.ts diff --git a/features/schema_builtin_view.feature b/features/schema_builtin_view.feature new file mode 100644 index 0000000..5f57d98 --- /dev/null +++ b/features/schema_builtin_view.feature @@ -0,0 +1,171 @@ +Feature: Read-only view of a built-in content type + As an owner or admin + I want to open a built-in type from the Schema list and read its fields + So that I can see the rules RenewCMS applies without being able to change them + + Background: + Given the SPA calls the API with relative URLs under /v1 and the "jwt" HttpOnly cookie + And GET /v1/builtin-type returns [{key, name, fields}] for owners and admins only + And each field is {key, label, type, required, unique, default, min, max, options} + And API errors are plain text + And the route /schema/:key has meta auth "verified" and title "Schema" + And the contentTypes store already exposes builtinItems, builtinStatus and load({builtin: true}) + And the view takes its data from builtinItems, matched on the route key, and never calls GET /v1/builtin-type/{key} + And only owners and admins can use Schema; the SPA decides from the session role, the API still enforces it + And a session whose role is neither owner nor admin is a test double for the forbidden states + And the built-in types are articles ("Articles"), authors, sites, media and users with 5, 5, 8, 6 and 6 fields in the sample data + + Scenario: A built-in row of the Schema list is a link + Given the Schema list is Populated + When the user looks at the five built-in rows + Then each row is a single link to /schema/ whose accessible name is the type name + And the row keeps its lock icon, name, "Built-in" badge, key, field count and a chevron-right at the end + And on desktop its "Last updated" cell reads "Managed by RenewCMS" + And below 640 px the card of a built-in type shows " · fields" with no "Updated" text and a chevron-right + And custom rows are not links and show no chevron + + Scenario: Opening a built-in type from the list + Given the Schema list is Populated + When the user activates the "Articles" row + Then the router navigates to /schema/articles + And GET /v1/builtin-type is not called a second time + + Scenario: Read-only view of a built-in type (design state 6, desktop) + Given an owner or admin is signed in + And GET /v1/builtin-type returns the type "articles" named "Articles" with the fields + | label | key | type | required | unique | min | max | default | + | Title | title | text | true | false | | 200 | | + | Slug | slug | text | true | true | | | | + | Body | body | richtext | false | false | | 10000 | | + | Online | online | boolean | false | false | | | false | + | Published on | published_on | date | false | false | | | | + When they open /schema/articles + Then the breadcrumb is "Schema" (a link to /schema) then "Articles" + And the h1 "Articles" is shown with a lock icon and a "Built-in" badge + And an info alert titled "Managed by RenewCMS" says "Articles is a built-in type. You can read its fields here, but you can't edit it, delete it or add fields." + And a table has the columns "Label", "Key", "Type", "Rules" + And the rows are, in this order + | Label | Key | Type | Rules | + | Title | title | Text | Required · up to 200 characters | + | Slug | slug | Text | Required · unique | + | Body | body | Rich text | Up to 10,000 characters | + | Online | online | Yes or no | Off by default | + | Published on | published_on | Date | – | + And each row starts with the icon of its type + And the note "Entries of built-in types are managed from their own screens, like Articles and Authors." is shown under the table + And there is no "New content type", edit, delete, add field, save or discard action + And the keys are shown in the mono style + And GET /v1/content-type and GET /v1/builtin-type are each called once + + Scenario: Read-only view of a built-in type on mobile + Given the same data and a 390 px wide viewport + When they open /schema/articles + Then the topbar shows an arrow-left and the title "Articles" + And the fields are cards in order, each with the icon box of its type, the label, and the key in mono followed by " · " and the rules + And the Type column is not shown + And the "Built-in" badge, the alert and the note are shown + + Scenario Outline: Field types show their label and icon + Given a built-in field of type "" + Then the Type cell reads "