feat: remove the 10,000-character article body limit and make the New article body optional
This commit is contained in:
1 parent
5e05b606a7
commit
10ec74c8cf
28 files changed
+860
-397
No files matched your search
@@ -0,0 +1,124 @@
|
||||
Feature: Article bodies have no length limit and the body is optional
|
||||
|
||||
As a verified RenewCMS owner
|
||||
I want to create an article with only a title and write articles of any length
|
||||
So that starting a draft is one field and long articles are never blocked
|
||||
|
||||
Background:
|
||||
Given POST /v1/article/ and PATCH /v1/article/{id} sit inside the jwt-protected group
|
||||
And the request structs PostArticle and UpdateArticleBody validate through validator.Validate.Struct
|
||||
And PostArticle.Title keeps validate "required,min=3,max=200"
|
||||
And PostArticle.Body and UpdateArticleBody.Body carry no validate tag: no max, no required
|
||||
And a body is stored and returned as given; an absent "body" key is treated as ""
|
||||
And success bodies are the article JSON (id, title, body, body_format, is_online, created_at, updated_at)
|
||||
And a new article is created offline (is_online false)
|
||||
|
||||
Scenario Outline: Create with only a title succeeds in every body format
|
||||
Given a valid jwt cookie for a verified user
|
||||
When the client sends POST /v1/article/<query> with JSON <payload>
|
||||
Then the status is 201
|
||||
And the response JSON has title "Choosing tiles for a small bathroom", is_online false, body_format "<format>" and body <rendered>
|
||||
And the fake article repository holds one article with Body ""
|
||||
|
||||
Examples:
|
||||
| query | payload | format | rendered |
|
||||
| | {"title": "Choosing tiles for a small bathroom"} | markdown | "" |
|
||||
| ?format=html | {"title": "Choosing tiles for a small bathroom"} | html | "" |
|
||||
| ?format=json | {"title": "Choosing tiles for a small bathroom"} | json | [] |
|
||||
| | {"title": "Choosing tiles for a small bathroom", "body": ""} | markdown | "" |
|
||||
|
||||
Scenario: A body of 120,000 characters is accepted on create
|
||||
Given a valid jwt cookie for a verified user
|
||||
When the client sends POST /v1/article/ with a title of 3 characters or more and a body of 120000 characters
|
||||
Then the status is 201
|
||||
And the repository holds the full 120000-character body, unmodified
|
||||
|
||||
Scenario Outline: Update the body with no length limit
|
||||
Given an article with id 12 exists
|
||||
And a valid jwt cookie for a verified user
|
||||
When the client sends PATCH /v1/article/12 with a body of <length> characters
|
||||
Then the status is 200
|
||||
And the repository body for article 12 has <length> characters
|
||||
|
||||
Examples:
|
||||
| length |
|
||||
| 10001 |
|
||||
| 120000 |
|
||||
|
||||
Scenario: Update the body to empty
|
||||
Given an article with id 12 exists with a non-empty body
|
||||
When the client sends PATCH /v1/article/12 with JSON {"body": ""}
|
||||
Then the status is 200 and the repository body is ""
|
||||
And GET /v1/article/12?format=json returns body []
|
||||
|
||||
Scenario Outline: Title rules are unchanged
|
||||
Given a valid jwt cookie for a verified user
|
||||
When the client sends POST /v1/article/ with JSON <payload>
|
||||
Then the status is 400, the response is plain text from http.Error, and no article is created
|
||||
|
||||
Examples:
|
||||
| payload |
|
||||
| {"body": "Hello"} |
|
||||
| {"title": "Ti", "body": "Hello"} |
|
||||
| {"title": "<201 characters>"} |
|
||||
|
||||
Scenario: Existing guards on PATCH are unchanged
|
||||
When PATCH /v1/article/abc is sent
|
||||
Then the status is 400 with the uint32 id error text
|
||||
When PATCH /v1/article/999 is sent and no such article exists
|
||||
Then the status is 404 with the article-not-found text
|
||||
When PATCH /v1/article/12 is sent with malformed JSON
|
||||
Then the status is 400 with apperr.BodyErrorMessage
|
||||
|
||||
Scenario: The SPA no longer limits or counts the body
|
||||
Given the Vue SPA
|
||||
Then the constant BODY_MAX_LENGTH no longer exists
|
||||
And the CharacterCounter component stays (ProfileView and CreateApiKeyModal still use it) but EditorView and NewArticleModal no longer import it
|
||||
And the editor has no "Near the limit" or "Too long" state
|
||||
|
||||
Scenario: Editor status bar shows a neutral count
|
||||
Given the editor is open on /article/12/edit with a loaded article whose body has 1204 words and 7318 characters
|
||||
Then the EditorStatusBar reads "1,204 words · 7,318 characters"
|
||||
And the count updates as the body changes
|
||||
And a new empty article reads "0 words · 0 characters"
|
||||
And the count carries no warning, error colour or icon at any length
|
||||
|
||||
Scenario: Editor states at 120,000 characters
|
||||
Given the editor holds an article body of 120000 characters (19,845 words)
|
||||
Then the count reads "19,845 words · 120,000 characters", neutral
|
||||
When the body is edited
|
||||
Then the state is Unsaved changes, and Save and Publish ("Save and publish") are enabled
|
||||
When the user saves and PATCH /v1/article/12 is pending
|
||||
Then the status shows the spinner with "Saving 120,000 characters. This can take a few seconds.", Save is disabled and the page stays editable
|
||||
When PATCH resolves 200
|
||||
Then the status reads Saved with the time and the count is unchanged
|
||||
When PATCH instead resolves 500, 413 or a network failure
|
||||
Then the editor shows "Couldn't save. Your text is kept. Retry." and the body is unchanged
|
||||
And Retry resends the same content
|
||||
|
||||
Scenario: NewArticleModal is title-only
|
||||
Given NewArticleModal is open
|
||||
Then it shows the Title field with its "0 / 200" counter and "3 to 200 characters." help, "Cancel" and "Create draft"
|
||||
And there is no First paragraph field
|
||||
When the user submits a valid title
|
||||
Then POST /v1/article/ is sent with JSON {"title": "<title>"} (no body key)
|
||||
|
||||
Scenario Outline: NewArticleModal states
|
||||
Given NewArticleModal is open with Title "<title>"
|
||||
When <trigger>
|
||||
Then <outcome>
|
||||
|
||||
Examples:
|
||||
| title | trigger | outcome |
|
||||
| | it opens | Default (empty): Title focused, counter "0 / 200" |
|
||||
| Ti | the field blurs or Create draft is pressed | Validation: "Use at least 3 characters.", counter in error style, no request |
|
||||
| Choosing tiles for a small bathroom | Create draft is pressed | Submitting: "Creating…", Title and buttons disabled, not dismissible |
|
||||
| Choosing tiles for a small bathroom | POST resolves 201 (id 42) | modal closes, navigates to /article/42/edit, toast "Draft created" id "article-created-42" |
|
||||
| Choosing tiles for a small bathroom | POST resolves 400 | Title rejected: "Check this title and try again." and alert "Something in the form isn't valid. Check the highlighted fields." |
|
||||
| Choosing tiles for a small bathroom | POST resolves 500 or never reaches server | Error: alert "Couldn't create the article. Your text is still here. Try again in a moment." |
|
||||
|
||||
Scenario: Integration API reference no longer says max 10000
|
||||
Given the Integration screen's request-body tables for POST /v1/article/ and PATCH /v1/article/{id}
|
||||
Then POST lists: title string required 3-200; body string optional, no length limit
|
||||
And PATCH lists: body string optional, no length limit
|
||||
And no text on the screen contains "max 10000"
|
||||
Reference in new issue
Block a user