172 lines
9.4 KiB
Gherkin
172 lines
9.4 KiB
Gherkin
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/<its key> 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 "<key> · <n> 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 "<type>"
|
||
Then the Type cell reads "<label>" with the icon <icon>
|
||
|
||
Examples:
|
||
| type | label | icon |
|
||
| text | Text | type |
|
||
| richtext | Rich text | pilcrow |
|
||
| number | Number | hash |
|
||
| boolean | Yes or no | toggle-left |
|
||
| date | Date | calendar |
|
||
| select | Choice | list |
|
||
|
||
Scenario Outline: The Rules cell is derived from the field
|
||
Given a field of type "<type>" with <settings>
|
||
Then the Rules cell reads "<rules>"
|
||
|
||
Examples:
|
||
| type | settings | rules |
|
||
| text | required, max 200 | Required · up to 200 characters |
|
||
| text | required, unique | Required · unique |
|
||
| richtext | max 10000 | Up to 10,000 characters |
|
||
| boolean | default false | Off by default |
|
||
| boolean | default true | On by default |
|
||
| date | nothing | – |
|
||
| text | min 3, max 80 (proposed copy) | 3 to 80 characters |
|
||
| text | min 3 (proposed copy) | At least 3 characters |
|
||
| number | min 1, max 5000 (proposed copy) | Between 1 and 5000 |
|
||
| number | min 1 (proposed copy) | At least 1 |
|
||
| number | max 5000 (proposed copy) | At most 5000 |
|
||
| select | 3 options (proposed copy) | 3 choices |
|
||
| text | default "Draft" (proposed copy) | Default: Draft |
|
||
|
||
Scenario: Back to the list
|
||
Given the read-only view is shown
|
||
When the user activates the "Schema" breadcrumb, or the arrow-left on mobile
|
||
Then the router navigates to /schema
|
||
|
||
Scenario: Deep link and reload load what the view needs
|
||
Given the user opens /schema/articles as the first page of the session
|
||
Then the session is resolved, then GET /v1/builtin-type is called once
|
||
And the view shows the read-only view when it answers 200
|
||
|
||
Scenario: Loading
|
||
Given GET /v1/builtin-type has not answered
|
||
When an owner opens /schema/articles
|
||
Then nothing is shown in the content area during the first 150 ms
|
||
And after 150 ms skeleton rows are shown
|
||
And the not-found page and the 403 page are not shown
|
||
|
||
Scenario Outline: Unknown key
|
||
Given GET /v1/builtin-type returns the five built-in types
|
||
When an owner opens <path>
|
||
Then the page "Content type not found" is shown with "It may have been deleted, or the address may be mistyped."
|
||
And the URL stays <path> and nothing redirects
|
||
And no field table is shown
|
||
|
||
Examples:
|
||
| path | why |
|
||
| /schema/unknown | a mistyped key |
|
||
| /schema/events | a custom type; its builder is a later slice |
|
||
| /schema/new | the builder is a later slice |
|
||
|
||
Scenario Outline: Error
|
||
Given GET /v1/builtin-type <failure>
|
||
When an owner opens /schema/articles
|
||
Then an alert shows "Couldn't load content types"
|
||
And it shows "GET /v1/builtin-type failed. Check your connection and try again."
|
||
And a "Try again" action is shown
|
||
And no table is shown
|
||
|
||
Examples:
|
||
| failure |
|
||
| answers 500 |
|
||
| fails (network) |
|
||
|
||
Scenario: Retry recovers
|
||
Given the view is in the Error state
|
||
When the user activates "Try again"
|
||
Then GET /v1/builtin-type is called again
|
||
And when it answers 200 the read-only view replaces the alert
|
||
|
||
Scenario: Forbidden for a user who is not owner or admin
|
||
Given a verified user whose role is neither owner nor admin is signed in
|
||
When they open /schema/articles
|
||
Then the URL stays /schema/articles and nothing redirects
|
||
And the page shows "You don't have access to Schema"
|
||
And it shows "Only owners and admins can change content types. You can still add and edit entries from the Content menu."
|
||
And a "Go to Home" action navigates to /home
|
||
And GET /v1/builtin-type is never called
|
||
|
||
Scenario: The API answers 403
|
||
Given the session says owner or admin but GET /v1/builtin-type answers 403
|
||
When they open /schema/articles
|
||
Then the same "You don't have access to Schema" page is shown
|
||
|
||
Scenario: An unverified or signed-out user keeps the existing redirects
|
||
Given the user is not verified or not signed in
|
||
When they open /schema/articles
|
||
Then they are redirected to /register/pending or /login as for any other "verified" route
|
||
|
||
Scenario: The list and the view share one load
|
||
Given the user opens /schema, then /schema/articles, then goes back
|
||
Then GET /v1/builtin-type and GET /v1/content-type are each called once in the session
|