Files
RenewCMS/features/remove_legacy_article_image_alias.feature
T

43 lines
2.2 KiB
Gherkin

Feature: The legacy POST /v1/article/{id}/image alias is removed
As the maintainer of RenewCMS
I want the editor to upload through /v1/media only and the article alias deleted
So that there is one way to add an image and no dead route to keep
Background:
Given this is a Go API change in a slice that is otherwise SPA only, made at the user's request
And features/upload_article_image.feature and its .qa.md are deleted, with their tests
And api/router.go no longer mounts r.Post("/{id}/image", ...) in NewArticleRouter, and the
imageHandler variable and the api/handlers/image import are removed from it
And the package api/handlers/image (PostLegacyArticleImage, its NewHandler and its helpers) is deleted
And CreateImageUseCase and GetArticleUseCase stay: both are used by the media handler and
the article handler, and api/pkg/upload stays because the media handler uses it
And the rest of the protected article group is unchanged, still behind jwtauth.Authenticator,
RequireCurrentToken and RequireVerifiedUser
And docs/architecture.md no longer lists api/handlers/image
And POST /v1/media/ is the only upload route, and DELETE /v1/article/{id}/image/{imageId}
stays unmounted, as before
Scenario Outline: The removed routes are not found
Given a valid jwt cookie for verified user 1 and an article with id 1
When the client sends <method> <path> with a valid PNG as multipart field "file"
Then the response status is 404
And the image repository's Create is never called
And no image exists afterwards
Examples:
| method | path |
| POST | /v1/article/1/image |
| DELETE | /v1/article/1/image/10 |
Scenario: Uploading still works through the media route
Given a valid jwt cookie for verified user 1
When the client sends POST /v1/media/ with a real PNG named "before.png"
Then the response status is 201 and the body is the library item with a "url" and an "id"
And GET /v1/media/ lists it
Scenario: The rest of the article router is unchanged
Given a valid jwt cookie for verified user 1 and an article with id 1
When the client sends PATCH /v1/article/1/publish
Then the response is as before this slice